2

I am implementing an application to search for nearest local venues from a gps coordinates database.

i am using the Location class distanceTo() function to calculate distance between two location the current one and the one from the database.

currentloc.setLatitude(loc.getLatitude());
currentloc.setLongitude(loc.getLongitude());

dbcurrent.setLatitude(C.getDouble(latindex));
dbcurrent.setLongitude(C.getDouble(lonindex));
distance = currentloc.distanceTo(dbcurrent);

this work fine and i am able to use this distance to calculate proximity in the rest of my app, but the distance it self is not apparently in meters i am getting result like 4134801.4 i am sure that the distance is 3200meters in this case.

Is there any explanation or solution for this issue.

thank you all.

Mohamed Ben Dhaou
  • 1,124
  • 2
  • 10
  • 16
  • First double check your values to guarantee they are correct. Then make a test call where you get distance for maybe one second of longitude difference. See what happens. – Zan Lynx Apr 30 '11 at 00:17
  • 1
    possible duplicate of [Android : Location.distanceTo not working correctly?](http://stackoverflow.com/questions/531324/android-location-distanceto-not-working-correctly) – Zan Lynx Apr 30 '11 at 00:18
  • Wondering how that other duplicate question was possibly missed in the review of existing questions the SO does before you ask? – Zan Lynx Apr 30 '11 at 00:20

1 Answers1

0

distanceTo() work correctly, it is your fault. Such high distances can happen if your provide (0,0) as other point.

AlexWien
  • 28,470
  • 6
  • 53
  • 83