What Distance Does Distanceto Returns?
Does it take into account altitude changes? I mean, if I start in left vertex of this triangle and end in the right upper vertex, does it return distance a or b? double distanceInM
Solution 1:
The altitude is not taken into account when computing Location.distanceTo
.
You can test it like this:
Locationlocation1=newLocation("");
location1.setLatitude(40);
location1.setLongitude(-4);
location1.setAltitude(0);
Locationlocation2=newLocation("");
location2.setLatitude(30);
location2.setLongitude(-3);
location2.setAltitude(0);
Locationlocation3=newLocation("");
location3.setLatitude(30);
location3.setLongitude(-3);
location3.setAltitude(100);
Log.e("Without altitude", ""+location1.distanceTo(location2));
Log.e("With altitude", ""+location1.distanceTo(location3));
Log.e("Different altitude", ""+location2.distanceTo(location3));
This is the output:
E/Without altitude﹕ 1113141.5
E/With altitude﹕ 1113141.5
E/Different altitude﹕ 0.0
Post a Comment for "What Distance Does Distanceto Returns?"