【问题标题】:T-SQL : does this geographic distance algorithm fail to take curvature of earth into accountT-SQL:这个地理距离算法是否没有考虑地球曲率
【发布时间】:2013-06-06 14:25:30
【问题描述】:

下面的距离计算是否没有考虑到地球的曲率?

"普通地球模型上的 STDistance() 与精确的偏差 测地线距离不超过 0.25%。 "

文档:http://msdn.microsoft.com/en-us/library/bb933808.aspx

create proc findNearbyZips
@lat float,
@lon float,
@radius float
as
begin

declare @geo geography;
set @geo = geography::Point(@lat, @lon,4326);

with ZipsWithinRadius as
(
select zip5, city, state from zips
where
@geo.STDistance( zips.centroidGeoLocationInBinaryFormat ) <= @radius * 5280.00
)
select [...]


end

【问题讨论】:

  • 您的问题措辞表明您认为它确实没有考虑到这一点。为什么不给我们一些Expected Results and (presumably different) Actual Results
  • 300 英里外的邮政编码满足 100 英里半径条件。例如。波士顿和费城。
  • 5280这个数字是什么意思?此外,请检查您是否使用了正确的单位,这样当它应该是公里时,您就不会以英里为单位进行计算,反之亦然。
  • @Jakob 你有它,我想。 5280 是一英里的英尺数,但我很确定 STDistance 这里需要米。
  • 啊哈。让它成为雅各布的答案,我会接受。感谢您指出我的愚蠢错误。

标签: tsql geography


【解决方案1】:

确保您使用正确的单位,这样当它应该是米时,您就不会以英里计算,反之亦然。如有疑问,请假设 SI 基本单位 (http://en.wikipedia.org/wiki/SI_base_unit)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    相关资源
    最近更新 更多