T-SQL : does this geographic distance algorithm fail to take curvature of earth into account

StackOverflow https://stackoverflow.com/questions/16964689

  •  31-05-2022
  •  | 
  •  

문제

Does the following distance calculation fail to take into account the curvature of the earth?

"The deviation of STDistance() on common earth models from the exact geodesic distance is no more than .25%. "

Docs: 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
도움이 되었습니까?

해결책

Make sure that you use the correct units so you dont calculate things in miles when it should be meters or vice versa. When in doubt, assume SI base units (http://en.wikipedia.org/wiki/SI_base_unit)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top