Skip to content

Commit b0ad08c

Browse files
authored
Fixed an error when importing projected coordinate systems. Support of the UNIT parameter (#128)
1 parent 5821992 commit b0ad08c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ProjNet/IO/CoordinateSystems/CoordinateSystemWktReader.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,17 @@ private static ProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStream
360360
tokenizer.ReadToken("GEOGCS");
361361
var geographicCS = ReadGeographicCoordinateSystem(tokenizer);
362362
tokenizer.ReadToken(",");
363-
tokenizer.ReadToken("PROJECTION");
363+
tokenizer.NextToken();
364+
365+
LinearUnit linearUnit = null;
366+
367+
if (tokenizer.GetStringValue().Equals("UNIT", StringComparison.OrdinalIgnoreCase))
368+
{
369+
linearUnit = ReadLinearUnit(tokenizer);
370+
tokenizer.ReadToken(",");
371+
}
364372
var projection = ReadProjection(tokenizer);
365-
var unit = ReadLinearUnit(tokenizer);
373+
var unit = linearUnit ?? ReadLinearUnit(tokenizer);
366374
var axisInfo = new List<AxisInfo>(2);
367375
string authority = string.Empty;
368376
long authorityCode = -1;

test/ProjNet.Tests/CoordinateSystemServicesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static IEnumerable<KeyValuePair<int, string>> LoadXml(string xmlPath)
8888
var sridElement = node.Element("SRID");
8989
if (sridElement != null)
9090
{
91-
var srid = int.Parse(sridElement.Value);
91+
int srid = int.Parse(sridElement.Value);
9292
yield return new KeyValuePair<int, string>(srid, node.LastNode.ToString());
9393
}
9494
}

0 commit comments

Comments
 (0)