60 likes | 198 Vues
This article delves into the spatial data types available in SQL Server 2008, focusing on geometry and geography. It highlights their ability to represent various forms such as points, polygons, and regions while discussing common methods like Contains, Distance, and Intersects. Additionally, the piece covers indexing techniques, including quad-tree-based indexing and coverage masks. Practical examples show how to define polygons and query spatial data efficiently using SQL, alongside tips for optimizing searches through spatial indexes.
E N D
Data Types • geometry • Planar data • geography • Geodetic data (projection of the curve of the Earth) • Represents points, polygons, regions, etc. in the same data type
Common Methods • Contains • Distance • Equals • Intersects • Overlaps • Touches • Within • Union DECLARE @g geometry; SET @g = geometry::STPolyFromText('POLYGON ((5 5, 10 5, 10 10, 5 5))', 0); SELECT @g.ToString();
Indexing the geo* datatypes • Quad-tree based • Successively smaller grid cells
Indexing the geo* datatypes • Coverage masks • Touched • Partially Covered • Interior • Map a cell identifierto a primary key • Map sub-cells
Searching a geo* index • Select on a cell identifier using prefix matching: • (T.cell LIKE I.cell + ‘%’) OR (I.cell LIKE T.cell + ‘%_’) • Use existing SQL text searching optimizations