SQL Server 2008 Spatial - STContains for Geography type

Where is the STContains function for the Geography type. I don't know but its not in Sql Server 2008.

As a workaround you can use STIntersection and compare the results with the geography you are comparing with i..e

declare @g geography = 'POLYGON((0 0,0 10,0 20,0 30, 0 40, 50 40,50 30 ,50 20, 50 10, 50 0, 0 0))'

declare @l geography = geography::Parse('LINESTRING(20 0,20 10,20 20)')

select @g.STIntersection(@l).ToString(), @g.STIntersection(@l).STEquals(@l);

This returns 1 if the LINESTRING  is within the POLYGON



-
Published Monday, January 21, 2008 10:38 PM by simonsabin
Filed under:

Comments

Tuesday, January 22, 2008 2:54 AM by Morten

# re: SQL Server 2008 Spatial - STContains for Geography type

This is not entirely correct. STContains means that they can't share border. Calculating the intersection includes the border:

Compare these two queries:

declare @g geography = 'POLYGON((0 0,0 10,10 10,10 0, 0 0))';

declare @l geography = geography::Parse('LINESTRING(0 10,10 10)');

select @g.STIntersection(@l).STEquals(@l);

(return true)

declare @g1 geometry = 'POLYGON((0 0,10 0,10 10,0 10, 0 0))';

declare @l1 geometry =  geometry::Parse('LINESTRING(10 0,10 10)');

select @g1.STContains(@l1);

(returns false)

In general the problem with Geography is that Microsoft haven't implemented STRelate which is the generic method that all these operations use (granted this is hard for spherical geometry). Instead they patched it up with a couple specially implemented topological operations.

Tuesday, January 22, 2008 3:19 AM by simonsabin

# re: SQL Server 2008 Spatial - STContains for Geography type

Fairpoint but its a good approximation.

Wednesday, January 23, 2008 6:58 PM by Steven Hemingray

# re: SQL Server 2008 Spatial - STContains for Geography type

Actually, determining the Relation matrix itself is not a problem.  Instead, one big part of the problem is the definition of Boundary on the ellipsoid.  No OGC spec defines how an edge is defined on the earth (our resident mathematician, Michael Kallay, wrote a paper on the subject for ACM-GIS 2007 "Defining Edges on a Round Earth"

http://www.cise.ufl.edu/dept/acmgis2007/poster-sessions.html) and hence the boundary of these objects is not explicitly defined either.  So we did not implement any OGC relation operator that had an explicit requirement on the boundary of the object, nor did we expose the STBoundary method.

Tuesday, October 18, 2011 10:03 AM by Russian SQL Server Club

# Геопространственные агрегаты в Denali

Новой возможностью SQL Server 11 в части геопространственных расширений являются агрегатные функции...

# Геопространственные агре&a

Pingback from  Геопространственные агрегаты в Denali | Microsoft Russia ISV Team