Authority Value in Shapefile, Source Code problem??

Topics: Algorithms, Data Access, General Topics, SharpMap Project, SharpMap v2.0
Nov 18, 2010 at 1:23 PM

Please point it out if I am wrong.

 

The way that the Authority value is determined in the source code might NOT be correct. The source code is included at the bottom of this thread.

 

First of all, the WKT of Bitish National Grid (EPSG: 27700) is show 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/

The AUTHORITY is the last one at the end:
AUTHORITY["EPSG","27700"]


However, the source code read the AUTHORITY within
GEOGCS element, which is NOT correct, I think.


ProjNet.Converters.WellKnownText.CoordinateSystemWktReader
		private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer)
{
/*PROJCS[
"OSGB 1936 / British National Grid",
GEOGCS[
"OSGB 1936",
DATUM[...]
PRIMEM[...]
AXIS["Geodetic latitude","NORTH"]
AXIS["Geodetic longitude","EAST"]
AUTHORITY["EPSG","4277"]
],
PROJECTION["Transverse Mercator"],
PARAMETER["latitude_of_natural_origin",49],
PARAMETER["longitude_of_natural_origin",-2],
PARAMETER["scale_factor_at_natural_origin",0.999601272],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
AXIS["Easting","EAST"],
AXIS["Northing","NORTH"],
AUTHORITY["EPSG","27700"]
]
*/
tokenizer.ReadToken("[");
string name = tokenizer.ReadDoubleQuotedWord();
tokenizer.ReadToken(",");
tokenizer.ReadToken("GEOGCS");
IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);
tokenizer.ReadToken(",");
IProjection projection = ReadProjection(tokenizer);
IUnit unit = ReadLinearUnit(tokenizer);

string authority = String.Empty;
long authorityCode = -1;
tokenizer.NextToken();
List<AxisInfo> axes = new List<AxisInfo>(2);
if (tokenizer.GetStringValue() == ",")
{
tokenizer.NextToken();
while (tokenizer.GetStringValue() == "AXIS")
{
axes.Add(ReadAxis(tokenizer));
tokenizer.NextToken();
if (tokenizer.GetStringValue() == ",") tokenizer.NextToken();
}
if (tokenizer.GetStringValue() == ",") tokenizer.NextToken();
if (tokenizer.GetStringValue() == "AUTHORITY")
{
tokenizer.ReadAuthority(ref authority, ref authorityCode);
tokenizer.ReadToken("]");
}
}
//This is default axis values if not specified.
if (axes.Count == 0)
{
axes.Add(new AxisInfo("X"AxisOrientationEnum.East));
axes.Add(new AxisInfo("Y"AxisOrientationEnum.North));
}           

IProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(geographicCS.HorizontalDatum, geographicCS, unit as LinearUnit, projection, axes, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);
return projectedCS;
}
Coordinator
Nov 18, 2010 at 1:57 PM

hello kingofwebguru,

there are two issues with the way Proj.Net mishandles the wkt:

  • It assumes the [UNIT ...] clause right after the projection and projection parameters definition and not before
  • It assumes that the [AUTHORITY ...] clause is always the last paramter for projected coordinate systems.

Now I don't know which way is OGC conform, but if you adjust your input wkt to the way it gets parsed, you should be fine.

Please report this bug on the Proj.Net page, maybe along with a patchfile.

Hth FObermaier

 

Nov 19, 2010 at 4:55 PM

The source code was working correctly, after I re-exmamined it.

Nov 19, 2010 at 7:29 PM

After re-examined it, the source code might have error:

http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=235366