How can I calculate distance between multiple latitude and longitude?

后端 未结 4 1952
Happy的楠姐
Happy的楠姐 2021-01-29 16:02

I want to calculate total distance between each points both contains lat and long, these points are stored in local database, so the scenario is I want to calculate distance fro

4条回答
  •  时光取名叫无心
    2021-01-29 16:19

    I'm not sure if I understand the scope of this question. Do you need to take into account the curvature of earth? Or it is just 2 random points?

    If it's the first : I can show you this link as i cannot help you out:

    https://www.movable-type.co.uk/scripts/latlong.html

    If it is the latter:

    Suppose 1 is latitude and 2 is longitude, so that a1 is latitude of point A.

    Calculating 2 points in a plane is something like somethign like this:

    Distance = sqrt((a1−b1)+(a2−b2))

    So, to calculate for example distance from D to E is: sqrt((e1-d1) + (e2-d2))

提交回复
热议问题