SQL 的距离差异 - 为什么差异如此之大?

Distance difference in SQL - why so big discrepancy?

如果计算坐标之间的距离,我使用了2种方法,它们之间的差异很大(超过400米)。你知道为什么吗?以及所有计算方法中哪一种是最准确的?

第一名:

DECLARE @source geography = 'POINT(53.9202690124512 14.2586479187012)'
DECLARE @target geography = 'POINT(53.8970128 14.2387088)'

SELECT @source.STDistance(@target)

第二名:

SELECT geography::Point(53.9202690124512, 14.2586479187012, 4326).STDistance(geography::Point(53.8970128, 14.2387088, 4326))

geography::Point 期望纬度和经度按该顺序传递。 WKT 的 POINT 期望经度和纬度按该顺序传递。查看结果:

DECLARE @wkt_source geography = 'POINT(53.9202690124512 14.2586479187012)'
DECLARE @wkt_target geography = 'POINT(53.8970128 14.2387088)'

select @wkt_source.STAsText() as wkt_source, @wkt_target.STAsText() as wkt_target

declare @point_source geography = geography::Point(53.9202690124512, 14.2586479187012, 4326)
declare @point_target geography = geography::Point(53.8970128, 14.2387088, 4326)


select @point_source.STAsText() as point_source, @point_target.STAsText() as point_target

因此您需要交换一个或另一个来获得一致的结果(取决于哪个 lat/lng 是正确的)。