Update GeoApiProjectionFactory.cs

This commit is contained in:
Clemens 2022-01-24 21:00:20 +01:00
parent 0d602be611
commit b921600e1b

View file

@ -21,54 +21,57 @@ namespace MapControl.Projections
public const int Wgs84UtmSouthLast = 32760; public const int Wgs84UtmSouthLast = 32760;
public const int Wgs84UpsSouth = 32761; public const int Wgs84UpsSouth = 32761;
public Dictionary<string, string> CoordinateSystemWkts { get; } = new Dictionary<string, string>(); public Dictionary<int, string> CoordinateSystemWkts { get; } = new Dictionary<int, string>();
public override MapProjection GetProjection(string crsId) public override MapProjection GetProjection(string crsId)
{ {
MapProjection projection = null; MapProjection projection = null;
if (CoordinateSystemWkts.TryGetValue(crsId, out string wkt)) if (crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode))
{ {
projection = new GeoApiProjection(wkt); if (CoordinateSystemWkts.TryGetValue(epsgCode, out string wkt))
}
else if (crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode))
{
switch (epsgCode)
{ {
case WorldMercator: projection = new GeoApiProjection(wkt);
projection = new WorldMercatorProjection(); }
break; else
{
switch (epsgCode)
{
case WorldMercator:
projection = new WorldMercatorProjection();
break;
case WebMercator: case WebMercator:
projection = new WebMercatorProjection(); projection = new WebMercatorProjection();
break; break;
case int c when c >= Ed50UtmFirst && c <= Ed50UtmLast: case int c when c >= Ed50UtmFirst && c <= Ed50UtmLast:
projection = new Ed50UtmProjection(epsgCode % 100); projection = new Ed50UtmProjection(epsgCode % 100);
break; break;
case int c when c >= Etrs89UtmFirst && c <= Etrs89UtmLast: case int c when c >= Etrs89UtmFirst && c <= Etrs89UtmLast:
projection = new Etrs89UtmProjection(epsgCode % 100); projection = new Etrs89UtmProjection(epsgCode % 100);
break; break;
case int c when c >= Wgs84UtmNorthFirst && c <= Wgs84UtmNorthLast: case int c when c >= Wgs84UtmNorthFirst && c <= Wgs84UtmNorthLast:
projection = new Wgs84UtmProjection(epsgCode % 100, true); projection = new Wgs84UtmProjection(epsgCode % 100, true);
break; break;
case int c when c >= Wgs84UtmSouthFirst && c <= Wgs84UtmSouthLast: case int c when c >= Wgs84UtmSouthFirst && c <= Wgs84UtmSouthLast:
projection = new Wgs84UtmProjection(epsgCode % 100, false); projection = new Wgs84UtmProjection(epsgCode % 100, false);
break; break;
case Wgs84UpsNorth: case Wgs84UpsNorth:
projection = new UpsNorthProjection(); projection = new UpsNorthProjection();
break; break;
case Wgs84UpsSouth: case Wgs84UpsSouth:
projection = new UpsSouthProjection(); projection = new UpsSouthProjection();
break; break;
default: default:
break; break;
}
} }
} }