首页 > 代码库 > [MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离
[MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离
DECLARE @BJ GEOGRAPHY
DECLARE @XT GEOGRAPHY
/*
GET Latitude/Longitude FROM here:http://www.travelmath.com/cities/Beijing,+China
the distance unit in SRID 4326 is the meter
*/
SELECT @BJ = geography::Point(‘39.92889‘, ‘116.38833‘, 4326)
SELECT @XT = geography::Point(‘37.0630556‘, ‘114.4941667‘, 4326)
SELECT
@BJ AS Beijing,
@XT AS Xingtai,
‘The distance is ‘ +
CAST(@BJ.STDistance(@XT)/1000 AS VARCHAR(MAX)) + ‘ km‘ AS Distance
[MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。