I have a problem calculating the distance between two geotomes.
Geodetic points:
position1 = mapView.getProjection().fromPixels( (int) e.getX(), (int) e.getY());
and the other
double lat = 35.1064; double lng = 22.556412; GeoPoint position2 = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
Then I create two locations:
Location loc = new Location(""); loc.setLatitude(position1.getLatitudeE6()); loc.setLongitude(position1.getLongitudeE6()); Location loc2 = new Location(""); loc.setLatitude(position2.getLatitudeE6()); loc.setLongitude(position2.getLongitudeE6());
And then I calculate the distance:
float distance = loc.distanceTo(loc2);
and I will round it:
Math.round(distance);
But I get results like:
1.4331783E7
What am I doing wrong?
source share