60 likes | 189 Views
Spatial Data Types And Indexing SQL Server 2008. Bob King. 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
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