Calculate distance between 2 GPS coordinates

前端 未结 29 3527
青春惊慌失措
青春惊慌失措 2020-11-21 23:34

How do I calculate distance between two GPS coordinates (using latitude and longitude)?

29条回答
  •  时光说笑
    2020-11-21 23:49

    // Maybe a typo error ?
    We have an unused variable dlon in GetDirection,
    I assume

    double y = Math.Sin(dlon) * Math.Cos(lat2);
    // cannot use degrees in Cos ?
    

    should be

    double y = Math.Sin(dlon) * Math.Cos(dlat);
    

提交回复
热议问题