问题描述
我正在尝试查询距另一个位置指定距离内的任何位置.该查询不是问题,但由geoography.STDistance返回的距离是.
I'm trying to query any locations within a specified distance from another location. The query is not the problem, but the distance returned by geography.STDistance is.
看来STDistance
对靠近赤道的位置进行了相当准确的计算,但是我需要这样做才能与北欧国家的位置配合使用.挪威,瑞典,芬兰等...
It seems STDistance
makes fairly accurate calculations on locations close to the equator, but I need this to work with locations in the nordic countries. Norway, Sweden, Finland and so on...
根据我在瑞典北部地区进行的计算,该距离的误差约为2.38倍?!预期结果为1070米,返回距离为2537,28850694302米
According to my calculations, made on locations in northern Sweden, the distance is wrong by a factor of around 2.38?!Expected result is 1070 meters and returned distance is 2537,28850694302 meters
我的查询如下:
DECLARE @g geography = geography::STGeomFromText('POINT(65.580254 22.179428)', 4326)
SELECT name, [pos].STSrid as srdi, [pos].STDistance(@g) as d
FROM [GPSCHAT].[dbo].[USERS]
其他位置"的坐标为(65,578541 22,202286)(存储在SRID 4326中)
and the "other location" has coordinates (65,578541 22,202286) (stored with SRID 4326)
我猜想这与距赤道的距离(靠近极圈)有关,但是必须有一种方法可以根据纬度更精确地计算出这一点,还是我错了?
I'm guessing this has to do with the distance from the equator (close to the polar circle), but there has to be a way to calculate this more accurately based on the Latitude or am i wrong?
推荐答案
似乎您正在使用'X,Y'创建点.
从文本创建点时,请改用"Y,X".
It looks like you're creating your point using 'X, Y'.
When creating a point from text, use 'Y, X' instead.
查看此 MSDN文章了解更多信息.
这篇关于MS SQL geography.STDistance返回错误的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!