[Qgis-developer] Use of Spatial Index

maaza mekuria sailmcm at yahoo.com
Wed Jul 27 14:56:50 EDT 2011


I am just wondering if one could use the following in a spatial index created from the layer provider 

 QgsVectorLayer* cvertexLayer = cVertexLayer(txtStream);
 QgsVectorDataProvider* cvectorProvider = cvertexLayer->dataProvider();
 bool blnSpatialIdx = cvectorProvider->createSpatialIndex();
 
After creating the spatial index file how can I access it in code? 
can I use it in anyway to perform spatial filters for selection purposes?

 QgsSpatialIndex mSpatialIndex = <dynamic_Cast> cvectorProvider; // may be cvectorLayer; 

or may be even directly perform this 

 QgsSpatialIndex mSpatialIndex = cvectorProvider->createSpatialIndex();

 // and then do something like this
 mSpatialIndex.intersects( rect ); 


DO I have to create my own in memory spatial index to perform the above 

what do you think? 

Maaza




More information about the Qgis-developer mailing list