LabelLayer RotateColumn number conversion

Topics: SharpMap Project
Nov 24, 2010 at 5:51 AM

Hi!

 There are some bug in LabelLayer.cs.

 When I define RotationColumn for Label in 423 line of code value from dataset will be translate to String in current culture and after that parsed with Map.NumberFormatEnUs provider:

float.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
    out rotationColumn);

If CurrentCulture differ from en-US with decimal separator (for example in Russian local it ',' symbol) result of this operation may be wrong.

For example number 44.7 in Dataset translated to "44,7" string and after that to 447F float number. :(
 

IMHO next variant should be better:

{
    if ((feature[RotationColumn]) is IConvertible)
        float.TryParse(((IConvertible) (feature[RotationColumn])).ToString(Map.NumberFormatEnUs), NumberStyles.Any, Map.NumberFormatEnUs,
            out rotationColumn);
    else
        float.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs,
            out rotationColumn);
}

So with other same translations (PriorityColumn and so one).

Coordinator
Nov 24, 2010 at 8:07 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.