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