How to find distance between two points using latitude and longitude

后端 未结 3 1086
逝去的感伤
逝去的感伤 2021-01-29 00:43

I have a ROUTES table which has columns SOURCE_AIRPORT and DESTINATION_AIRPORT and describes a particular route that an airplane would take to get from one to the other.

3条回答
  •  情歌与酒
    2021-01-29 01:05

    This would have probably been a better question for the Mathematics Stack Exchange, but I’ll provide some insight here. If you are relatively farmiliar with trigonometry, I’m sure you could understand the implementation given this resource: https://en.m.wikipedia.org/wiki/Haversine_formula. You are looking to compute the distance between two point on the surface of a sphere in terms of their distance across its surface (not a straight line, you can’t travel through the Earth).

    The page displays this formula: https://wikimedia.org/api/rest_v1/media/math/render/svg/a65dbbde43ff45bacd2505fcf32b44fc7dcd8cc0

    Where
    • φ1, φ2 are the latitude of point 1 and latitude of point 2 (in radians),
    • λ1, λ2 are the longitude of point 1 and longitude of point 2 (in radians).

    If you data is in degrees, you can simply convert to radians by multiplying by pi/180

提交回复
热议问题