Symbology in code

Jan 13, 2012 at 1:26 PM

Hi All,

I am having a lot of problems getting symbology to display when setting via code.

I have a layer loaded from a shp file, if I set the Symbolizer it works fine, as soon as I try and create categories it all comes unstuck and I get a blank map.

The really odd thing is that if I set the symbolizer through code and I then use the FeatureCategoryControl to edit the categories and apply the changes the symbols are shown. I can then set my default theme again and it is shown correctly.

This is the code that is called both times, at the start and after the FeatureCategoryControl is used

if (layer.Symbology is PointScheme)
{
    PointLayer pointLayer = layer as PointLayer;
    featureScheme = pointLayer.Symbology;
    featureScheme.ClearCategories();

    PointCategory pointCategory = new PointCategory()
    {
        FilterExpression = "[Status] LIKE '%Saved'",
        LegendText = "Saved"
    };
    pointCategory.Symbolizer = new PointSymbolizer(Color.LightSalmon, DotSpatial.Symbology.PointShape.Rectangle, 4.0) { LegendText = "Saved" };
    featureScheme.AddCategory(pointCategory);

    pointCategory = new PointCategory()
    {
        FilterExpression = "[Status] LIKE '%Completed'",
        LegendText = "Completed"
    };
    pointCategory.Symbolizer = new PointSymbolizer(Color.PaleGreen, DotSpatial.Symbology.PointShape.Rectangle, 4.0) { LegendText = "Completed" };
    featureScheme.AddCategory(pointCategory);

    pointCategory = new PointCategory()
    {
        FilterExpression = "[Status] LIKE 'Closed%'",
        LegendText = "Closed"
    };
    pointCategory.Symbolizer = new PointSymbolizer(Color.DarkGray, DotSpatial.Symbology.PointShape.Rectangle, 4.0) { LegendText = "Closed" };
    featureScheme.AddCategory(pointCategory);

    pointLayer.DataSet.InvalidateVertices();
}

 

Can anyone give me a clue as to what might be going wrong, it almost as though something is not properly initilized in the Symbolizer.

 

Jan 16, 2012 at 11:27 AM

I have found an issue in the AssignFastDrawnStates() and raised it as an issue.

http://dotspatial.codeplex.com/workitem/410

Developer
Jan 17, 2012 at 6:28 PM
Edited Jan 17, 2012 at 8:17 PM

Thanks for your help on this. Please verify the fix corrects things for you.