Create Spatial Index on MapinfoTab File

Topics: SharpMap v0.9 / v1.x
Apr 13, 2016 at 9:33 AM
hi Team,
Is this possible to create index on OgrProvider Datasource for Mapinfo File.
If yes then please share some code.

Apr 13, 2016 at 11:23 AM
The OgrDriver for MapInfo Tab-Files already uses the MapInfo internal spatial index.
What is it you want to achieve?
Apr 13, 2016 at 12:18 PM
basically i am using ExecuteQuery Method to fire some sql query on my OgrProvider.Datasource but when i fire sql query it takes lots of time i want to optimize that sql statement.
Apr 13, 2016 at 12:52 PM
A spatial index only has advantages if you want a subset of the whole data. If you want to load it all, the use of the spatial index slows you down.
Do you want all the data?
Apr 13, 2016 at 1:02 PM
Edited Apr 13, 2016 at 1:05 PM
No i don't want all data this time , i have changed my approach as like u said.. :)
i have some conditions in my where clause in sql query
If you want i can send you the MapinfoFile and sql Query which get required data..?
Apr 13, 2016 at 2:34 PM
Go ahead
Apr 13, 2016 at 4:22 PM
Please download TabFile
I want to fire sql :-
Select * from TblName where HSCQIMax_0 > 28
HSCQIMax_0 is a field in this Table.
Please Check it
Apr 14, 2016 at 8:26 AM
You have 1.4 million rows in the whole dataset. Applying your filter leaves some 500 thousand rows.
I have checked with QGIS. Loading and displaying the filtered dataset takes ~25 seconds.
What is your figure?
Apr 14, 2016 at 9:53 AM
My Time to Query Data will take ~20 seconds, but this is for only Query and then ~15 seconds to render map.
But one question still there if we need to meet the timings with QGIS then the functionality in QGIS to get attribute Table for this particular layer will take ~10 sec to show all data.
which function of OgrProvider i need to use to get the attribute table so fast as same time as in the QGiS.
As i have used your sharpmap my product is ready but only thing i am lagging in Large MapinfoTab file . but i need to fix this desperately.
Apr 15, 2016 at 7:40 AM
Edited Oct 6, 2016 at 7:35 AM
I have performed performance profiling:

As you can see, most of the time gets spend parsing the geometry. The current approach is to Export the geometry to WKB and then read that using WKBReader.
Changing the function signature to use a reader instead a factory to create a reader brings in improvement around ~3secs (I have done that).

If there is a way to create an OgrGeometryReader we wouldn't neet the call to Flatten2D, WkbSize, ExportToWkb which would bring another improvement of ~6 seconds.
Apr 20, 2016 at 10:31 AM
Is there any option in sharpmap to cache my vector layer , as in QGIS there is an option named qgsVectorLayerCache.
basically I want same delegate as we use in styling but need for the purpose of cache..

Shubham Goyal.
Apr 20, 2016 at 11:51 AM
You can use GeometryFeatureProvider with a FeatureDataTable you get by Ogr.ExecuteIntersectionQuery
Apr 20, 2016 at 1:15 PM
No No that can't fulfil my requirement for this I need to render full layer on map using Ogr and then get FeatureDatatable by use of ExecuteIntersection Query. and then Use GeometryFeatureProvider.
Apr 21, 2016 at 6:24 AM
One more question .
Assume I have a Window form having mapcontrol on that Winform and I have render a layer on map and set some theme on it .
when I Zoom-In it calls styling delegate but mean while when processor process the styling delegate I want to close that Winform but it will not close in a blink . It will take time first process styling delegate for every feature and then close the form.

Is there any option to force stop styling if I want to close the Winform.