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)
T-SQL : does this geographic distance algorithm fail to take curvature of earth into account
質問
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
解決
所属していません StackOverflow