How to get straight distance between two location in android?

后端 未结 3 1653
遇见更好的自我
遇见更好的自我 2021-01-31 12:54

First read Question carefully ...

I need straight distance, not by walking,car,or etc.

Take a look to this image which given be

3条回答
  •  猫巷女王i
    2021-01-31 13:38

    The Haversine function is used to find the distance between two points on a sphere.

    It's fairly straightforward to extend this to finding the straight line distance between two points on the Earth. The Earth is not a perfect sphere, but this is still a good approximation using a standard measurement (called WGS84) for the radius at the equator.

    As CommonsWare has said, you can do this very simply by using distanceBetween(), which uses the Haversine function and the WGS84 radius.

    For better understanding of implementation/math, take a look at this sample code in Python.

提交回复
热议问题