# Thread: Coordinates.distance() question

1. ## Coordinates.distance() question

what formula does the Coordinates.distance() use? i would like to know because i want to convert x,y to latitude,longitude for a webapp..

3. ## Re: Coordinates.distance() question

Code:
```
public static double distanceBetween(double lat1, double lon1, double lat2, double lon2)
{
try {
double a = Math.sin(dlat / 2.0) * Math.sin(dlat / 2.0) + Math.cos(lat1Rad) * Math.cos(lat2Rad) * Math.sin(dlon / 2.0) * Math.sin(dlon / 2.0);
double c = 2.0 * Float11.asin(Math.min(1.0, Math.sqrt(a)));
return 6367000.0 * c; // 6367000 = radius of Earth at 45° of latitude
}
catch (Exception e) {
return Double.NEGATIVE_INFINITY;
}

}```
you have to include a float11.java library

Rocco

4. ## Re: Coordinates.distance() question

thanks for the code and the link!!
another question... how can i convert the coordinates from gps to pixel coordinates?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•