Calculate distance between 2 GPS coordinates

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

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

29条回答
  •  清歌不尽
    2020-11-22 00:09

    This is very easy to do with geography type in SQL Server 2008.

    SELECT geography::Point(lat1, lon1, 4326).STDistance(geography::Point(lat2, lon2, 4326))
    -- computes distance in meters using eliptical model, accurate to the mm
    

    4326 is SRID for WGS84 elipsoidal Earth model

提交回复
热议问题