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

Map Pan Performance

Topics: SharpMap v2.0
Sep 13, 2010 at 4:34 AM

I have just been using sharpmap against some detailed S57 charts, and I am finding that trying to pan the map using the pan tool is almost unusable, and I haven't added all the feature layers yet.

From my interpretations of reading the code, the pan tool currently causes a map offset for every mouse move event that is raised, which intern will requery all data sources and force a complete map redraw. 

Would it be possible that the pan cam be made transactional between the mouse down and the mouse up, and have the map offset the current loaded features with the new view matrix, and not requery for features until the mouse up event occurs?

All though you would then get empty space around the map as you hold and drag, it would at least be more responsive to user input?

Thoughts would appreciated


Sep 13, 2010 at 2:52 PM

Hello Pete,

first let me ask how you read your s57 data. Do you have an Ogr provider for SharpMap v2?

I think it makes sense to not query the datasources until your done panning, this releasing the mouse button. So here is how it goes:

IMapView2D interface:

  • add boolean RequerySource { get; set }

MapPresenter2D class

  • add boolean RequerySource { get; set }
  • In the RenderFeatureLayer function set variable features to layer.Select(...) if RequerySource is true, to Layer.Features if not.

MapControl class

  • Implement RequerySource from IMavView2D and pass the values from the presenter (both ways)


  • copy code from ContinuePan(...) to EndPan(...)
  • Modify code from ContinuePan(...) so that view.RequerySource is set to false before calling view.Offset(...) and to false afterwards.

Unfortunately I do not have a clean version, that is one without modifications, of SharpMap v2, otherwise I'd post a patchfile.

Hth FObermaier

Sep 13, 2010 at 3:15 PM

Hey FObermaier,

Yeah I have a hacked version of the OgrProvider in SharpMap v2. However, it has a bug where I get access violation exception when reading more than 2 layers out of any one file. This error doesn't occur in the 0.9 trunk, so I was thinking of having another look at that soon, but I figure I might as well just process the S57 data into a SQL Server 2008 database using the 0.9 code.

I am also seeing the same pan behaviour in 0.9, so there is a common theme across SharpMap where a full map render is done on a mouse move event using the winforms MapImage control.

The above solution seems like a valid solution to the issue and I will have a look at implementing it in the winforms presentation. Ultimately I am looking for a WPF mapping solution as our application is a WPF app, and there is a decent amount of guidance to get a WPF solution working based on the WPF SharpMapControls project, but I needed to get this usability issue sorted before considering taking on that task. 

Cheers for your input,


Sep 13, 2010 at 3:32 PM


do you mind sharing your provider? I have one in line, too, perhaps a merge of both would speed up things.

SharpMap v0.9 has two System.Windows.Forms controls. MapImage shifts the rendered Image around until you release the MouseButton, MapBox has a different behavior depending on PreviewMode. Have you tried setting it to Fast?

I was going to ask blackrussian if he minds incorporating his WPF work in the sharpmap v2 trunk

Cheers FObermaier

Sep 16, 2010 at 6:10 PM


I just commited my version of OgrProvider for SharpMap v2. It does not have issues with multiple layers from same datasource, e.g. S57.

Feel free to check it out. It is in the /branches/initalgdalintegration branch.


Sep 22, 2010 at 5:27 AM
Edited Sep 22, 2010 at 5:33 AM

Hey FObermaier,

Just gave the initalgdalintegration branch a run and I found that the references to where you placed gdal_csharp.dll etc cannot be found. Have you missed checking these assemblies in?

EDIT: The path the project is referencing is Native\x86\csharp\gdal_csharp.dll


Sep 22, 2010 at 8:05 AM

Hello Pete,

originally I did this by intent. I'm not so sure if that was a good idea now. There is a ReadMe.txt in the Extensions\Gdal folder. All of this applies to Ogr as well.



Sep 24, 2010 at 12:10 AM


I have been using the OgrProvider and so far have only found a single issue. The GetLayers method currently rejects layers if the OgrGeometryType is wkbUnknown. The issue is that some layers have multiple geometry types in the layer, and hence will return wkbUnknown. This means that it currently is rejecting some of the most important layers like the land areas as there are polygons and points.

I have raised an issue and given a patch for this.