Great Circle distance calculation
Is there any stored procedure or application that implements Great Circle
distance calculationHello JIM.H.,
> Great Circle distance calculation
> Is there any stored procedure or application that implements Great
> Circle
> distance calculation
In SQL Server 2005, no. In Katmai, maybe. Here it is as a UDF for you.
create function dbo.DistanceBetweenInMiles(@.Lat1 float,@.Lon1 float,@.Lat2
float,@.Lon2 float)
returns float
as begin
declare @.radians float,@.dlon float,@.dlat float,@.a float,@.d float
set @.radians = PI()/180.0
set @.dlon = (@.lon1 - @.lon2) * @.radians
set @.dlat = (@.lat1 - @.lat2) * @.radians
set @.a = power(sin(@.dlat/2.0),2.0) + cos(@.lat1 * @.radians) *
cos(@.lat2 * @.radians) * power(sin(@.dlon/2.0),2.0)
set @.d = 3956 * 2.0 * atn2(sqrt(@.a),sqrt(1.0-@.a))
return @.d
end
go
Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/|||Jim,
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81360
RLF
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:23712CCA-A9EA-4B5B-B643-2A97F21D0FAE@.microsoft.com...
> Great Circle distance calculation
> Is there any stored procedure or application that implements Great Circle
> distance calculation
>|||On Mon, 15 Oct 2007 05:33:00 -0700, JIM.H. wrote:
>Great Circle distance calculation
>Is there any stored procedure or application that implements Great Circle
>distance calculation
>
Hi Jim,
<plug>
Adam Machanics book "Expert SQL Server 2005 Development" has a complete
chapter on working with spatial data. This of course covers great circle
distance calculations, as well as finding neighbors in a given distance,
or finding the nearest neighbor.
</modesty>
That chapter is authored by me. It is really great.
<modesty>
</plug>
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Saturday, February 25, 2012
q; Great Circle distance calculation
Labels:
application,
calculation,
circle,
database,
distance,
implements,
microsoft,
mysql,
oracle,
procedure,
server,
sql,
stored
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment