mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Updated MapProjections
This commit is contained in:
parent
c6c597a142
commit
544ac32ee3
5 changed files with 129 additions and 112 deletions
|
|
@ -11,40 +11,90 @@ namespace MapControl.Projections
|
|||
{
|
||||
public class GeoApiProjectionFactory : MapProjectionFactory
|
||||
{
|
||||
public const int WorldMercator = 3395;
|
||||
public const int WebMercator = 3857;
|
||||
public const int Etrs89UtmNorthFirst = 25828;
|
||||
public const int Etrs89UtmNorthLast = 25838;
|
||||
public const int Wgs84UtmNorthFirst = 32601;
|
||||
public const int Wgs84UtmNorthLast = 32660;
|
||||
public const int Wgs84UpsNorth = 32661;
|
||||
public const int Wgs84UtmSouthFirst = 32701;
|
||||
public const int Wgs84UtmSouthLast = 32760;
|
||||
public const int Wgs84UpsSouth = 32761;
|
||||
|
||||
private readonly Dictionary<int, string> wkts = new Dictionary<int, string>();
|
||||
private readonly HttpClient httpClient = new HttpClient();
|
||||
|
||||
public override MapProjection CreateProjection(string projectionDefinition)
|
||||
public override MapProjection CreateProjection(string crsId)
|
||||
{
|
||||
var projection = base.CreateProjection(projectionDefinition);
|
||||
MapProjection projection = null;
|
||||
|
||||
if (projection == null &&
|
||||
projectionDefinition.StartsWith("EPSG:") &&
|
||||
int.TryParse(projectionDefinition.Substring(5), out int epsgCode))
|
||||
if (crsId.StartsWith("EPSG:") && int.TryParse(crsId.Substring(5), out int epsgCode))
|
||||
{
|
||||
if (epsgCode >= 32601 && epsgCode <= 32660)
|
||||
switch (epsgCode)
|
||||
{
|
||||
projection = new UtmProjection(epsgCode - 32600, true);
|
||||
}
|
||||
else if (epsgCode == 32661)
|
||||
{
|
||||
projection = new UpsNorthProjection();
|
||||
}
|
||||
else if (epsgCode >= 32701 && epsgCode <= 32760)
|
||||
{
|
||||
projection = new UtmProjection(epsgCode - 32700, false);
|
||||
}
|
||||
else if (epsgCode == 32761)
|
||||
{
|
||||
projection = new UpsSouthProjection();
|
||||
}
|
||||
else
|
||||
{
|
||||
projection = new GeoApiProjection(GetWkt(epsgCode));
|
||||
case WorldMercator:
|
||||
projection = new WorldMercatorProjection();
|
||||
break;
|
||||
|
||||
case WebMercator:
|
||||
projection = new WebMercatorProjection();
|
||||
break;
|
||||
|
||||
case int c when c >= Etrs89UtmNorthFirst && c <= Etrs89UtmNorthLast:
|
||||
projection = new GeoApiProjection(GetEtrs89UtmWkt(epsgCode));
|
||||
break;
|
||||
|
||||
case int c when c >= Wgs84UtmNorthFirst && c <= Wgs84UtmNorthLast:
|
||||
projection = new UtmProjection(epsgCode - Wgs84UtmNorthFirst + 1, true);
|
||||
break;
|
||||
|
||||
case int c when c >= Wgs84UtmSouthFirst && c <= Wgs84UtmSouthLast:
|
||||
projection = new UtmProjection(epsgCode - Wgs84UtmSouthFirst + 1, false);
|
||||
break;
|
||||
|
||||
case Wgs84UpsNorth:
|
||||
projection = new UpsNorthProjection();
|
||||
break;
|
||||
|
||||
case Wgs84UpsSouth:
|
||||
projection = new UpsSouthProjection();
|
||||
break;
|
||||
|
||||
default:
|
||||
projection = new GeoApiProjection(GetWkt(epsgCode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return projection;
|
||||
return projection ?? base.CreateProjection(crsId);
|
||||
}
|
||||
|
||||
private static string GetEtrs89UtmWkt(int epsgCode)
|
||||
{
|
||||
const string etrs89UtmWktFormat
|
||||
= "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}\"]]";
|
||||
|
||||
int centralMeridian = 6 * (epsgCode - Etrs89UtmNorthFirst) - 15;
|
||||
|
||||
return string.Format(etrs89UtmWktFormat, epsgCode, epsgCode - 25800, centralMeridian);
|
||||
}
|
||||
|
||||
private string GetWkt(int epsgCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue