I am developing a desktop application and I have two points (latitude, longitude). How can I get the distance between these two points? I looked at the API, and most of them are javascript or a web interface. I am not developing a webpage. How can i do this in java?
I want the distance to the road, not the direct distance
If you have latitude and longitude, you can use the Haversine formula to calculate the distance between them - if you want a “straight line”.
EDIT: , , , , Directions API. - URL , XML, JSON-, .
, "JSON"!= "Javascript-based". JSON , , , Javascript.
Google : http://www.postalcodeworld.com/samples/distance.java.html , , , , .
This Great Circle Distance code is above probaby OK for most applications. However, if you need more accuracy, keep in mind that it may fail in some cases due to the fact that the earth is not an ideal sphere. In this case, you are talking about more complex algorithms.
Source: https://habr.com/ru/post/1777717/More articles:Joining sql views in oracle sql - sqlConstructor: is this the right call? - c ++How to intercept an authentication request in an ASP.net web form - authenticationTest boot system properties - javajQuery: any suggestions for preloading all images in dom sequentially? - jqueryC ++ 9 :: Casting "System :: Object ^ sender" for control type - visual-studio-2008CSS: 3 divs - resizing 2 outer divs automatically based on the width of the inner div / text - htmllist of video devices via terminal - unixTransactional Replication Issues - sql-serverTFS2010 Query - Find Tasks for Orphans? - tfs2010All Articles