Here is one brief example to demonstrate the GEOGRAPHY data type and one of the related methods. The code below finds if a geographical location defined by latitude and longitude coordinates is within a geographical region defined by a polygon.
DECLARE @point GEOGRAPHY;
DECLARE @polygon GEOGRAPHY;
SET @point = geography::Parse('POINT(49.274138 73.098562)');
SET @polygon = geography::Parse('POLYGON((47.0 90.0, 47.0 73.0, 50.0 52.0, 50.0 54.0, 47.0 90.0))');
SELECT @polygon.STIntersects(@point);
Additional resources:
Working with Spatial Data
http://msdn.microsoft.com/en-us/library/bb933876(SQL.100).aspx
Geometry Data Type Method Reference
http://msdn.microsoft.com/en-us/library/bb933973(SQL.100).aspx
Geography Data Type Method Reference
http://msdn.microsoft.com/en-us/library/bb933802(SQL.100).aspx
Working with Spatial Indexes
http://msdn.microsoft.com/en-us/library/bb895265(SQL.100).aspx

0 comments:
Post a Comment