views:

211

answers:

3

I am wanting to know what Algorithm SQL2008 uses when computing distance on Geography Data Types.

There are several such Algorithms as the Haversine and Vincenty, however I have found no references for what SQL2008 is actaully using.

+1  A: 

It depends completely on the Spatial Reference Identifier that is associated with the geography type.

The SRID is representative of what exactly the units in the geography type are, and will dictate the coordinate system. This system will indicate which algorithms are being used.

That being said, SQL Server 2008 only supports a certain set of SRIDs (see the section titled "geography Instances Must Use Supported SRID" in the link above) when performing calculations on geography instances.

You can probably gain more information from the spec that SQL Server 2008 uses for geography/geometry types, the Open Geospacial Consortium's Simple Feature Access specification.

casperOne
Hi, and thanks! We are using SRID 4326 (WGS84)
Darryl
A: 

I think you are interested in the geography type and how it does it's distance calculation. This chapter might help (as well as this blog) http://blogs.msdn.com/edkatibah/archive/2009/12/17/inside-microsoft-sql-sever-2008-t-sql-programming-chapter-14-spatial-data.aspx

There is also the MS SQLSpatialTools on Codeplex. Their interpolation functions for geography types might give you a hint what they are doing under the hoods

http://sqlspatialtools.codeplex.com/wikipage?title=Current%20Contents&referringTitle=Home

Can I ask why you care what function is being used as long as the answer is right?

TheSteve0
Hey, thanks for the info. The Calculations may be required to be produced in legal matters.
Darryl
then maybe it would be worth calling MS support and getting them to send you a direct answer. The other option is to use PostGIS - 1.5 has support for geography types and all the source code is open for you to see.
TheSteve0
A: 

It seems what you really care about is now how SQL Server calulates the distance, but how it actually defines distance on the earth as there are many alternative definitions. The best reference for this is the paper by Michael Kallay Defining edges on a round earth.

Isaac Kunen also wrote a whitepaper about representing round surfaces in 2d coordinates which is excellent good background reading.

stevehem