Reading East Error, Source code error?

Topics: General Topics, SharpMap Project, SharpMap v2.0
Nov 19, 2010 at 7:29 PM

Exception occured when reading WKT which is shown below:

 

PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,
AUTHORITY["EPSG","7001"]],
AUTHORITY["EPSG","6277"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4277"]],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.9996012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
AUTHORITY["EPSG","27700"],
AXIS["Easting",EAST],
AXIS["Northing",NORTH]]

http://spatialreference.org/ref/epsg/27700/html/

 

There are two issues here

 

1) the source code assume the last AUTHORITY is after the AXIS, as in ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.ReadProjectedCoordinateSystem method.

This won't cause exception, but will NOT read AUTHORITY if it came before axis.

The issue has been posted here http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=235168

 

2) The method reading the last two AXIS elements might NOT be correct, as shown here with my modified code and original code:

     private static AxisInfo ReadAxis(WktStreamTokenizer tokenizer)
        {
            if (tokenizer.GetStringValue() != "AXIS")
                tokenizer.ReadToken("AXIS");
            tokenizer.ReadToken("[");
            string axisName = tokenizer.ReadDoubleQuotedWord();
            tokenizer.ReadToken(",");
            //tokenizer.NextToken();           //original code
            //string unitname = tokenizer.GetStringValue();  //original code
            string unitname = tokenizer.ReadDoubleQuotedWord();  //my added code
            tokenizer.ReadToken("]");
            switch (unitname.ToUpper(CultureInfo.InvariantCulture))
            {
                case "DOWN"return new AxisInfo(axisName, AxisOrientationEnum.Down);
                case "EAST"return new AxisInfo(axisName, AxisOrientationEnum.East);
                case "NORTH"return new AxisInfo(axisName, AxisOrientationEnum.North);
                case "OTHER"return new AxisInfo(axisName, AxisOrientationEnum.Other);
                case "SOUTH"return new AxisInfo(axisName, AxisOrientationEnum.South);
                case "UP"return new AxisInfo(axisName, AxisOrientationEnum.Up);
                case "WEST"return new AxisInfo(axisName, AxisOrientationEnum.West);
                default:
                    throw new ArgumentException("Invalid axis name '" + unitname + "' in WKT");
            }
        }