| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0421e3c commit 1d0f0ef
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,14 +98,19 @@ public ICoordinateSystem CreateFromXml(string xml) | |||
| 98 | 98 | public ICoordinateSystem CreateFromWkt(string wkt) | |
| 99 | 99 | { | |
| 100 | 100 | //Hack: DotSpatial.Projections does not handle Authority and AuthorityCode | |
| 101 | - var pos1 = 10 + wkt.LastIndexOf("AUTHORITY[", StringComparison.InvariantCulture); | ||
| 102 | - var pos2 = wkt.IndexOf("]", pos1, StringComparison.InvariantCulture) - 1; | ||
| 103 | - var parts = wkt.Substring(pos1, pos2 - pos1 + 1).Split(','); | ||
| 104 | - | ||
| 105 | - var auth = parts[0].Replace("\"", "").Trim(); | ||
| 106 | - var code = int.Parse(parts[1].Replace("\"", ""), NumberStyles.Integer, | ||
| 107 | - NumberFormatInfo.InvariantInfo); | ||
| 101 | + var pos1 = wkt.LastIndexOf("AUTHORITY[", StringComparison.InvariantCulture); | ||
| 102 | + string auth = "EPSG"; | ||
| 103 | + int code = 0; | ||
| 104 | + // If there is an Authority entry in the WKT, try to parse the values | ||
| 105 | + if (pos1 >= 0) | ||
| 106 | + { | ||
| 107 | + pos1 += 10; | ||
| 108 | + var pos2 = wkt.IndexOf("]", pos1, StringComparison.InvariantCulture) - 1; | ||
| 109 | + var parts = wkt.Substring(pos1, pos2 - pos1 + 1).Split(','); | ||
| 108 | 110 | ||
| 111 | + auth = parts[0].Replace("\"", "").Trim(); | ||
| 112 | + int.TryParse(parts[1].Replace("\"", ""), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out code); | ||
| 113 | + } | ||
| 109 | 114 | ProjectionInfo pi = null; | |
| 110 | 115 | try | |
| 111 | 116 | { | |
@@ -270,4 +275,4 @@ public IVerticalDatum CreateVerticalDatum(string name, DatumType datumType) | |||
| 270 | 275 | throw new NotSupportedException(); | |
| 271 | 276 | } | |
| 272 | 277 | } | |
| 273 | - } | ||
| 278 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,9 @@ public class DotSpatialCoordinateTransformationFactory : ICoordinateTransformati | |||
| 27 | 27 | /// </remarks> | |
| 28 | 28 | public ICoordinateTransformation CreateFromCoordinateSystems(ICoordinateSystem sourceCS, ICoordinateSystem targetCS) | |
| 29 | 29 | { | |
| 30 | + if (sourceCS == null || targetCS == null) | ||
| 31 | + return null; | ||
| 32 | + | ||
| 30 | 33 | var source = sourceCS as DotSpatialCoordinateSystem ?? | |
| 31 | 34 | new DotSpatialCoordinateSystem(ProjectionInfo.FromEsriString(sourceCS.WKT)); | |
| 32 | 35 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments