为了计算特定地理点的经纬度长度是多少米,我使用以下算法:
-- Geograpic Point Cordinates
DECLARE @LATTIDUDE REAL=45
DECLARE @LONGITUDE REAL=45
DECLARE @Distance REAL=10
-- Constants
DECLARE @ConvertionConstant AS FLOAT=2*PI()/360
DECLARE @MetersPerDegree AS FLOAT
DECLARE @LattidueInRadians AS FLOAT=@ConvertionConstant*@LATTIDUDE
DECLARE @LongitudeParameter1 AS FLOAT=111412.84
DECLARE @LongitudeParameter2 AS FLOAT=-93.5
DECLARE @LongitudeParameter3 AS FLOAT=0.118
SET @MetersPerDegree=(@LongitudeParameter1*COS(@LattidueInRadians))+(@LongitudeParameter2*(COS(3*@LattidueInRadians)))+(@LongitudeParameter3*COS(5*@LattidueInRadians))
DECLARE @LongitudeRangeTemp AS FLOAT=@Distance/(@MetersPerDegree/1000)
-- Results for longitude
SELECT @LongitudeRangeTemp AS DegreesForGivenKM
SELECT @MetersPerDegree AS MetersPerDegreeOfLongitude
-- Constants
DECLARE @LatitudeParameter1 AS FLOAT=111132.92
DECLARE @LatitudeParameter2 AS FLOAT=-559.82
DECLARE @LatitudeParameter3 AS FLOAT=1.175
DECLARE @LatitudeParameter4 AS FLOAT=-0.0023
-- Results for longitude
SET @MetersPerDegree=(@LatitudeParameter1+(@LatitudeParameter2*COS(2*@LattidueInRadians))+(@LatitudeParameter3*COS(4*@LattidueInRadians))+(@LatitudeParameter4*COS(6*@LattidueInRadians)))
DECLARE @LatitudeRangeTemp AS FLOAT=@Distance/(@MetersPerDegree/1000)
SELECT @LatitudeRangeTemp AS DegreesForGivenKM
SELECT @MetersPerDegree AS MetersPerDegreeOfLatitude
为公里添加了一个附加参数 - 代码将计算多少度等于给定的公里。
您可以自由地在函数中实现代码。