I have two coordinates with latitude and longitude, and I want to calculated the distance between them in meters/miles. Does the vividsolutions JTS library have the functionality to do this? If there is a function I can use please point me to it, thanks!
Asked
Active
Viewed 623 times
0
-
No idea. But it's *just* [math](https://www.geeksforgeeks.org/program-distance-two-points-earth/). – Elliott Frisch May 15 '22 at 02:32
-
google [haversine](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiVx7zr4uD3AhUVOuwKHYecAAkQFnoECAwQAQ&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHaversine_formula&usg=AOvVaw1HT1mtRoZyd9Odl6dK5jfk) formula however on ellipsoid its more complicated so curve integration is needed ... – Spektre May 15 '22 at 05:28
-
Does this answer your question? [Calculate large distance between two points using GeoTools](https://stackoverflow.com/questions/60320999/calculate-large-distance-between-two-points-using-geotools) – Ian Turton May 15 '22 at 11:19
1 Answers
1
JTS Will calc distance with the measurement unit the SRID is based on (so if you're using 4326 the number will literally be the diff in lat/lng). If you can convert to an SRID that is metric based, you can get a measurement in meters using distance, or distance3d (if your objects have a 3rd dimension for elevation). Then convert that to other units if you need to.
You can also do the math, but isn't a basic conversion - it takes into account the radius of the earth, and other geometric issues (things the spatial reference will do for you). If prefer that way search for something like "convert lat long to meters" and something will pop up.

slambeth
- 887
- 5
- 17