|
From: koma <ko...@ko...> - 2006-09-03 20:16:22
|
Hi
I'm new to geotools and I start using it to calculate the distance between
airports.
>From my research i learned that this distance is called orthodromic distanc=
e
and there are ellipsoids that appromixate the earth surface etc;..
My problem is that my results do not match with what I find in the numerous
online tools that serve the same purpose of calculating this distance;
for BRU-JFK, I get 8715 km while it should result in 5901 km. I tried to
document as complete as possible how I get to this result below.
*** Here is the part of my code where I actually call geotools - I put a
lot of logging in there so you can see the values below.
public class Airport {
................
=09public Measure getOrthodromicDistance(Airport otherAirport) {
=09=09
=09=09double x1 =3D this.getPersistentLatLong().getLatitudeValue().doubleVa=
lue();
=09=09double y1 =3D this.getPersistentLatLong().getLongitudeValue().doubleV=
alue();
=09=09double x2 =3D
otherAirport.getPersistentLatLong().getLatitudeValue().doubleValue();
=09=09double y2 =3D
otherAirport.getPersistentLatLong().getLongitudeValue().doubleValue();
=09=09
=09=09log.info("x1: " + x1);
=09=09log.info("y1: " + y1);
=09=09log.info("x2: " + x2);
=09=09log.info("y2: " + y2);
=09=09double distanceInMeter =3D DefaultEllipsoid.WGS84.orthodromicDistance=
(x1,
y1, x2, y2);
=09=09
=09=09log.info("distance in meter: " + distanceInMeter);
=09=09
=09=09return Measure.valueOf(distanceInMeter, SI.METER);
=09}
**** Here is how I called this function in a test case :
=09=09Measure expectedDistance =3D null;=20
=09=09Measure actualDistance =3D null;
=09=09
=09=09AirportFilter filter =3D new AirportFilter();
=09=09filter.setLikeIcao("EBBR");
=09=09Airport brussels =3D
(Airport)BusinessFactory.getSafeAirportsFacade().findAirports(filter).get(0=
);
=09=09filter.setLikeIcao("LGAV");
=09=09Airport athens =3D
(Airport)BusinessFactory.getSafeAirportsFacade().findAirports(filter).get(0=
);
=09=09filter.setLikeIcao("KJFK");
=09=09Airport jfk =3D
(Airport)BusinessFactory.getSafeAirportsFacade().findAirports(filter).get(0=
);
=09=09assertTrue(brussels!=3Dnull);
=09=09assertTrue(athens!=3Dnull);
=09=09assertTrue(jfk!=3Dnull);
=09=09log.info("BRUSSELS: " + brussels.getPersistentLatLong().getLatLong())=
;
=09=09log.info("ATHENS:" + athens.getPersistentLatLong().getLatLong());
=09=09log.info("JFK:" + athens.getPersistentLatLong().getLatLong());
=09=09
=09=09
=09=09log.info("*******CALCULATING BRU-JFK");
=09=09expectedDistance =3D Measure.valueOf(5901, 1, SI.KILO(SI.METER));
=09=09actualDistance =3D brussels.getOrthodromicDistance(jfk);
=09=09log.info("bru-jfk:" + actualDistance + "<> expected " + expectedDista=
nce);
=09=09log.info("*******CALCULATING JFK-ATH");
=09=09expectedDistance =3D Measure.valueOf(7952, 1, SI.KILO(SI.METER));
=09=09actualDistance =3D jfk.getOrthodromicDistance(athens);
=09=09log.info("jfk-ath:" + actualDistance+ "<> expected " + expectedDistan=
ce);
=09=09
=09=09log.info("*******CALCULATING BRU-ATH");
=09=09expectedDistance =3D Measure.valueOf(2104, 1, SI.KILO(SI.METER));
=09=09actualDistance =3D brussels.getOrthodromicDistance(athens);
=09=09
=09=09log.info("bru-ath:" + actualDistance+ "<> expected " + expectedDistan=
ce);
***************=09=09
********** Here is the log output and you can see the mismatch in the
results !
21:53:35,949 INFO AbstractTest:53 - BRUSSELS: [50.901389 =C2=B0, 4.484444 =
=C2=B0]
21:53:35,953 INFO AbstractTest:54 - ATHENS:[37.936358 =C2=B0, 23.944467 =
=C2=B0]
21:53:35,954 INFO AbstractTest:55 - JFK:[37.936358 =C2=B0, 23.944467 =C2=
=B0]
21:53:35,955 INFO AbstractTest:58 - *******CALCULATING BRU-JFK
21:53:35,966 INFO Airport:105 - x1: 50.901389
21:53:35,967 INFO Airport:106 - y1: 4.484444
21:53:35,968 INFO Airport:107 - x2: 40.63975
21:53:35,968 INFO Airport:108 - y2: -73.778925
21:53:36,011 INFO Airport:112 - distance in meter: 8715665.085436275
21:53:36,022 INFO AbstractTest:62 - bru-jfk:(8.7156650854362752E6 =C2=B1 1=
.9E-9)
m<> expected (5901.0 =C2=B1 1.0) km
21:53:36,023 INFO AbstractTest:64 - *******CALCULATING JFK-ATH
21:53:36,023 INFO Airport:105 - x1: 40.63975
21:53:36,024 INFO Airport:106 - y1: -73.778925
21:53:36,026 INFO Airport:107 - x2: 37.936358
21:53:36,027 INFO Airport:108 - y2: 23.944467
21:53:36,027 INFO Airport:112 - distance in meter: 1.0841626343788018E7
21:53:36,028 INFO AbstractTest:68 - jfk-ath:(1.08416263437880192E7 =C2=B1
1.9E-9) m<> expected (7952.0 =C2=B1 1.0) km
21:53:36,028 INFO AbstractTest:70 - *******CALCULATING BRU-ATH
21:53:36,029 INFO Airport:105 - x1: 50.901389
21:53:36,029 INFO Airport:106 - y1: 4.484444
21:53:36,030 INFO Airport:107 - x2: 37.936358
21:53:36,030 INFO Airport:108 - y2: 23.944467
21:53:36,031 INFO Airport:112 - distance in meter: 2563549.1161598773
21:53:36,032 INFO AbstractTest:74 - bru-ath:(2.56354911615987712E6 =C2=B1
4.7E-10) m<> expected (2104.0 =C2=B1 1.0) km
=09=09
Somebody can tell me what I'm doing wrong ???
TIA !
Koen
--=20
View this message in context: http://www.nabble.com/Orthodromic-distance-ca=
lculation-between-airports%3A-wrong-results-tf2212018.html#a6126286
Sent from the geotools-gt2-users forum at Nabble.com.
|