码迷,mamicode.com
首页 > 数据库 > 详细

[MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离

时间:2014-12-18 16:43:53      阅读:380      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   sp   on   2014   log   ef   

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

 

bubuko.com,布布扣

[MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离

标签:style   blog   http   ar   sp   on   2014   log   ef   

原文地址:http://www.cnblogs.com/kkun/p/Spatial-Data-Geography.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!