ThinkGeo.com    |     Documentation    |     Premium Support

Issue with ClassBreakStyle and floating number

Hi,


I'm getting in troubles with 3.1.302 and ClassBreakStyle.


If I target a numeric column that includes only non decimal number then it works fine.

However, if the column contains floating numbers, then every floating numbers are not represented with the class style they belong but the higher class style.


Is there something special to do with MS3 ?

This is working with MS2 and the same data.


Thank you for your help.


Patrick.



 


Patrick,
 
Thanks for your post and question.
 
I think the logic is a bit different with 2.x version with the using of ClassBreakStyle.
 
In 3.x version, the direction of ClassBreak is from lower to upper, for example, I set a class break value for a class break, then the numberic value greater( or equal which is influced by property BreakValueInclusion) than this break value will match up.
 
For example:

classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Blue)));

// >3648399.74 (or >=3648399.74)
classBreakStyle.ClassBreaks.Add(new ClassBreak(3648399.74, AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Red)));

 
The US area is 3648399.75, then it will go to the Red class break . While if some country area is 3648399.73, then it will go to its previous class break(Blue one).
 
The equal value will be determined by following property:

classBreakStyle.BreakValueInclusion = BreakValueInclusion.IncludeValue;    //(>=)

 
Anything I am not clear just feel free to let me know.
 
Thanks.
 
Yale

Yale, 
  
 Let me clarify the issue 
  
 Let say that I’ve the following classes: 
 (a) classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue  
 (b) classBreakStyle.ClassBreaks.Add(new ClassBreak(5 
 © classBreakStyle.ClassBreaks.Add(new ClassBreak(10 
 (d) classBreakStyle.ClassBreaks.Add(new ClassBreak(15 
  
 if the column value is 6 then it will be represented with style (b) which is good 
 BUT if the column value is 6.1 then it will be represented with style (d) which is not good. 
  
 Any idea ? 
  
 Regards, 
 Patrick.

Patrick,


I create a test data accroding to your description. Attachment is the data. The following is the screenshot of the class break column.

 
string fileName = @"C:\tmp\Post6839\Post6839TestData.shp";
 
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
 
// Draw thematic features
ClassBreakStyle classBreakStyle = new ClassBreakStyle("TestColumn");
classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, AreaStyles.Grass1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(5, AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Red)));
classBreakStyle.ClassBreaks.Add(new ClassBreak(10, AreaStyles.Evergreen1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(15, AreaStyles.Crop1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(20, AreaStyles.Forest1));
 
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(fileName);
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.Country1);
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
 
LayerOverlay worldOverlay = new LayerOverlay();
worldOverlay.Layers.Add("WorldLayer", worldLayer); 
winformsMap1.Overlays.Add(worldOverlay);
 
winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.Default;
winformsMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
winformsMap1.Refresh();
 
The following snapshot shows the renderring result, which seems ring in the Red classbreak style for both features.

 
Any more quetsions just feel free to let me know.
 
Thanks.
 
Yale

1600-Post6839Data.zip (102 KB)

Yale,


The problem is that I do not get the same result with your sample data and your code on my PC.

Please see the screenshot.



FYI, I'm using VS2008, 64bits, french environment and MS 3.1.302.


Please advise.


Patrick.



Patrick,


Thanks for your post and response.
 
I think there are 2 solutions for you to fix this problem currently.
 
1)      Change the setting in the “Regional and Language Options” which was opened in your Control Panel. Following is the screenshot for this. Try to change the (,) in french enviroment to (.) used in standard english enviroment.
 


 
 
2)  Try to create your own class break style and override the DrawCore API. Folloiwng is the implementation.
 
Create your own ClassBreakStyle as following:
public class MyClassBreakStyle : ClassBreakStyle 
 {
        public MyClassBreakStyle()
            : this(string.Empty, BreakValueInclusion.IncludeValue)
        {
        }
 
        public MyClassBreakStyle(string columnName)
            : this(columnName, BreakValueInclusion.IncludeValue)
        {
        }
 
        public MyClassBreakStyle(string columnName, BreakValueInclusion breakValueInclusion)
            : this(columnName, breakValueInclusion, new Collection<ClassBreak>())
        {
        }
 
 
        public MyClassBreakStyle(string columnName, BreakValueInclusion breakValueInclusion, Collection<ClassBreak> classBreaks)
            : base(columnName,breakValueInclusion,classBreaks)
        {
        }
 
        protected override void DrawCore(System.Collections.Generic.IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
        {
            Collection<Feature> updatedFeatures = new Collection<Feature>();
 
            foreach (Feature feature in features)
            {
                double fieldValue = double.Parse(feature.ColumnValues[ColumnName].Trim());
                feature.ColumnValues[ColumnName] = fieldValue.ToString(CultureInfo.InvariantCulture);
                updatedFeatures.Add(feature);
            }
            base.DrawCore(updatedFeatures, canvas, labelsInThisLayer, labelsInAllLayers);
        }
}
 
Use it in this way:
MyClassBreakStyle classBreakStyle = new MyClassBreakStyle("TestColumn");
classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, AreaStyles.Grass1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(5, AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Red)));
classBreakStyle.ClassBreaks.Add(new ClassBreak(10, AreaStyles.Evergreen1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(15, AreaStyles.Crop1));
classBreakStyle.ClassBreaks.Add(new ClassBreak(20, AreaStyles.Forest1));
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

 



Yale, 
  
 1. fixed the issue, but I cannot ask my customer to change their settings. 
 2. That bug was not in MS2 neither in MS3 Betas … please fix it and send me the updated version. 
  
 Regards, 
 Patrick.

Patrick, 
  
 Thanks for your responding. 
  
 I digged into our source code and found that this bug should be existing for a long time now since year 2008, we will try to solve it soon. While I am afraid I cannot agree with you that this bug was not in MS3 beta, could you let me know which version works fine if you can remerber it? That would be great helpful. 
  
 One thing is that our build system is under construction, I am afraid I can only send you a updated version after the build system is ready, that probablly would take a couple of days. 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


Yale, 
  
 first, I did your change (2) and it works perfectly as a workaround; thank you. 
 second, It was working with MS2 in 2008-2009 
 it was working with MS3 from 2009 march to october; I cannot recall your build number, but I can recall my launch dates. 
  
 I’m waiting for the new version, thank you again. 
  
 Patrick.

Patrick, 
  
 I don’t agree with you, I have tested two packages which release during 2009 March to October, they’re both have the same issue. 
  
 3.0.307 is released at 2009.05.28, 3.0.362 is released at 2009.07.23. 
  
 Please make sure before you want to say something. 


Bill, Thanks for your sharing! 
  
 Patrick, 
  
 I know you have a ticket for your issue here, I will let you know then when we are ready for your package. 
  
 Thanks for your post and bug reporting. 
  
 Yale 


Bill, 
  
   That comment you made about Patrick needing to be sure before he said something is a little out of line.  Patrick, sorry about that, just disregard Bill’s comment.  We have to keep these forum good spirited and we don’t need sharp remarks like that.  I have been following this thread and though it is not finishing up as quickly as I would have liked it seems everyone is making progress.  Let everyone make an effort to keep things professional. 
  
 David