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

Problem with refreshing VariableLayerCollection

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Dec 12, 2012 at 8:19 AM
Edited Dec 12, 2012 at 11:56 AM


Still I have a problem with the refreshing of the VariableLayerCollection on the MapBox.

I'm using a shapefile with attributes and one of the attributes in the DBF, a text, will be changed in the program (with some external code).

Created the VectorLayer with a shapefile (referenced as _shapeFile), created a LabelLayer which datasource is the VectorLayer. Added the VectorLayer and LabelLayer to the map with

mapBox.Map.VariableLayers.AllowEdit = true;
mapBox.Map.VariableLayers.AllowRemove = true;
VariableLayerCollection.Interval = 1000;

For the _shapeLayer I use a simple CustomTheme (line color and width), based on the value of the attribute which I have to change.

For the editing I use

VariableLayerCollection.Pause = true;
if (_shapeFile.IsOpen) _shapeFile.Close();

// edit the attribute //
if (!_shapeFile.IsOpen) _shapeFile.Open(); VariableLayerCollection.Pause = false; VariableLayerCollection.TouchTimer();

The segments and labels on the map will not change when the attribute is changed. I can take a long time before it is changed.

Is there anything I'm doing wrong?



Dec 13, 2012 at 9:16 AM

Dear mr Obermaier,

Sorry, but the UseMemoryCache property is not available in the version I use (0.9.5 as from downloads -> SharpMap-0.9-Trunk-2012.04.17).

I have the source code here (99885), and have found that property in ShapeFile.cs in Branches\0.9-GeoJSON, Branches\Trunk-Benjii, Branches\v1.0, Tags\v0.9, Trunk\SharpMap and Trunk\SharpMap.Extensions.

Which one I should use, and if I incorporate the sourcecode in my project (with a modified class name, eg. ShapeFile4Me), do I need some others also, and will it affect the rest of the SharpMap library?

And what is the memory mapped file version of the ShapeFile provider? I'm using SharpMap.Data.Providers.ShapeFile .



Dec 13, 2012 at 9:36 AM
Edited Dec 13, 2012 at 9:37 AM

Sorry, my fault, you have to specify whether or not to use memory cache in the shapefile constructor.

ShapeFile _shapeFile = new ShapeFile(
    filename, /*full path to shapefile*/
    true      /*or false, controls spatial index creation*/, 
    false     /*this controls use of memory cache*/);

Hth FObermaier

Dec 13, 2012 at 3:16 PM

Thanks mr Obermaier, it works great!

It was my mistake to overlook the shapefile constructor parameters ;-)