ThinkGeo.com    |     Documentation    |     Premium Support

CustomColumnFetch Event with ClassBreak Sample

Could you provide me with some sample code showing how to implement use a CustomColumnFetch to get column data that I could use in a ClassBreak Renderer?


I saw the sample in the DeveloperBlog showing how to implement a DictionaryValueStyle; do you think that a ClassBreakStyle has the same overhead as a ValueStyle? If so is there a way to create a DictionaryClassBreakStyle that would have higher performance?



Steve,


 Thanks for your post!
 
Following is some code you can reference using the CustomColumnFetch to get the column data when using the ClassBreakStyle.

private void Form1_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            winformsMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            ClassBreakStyle classBreakStyle = new ClassBreakStyle("Custom");
           
            classBreakStyle.ClassBreaks.Add(new ClassBreak(100, AreaStyles.County1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(1000000, AreaStyles.Evergreen2));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(10000000, AreaStyles.Evergreen1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(50000000, AreaStyles.Crop1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(100000000, AreaStyles.Forest1));

            ShapeFileFeatureLayer worldShapeLayer = new ShapeFileFeatureLayer("Countries02.shp");
            worldShapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
            worldShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            worldShapeLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("WorldShapeLayer", worldShapeLayer);
            winformsMap1.Overlays.Add(staticOverlay);

            winformsMap1.Refresh();
        }


void FeatureSource_CustomColumnFetch(object sender, CustomColumnFetchEventArgs e)
        {
            if (e.ColumnName == "Custom")
            {
                if (e.Id == "47" || e.Id == "135")
                {
                    e.ColumnValue = "120";
                }
                else
                {
                    e.ColumnValue = "1000000";
                }
            }
        }

Besides, about the DictionaryValueStyle problem, I would say that this is to solve very specific problem: have hundreds or thousands of value item in the ValueStyle.
 
Normally, we do not want to include so many ClassBreakItem in ClassBreakStyle just for very normal and practice application and the performance will be very high, so we do not suggest this if the class breaks will not too many. If you really want to add thousands of class breaks for some particular purpose, you can try to create your own DictionaryClassBreakStyle, there might be some difference between DictionaryValueStyle vs DictionaryClassBreakStyle, but we still can deal with it with some trick way.
 
Let me know if you have any problems!
 
Thanks.
 
Yale