Updated GeoApiProjection

This commit is contained in:
Clemens 2022-01-24 20:43:22 +01:00
parent d61cb51f80
commit 0d602be611
5 changed files with 16 additions and 7 deletions

View file

@ -45,7 +45,7 @@ namespace MapControl.Projections
+ "AXIS[\"Northing\",NORTH]," + "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"230{0}\"]]"; + "AUTHORITY[\"EPSG\",\"230{0}\"]]";
WKT = string.Format(wktFormat, zone, 6 * zone - 183); CoordinateSystemWkt = string.Format(wktFormat, zone, 6 * zone - 183);
} }
} }
} }

View file

@ -45,7 +45,7 @@ namespace MapControl.Projections
+ "AXIS[\"Northing\",NORTH]," + "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"258{0}\"]]"; + "AUTHORITY[\"EPSG\",\"258{0}\"]]";
WKT = string.Format(wktFormat, zone, 6 * zone - 183); CoordinateSystemWkt = string.Format(wktFormat, zone, 6 * zone - 183);
} }
} }
} }

View file

@ -32,9 +32,9 @@ namespace MapControl.Projections
{ {
} }
public GeoApiProjection(string wkt) public GeoApiProjection(string coordinateSystemWkt)
{ {
WKT = wkt; CoordinateSystemWkt = coordinateSystemWkt;
} }
/// <summary> /// <summary>
@ -42,7 +42,7 @@ namespace MapControl.Projections
/// i.e. a PROJCS[...] or GEOGCS[...] string as used by https://epsg.io or http://spatialreference.org. /// i.e. a PROJCS[...] or GEOGCS[...] string as used by https://epsg.io or http://spatialreference.org.
/// Setting this property updates the CoordinateSystem property with an ICoordinateSystem created from the WKT string. /// Setting this property updates the CoordinateSystem property with an ICoordinateSystem created from the WKT string.
/// </summary> /// </summary>
public string WKT public string CoordinateSystemWkt
{ {
get { return CoordinateSystem?.WKT; } get { return CoordinateSystem?.WKT; }
protected set { CoordinateSystem = new CoordinateSystemFactory().CreateFromWkt(value); } protected set { CoordinateSystem = new CoordinateSystemFactory().CreateFromWkt(value); }

View file

@ -2,6 +2,8 @@
// © 2022 Clemens Fischer // © 2022 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL) // Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic;
namespace MapControl.Projections namespace MapControl.Projections
{ {
public class GeoApiProjectionFactory : MapProjectionFactory public class GeoApiProjectionFactory : MapProjectionFactory
@ -19,11 +21,17 @@ 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 override MapProjection GetProjection(string crsId) public override MapProjection GetProjection(string crsId)
{ {
MapProjection projection = null; MapProjection projection = null;
if (crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode)) if (CoordinateSystemWkts.TryGetValue(crsId, out string wkt))
{
projection = new GeoApiProjection(wkt);
}
else if (crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode))
{ {
switch (epsgCode) switch (epsgCode)
{ {

View file

@ -17,7 +17,8 @@ namespace MapControl.Projections
{ {
public WorldMercatorProjection() public WorldMercatorProjection()
{ {
WKT = "PROJCS[\"WGS 84 / World Mercator\"," CoordinateSystemWkt
= "PROJCS[\"WGS 84 / World Mercator\","
+ "GEOGCS[\"WGS 84\"," + "GEOGCS[\"WGS 84\","
+ "DATUM[\"WGS_1984\"," + "DATUM[\"WGS_1984\","
+ "SPHEROID[\"WGS 84\",6378137,298.257223563," + "SPHEROID[\"WGS 84\",6378137,298.257223563,"