This project has moved and is read-only. For the latest updates, please go here.

ShapeFile Provider Optimization

Topics: Algorithms, Data Access, SharpMap v0.9 / v1.x
Jan 23, 2011 at 12:02 AM

Hi to all again.


I'm looking at the shapefile provider and I've run the dottrace Profiler and I think that it can be optimized in the following way:


1 For each shapefile createn internal Memory Cache that caches all the Features in the current BoundingBox

2 When the IntersectionQuery  or GetGeometriesInView 

2.1 - Use the spatialIndex to get the OID in the BoundingBox

2.2 - Search for the Geometries or Features first in the internal cache

2.3 - If it misses then go to the shapefile and get them

3 - Define a cache timeout to "clean" the internal MemoryCache and clean the Features Cached that are not anymore in the view.


With this the performance boost is very high because when the user makes a pan or a zoom, a lot of features will maintain the same.

By default the memorycache is disabled, and must be activated in the creation of the ShapeFileProvider.

I've proposed a patch to the ShapeFile.cs (Sharpmap.Data.Providers).



Jan 24, 2011 at 12:04 PM

Hello cofee,

thanks for sharing this. It might be an enhancement for the other providers as well. I'll look into that.