Distance Algorithm used in SQL2008 for Geography Data Types

1k Views Asked by At

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.

3

There are 3 best solutions below

0
On

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.

2
On

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?

1
On

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.