Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spatial Indexing

I want to create a large database of GPS coordinates that can be queried by saying "Return all coordinates that are within 'n' metres of [this coordinate]".

I would like to know how to implement Quadtree Indexing in Sqlserver2008?

I want to write a .net module that calls the query which uses quad tree so that i can retrieve the objects so quickly.

How can i implement the above functionality?

Thanks in advance

like image 711
user98454 Avatar asked Aug 26 '09 13:08

user98454


People also ask

What are spatial indexes?

A spatial index is a type of extended index that allows you to index a spatial column. A spatial column is a table column that contains data of a spatial data type, such as geometry or geography.

What is geospatial indexing?

With the spatio-temporal library, you can use functions to index points within a region, on a region containing points, and points within a radius to enable fast queries on this data during location analysis.

What does create spatial index do?

Creates a spatial index on a specified table and column in SQL Server. An index can be created before there is data in the table. Indexes can be created on tables or views in another database by specifying a qualified database name. Spatial indexes require the table to have a clustered primary key.


1 Answers

CREATE TABLE mytable (id INT NOT NULL, mypoint GEOGRAPHY NOT NULL, ...)

CREATE SPATIAL INDEX SX_mytable_mypoint ON mytable (mypoint)

SELECT  *
FROM    mytable
WHERE   mypoint.STDistance(geography::STGeomFromText(N'POINT (latitude longitude)', 4326) <= @N
like image 115
Quassnoi Avatar answered Oct 06 '22 01:10

Quassnoi