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],"
+ "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],"
+ "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>
@ -42,7 +42,7 @@ namespace MapControl.Projections
/// 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.
/// </summary>
public string WKT
public string CoordinateSystemWkt
{
get { return CoordinateSystem?.WKT; }
protected set { CoordinateSystem = new CoordinateSystemFactory().CreateFromWkt(value); }

View file

@ -2,6 +2,8 @@
// © 2022 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic;
namespace MapControl.Projections
{
public class GeoApiProjectionFactory : MapProjectionFactory
@ -19,11 +21,17 @@ namespace MapControl.Projections
public const int Wgs84UtmSouthLast = 32760;
public const int Wgs84UpsSouth = 32761;
public Dictionary<string, string> CoordinateSystemWkts { get; } = new Dictionary<string, string>();
public override MapProjection GetProjection(string crsId)
{
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)
{

View file

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