Added Etrs89UtmProjection

This commit is contained in:
Clemens 2022-01-23 14:02:04 +01:00
parent 45b5d037bb
commit 0896209e22
4 changed files with 66 additions and 52 deletions

View file

@ -8,8 +8,8 @@ namespace MapControl.Projections
{
public const int WorldMercator = 3395;
public const int WebMercator = 3857;
public const int Etrs89UtmNorthFirst = 25828;
public const int Etrs89UtmNorthLast = 25838;
public const int Etrs89UtmFirst = 25828;
public const int Etrs89UtmLast = 25838;
public const int Wgs84UtmNorthFirst = 32601;
public const int Wgs84UtmNorthLast = 32660;
public const int Wgs84UpsNorth = 32661;
@ -33,16 +33,16 @@ namespace MapControl.Projections
projection = new WebMercatorProjection();
break;
case int c when c >= Etrs89UtmNorthFirst && c <= Etrs89UtmNorthLast:
projection = new GeoApiProjection(GetEtrs89UtmWkt(epsgCode));
case int c when c >= Etrs89UtmFirst && c <= Etrs89UtmLast:
projection = new Etrs89UtmProjection(epsgCode % 100);
break;
case int c when c >= Wgs84UtmNorthFirst && c <= Wgs84UtmNorthLast:
projection = new UtmProjection(epsgCode - Wgs84UtmNorthFirst + 1, true);
projection = new Wgs84UtmProjection(epsgCode % 100, true);
break;
case int c when c >= Wgs84UtmSouthFirst && c <= Wgs84UtmSouthLast:
projection = new UtmProjection(epsgCode - Wgs84UtmSouthFirst + 1, false);
projection = new Wgs84UtmProjection(epsgCode % 100, false);
break;
case Wgs84UpsNorth:
@ -60,38 +60,5 @@ namespace MapControl.Projections
return projection ?? base.GetProjection(crsId);
}
private static string GetEtrs89UtmWkt(int epsgCode)
{
const string wktFormat
= "PROJCS[\"ETRS89 / UTM zone {1}N\","
+ "GEOGCS[\"ETRS89\","
+ "DATUM[\"European_Terrestrial_Reference_System_1989\","
+ "SPHEROID[\"GRS 1980\",6378137,298.257222101,"
+ "AUTHORITY[\"EPSG\",\"7019\"]],"
+ "TOWGS84[0,0,0,0,0,0,0],"
+ "AUTHORITY[\"EPSG\",\"6258\"]],"
+ "PRIMEM[\"Greenwich\",0,"
+ "AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"degree\",0.0174532925199433,"
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
+ "AUTHORITY[\"EPSG\",\"4258\"]],"
+ "PROJECTION[\"Transverse_Mercator\"],"
+ "PARAMETER[\"latitude_of_origin\",0],"
+ "PARAMETER[\"central_meridian\",{2}],"
+ "PARAMETER[\"scale_factor\",0.9996],"
+ "PARAMETER[\"false_easting\",500000],"
+ "PARAMETER[\"false_northing\",0],"
+ "UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],"
+ "AXIS[\"Easting\",EAST],"
+ "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"{0}\"]]";
var zone = epsgCode % 100;
var centralMeridian = 6 * (epsgCode - Etrs89UtmNorthFirst) - 15;
return string.Format(wktFormat, epsgCode, zone, centralMeridian);
}
}
}