Slow Shapefile Geometry access in 2.0?

Jul 10, 2008 at 6:17 PM
Am I doing something wrong?  The following code takes 100x longer in 2.0 than in 0.9.  Is there a faster way in 2.0?

Thanks!
-Matt


2.0 code

ShapeFileProvider shpFile = new ShapeFileProvider(HttpContext.Current.Server.MapPath(@"~\App_Data\states.shp"), GeometryFactory, CoordinateSystemFactory);
shpFile.Open();
FeatureQueryExpression query = new FeatureQueryExpression(shpFile.GetExtents(), SpatialOperation.Contains);
IFeatureDataReader dr = shpFile.ExecuteFeatureQuery(query);
while (dr.Read())
{
        IGeometry geo = dr.Geometry;
}
shpFile.Close();


0.9 code

ShapeFile shpFile = new ShapeFile(HttpContext.Current.Server.MapPath(@"~\App_Data\states.shp"), true);
shpFile.Open();
List<Geometry> shapes = shpFile.GetGeometriesInView(shpFile.GetExtents());
for (int i = 0; i < shapes.Count; i++)
{
            LinearRing ring = ((Polygon)shapes[i]).ExteriorRing;
}
shpFile.Close();
Coordinator
Jul 11, 2008 at 3:30 PM
You think 100x is bad, try running it when a profiler is attached to the process! It makes it 10x worse... ;)

I fixed a huge performance issue in recent SharpMap code which looks to be the one you are running into. Do you use the source from the subversion repository or the binaries from the Release tab? I hope to bundle what I have and make a drop this weekend if it is the latter.

There are still some performance weaknesses due to things like having to make due with a NullQueryCache (where the datasource is always queried) for the time being.
Jul 11, 2008 at 3:44 PM
I'm currently using the code from the June 2008 drop.
I'll try to see if I can get the latest up on my machine.

Thanks!
-Matt