Ms SQL geography.STDistance 返回错误的距离

发布于 2024-11-17 17:10:21 字数 564 浏览 2 评论 0原文

我正在尝试查询距另一个位置指定距离内的任何位置。查询不是问题,而是 geography.STDistance 返回的距离有问题。

似乎 STDistance 对靠近赤道的位置进行了相当准确的计算,但我需要它来处理北欧国家的位置。挪威、瑞典、芬兰等等...

根据我在瑞典北部地点的计算,距离误差大约为2.38?! 预期结果是 1070 米,返回的距离是 2537,28850694302 米

我的查询如下所示:

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 存储)

我猜这与距赤道(靠近极圈)的距离,但必须有一种方法可以更准确地计算它基于纬度还是我错了?

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.

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...

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

My query looks like this:

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]

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半城柳色半声笛 2024-11-24 17:10:21

看起来您正在使用“X,Y”来创建您的观点。
从文本创建点时,请改用“Y, X”。

看看这个MSDN 文章 了解更多信息。

It looks like you're creating your point using 'X, Y'.
When creating a point from text, use 'Y, X' instead.

Check out this MSDN Article for some more info.

沉睡月亮 2024-11-24 17:10:21

为什么不使用另一个更适合您所在位置周围地球曲率的空间参考标识符呢? SRID 4326 的测量结果可能不如其他本地参考系统准确

Why don't you make use of another spatial reference identifier which fits better the earth curvature around your position. SRID 4326 might not been measured as accurate as other local referential systems

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文