mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Updated MapProjection and MapGraticule
This commit is contained in:
parent
2a45c1165c
commit
cfed3575ac
16 changed files with 392 additions and 355 deletions
|
|
@ -52,10 +52,13 @@ namespace MapControl.Projections
|
|||
var projection = field.Projection ??
|
||||
throw new ArgumentException("CoordinateSystem.Projection must not be null.", nameof(value));
|
||||
|
||||
IsNormalCylindrical = projection.Name.StartsWith("Mercator") || projection.Name.Contains("Pseudo-Mercator");
|
||||
|
||||
var ellipsoid = field.GeographicCoordinateSystem.HorizontalDatum.Ellipsoid;
|
||||
var transformFactory = new CoordinateTransformationFactory();
|
||||
|
||||
CrsId = !string.IsNullOrEmpty(field.Authority) && field.AuthorityCode > 0
|
||||
? $"{field.Authority}:{field.AuthorityCode}"
|
||||
: string.Empty;
|
||||
|
||||
LocationToMapTransform = transformFactory
|
||||
.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, field)
|
||||
.MathTransform;
|
||||
|
|
@ -64,14 +67,9 @@ namespace MapControl.Projections
|
|||
.CreateFromCoordinateSystems(field, GeographicCoordinateSystem.WGS84)
|
||||
.MathTransform;
|
||||
|
||||
CrsId = !string.IsNullOrEmpty(field.Authority) && field.AuthorityCode > 0
|
||||
? $"{field.Authority}:{field.AuthorityCode}"
|
||||
: string.Empty;
|
||||
|
||||
var ellipsoid = field.GeographicCoordinateSystem.HorizontalDatum.Ellipsoid;
|
||||
|
||||
if (projection.Name.Contains("Pseudo-Mercator"))
|
||||
{
|
||||
IsNormalCylindrical = true;
|
||||
FallbackProjection = new MapControl.WebMercatorProjection
|
||||
{
|
||||
EquatorialRadius = ellipsoid.SemiMajorAxis
|
||||
|
|
@ -79,6 +77,7 @@ namespace MapControl.Projections
|
|||
}
|
||||
else if (projection.Name.StartsWith("Mercator"))
|
||||
{
|
||||
IsNormalCylindrical = true;
|
||||
FallbackProjection = new MapControl.WorldMercatorProjection
|
||||
{
|
||||
EquatorialRadius = ellipsoid.SemiMajorAxis,
|
||||
|
|
@ -106,7 +105,7 @@ namespace MapControl.Projections
|
|||
ScaleFactor = projection.GetParameter("scale_factor").Value,
|
||||
FalseEasting = projection.GetParameter("false_easting").Value,
|
||||
FalseNorthing = projection.GetParameter("false_northing").Value,
|
||||
Hemisphere = projection.GetParameter("latitude_of_origin").Value >= 0 ? Hemisphere.North : Hemisphere.South
|
||||
LatitudeOfOrigin = projection.GetParameter("latitude_of_origin").Value
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace MapControl.Projections
|
|||
{ 29193, WktConstants.ProjCsSad69Utm23S },
|
||||
};
|
||||
|
||||
public override MapProjection GetProjection(string crsId)
|
||||
protected override MapProjection CreateProjection(string crsId)
|
||||
{
|
||||
return crsId switch
|
||||
{
|
||||
|
|
@ -32,11 +32,11 @@ namespace MapControl.Projections
|
|||
MapControl.WorldMercatorProjection.DefaultCrsId => new WorldMercatorProjection(),
|
||||
MapControl.Wgs84UpsNorthProjection.DefaultCrsId => new Wgs84UpsNorthProjection(),
|
||||
MapControl.Wgs84UpsSouthProjection.DefaultCrsId => new Wgs84UpsSouthProjection(),
|
||||
_ => GetProjectionFromEpsgCode(crsId) ?? base.GetProjection(crsId)
|
||||
_ => base.CreateProjection(crsId)
|
||||
};
|
||||
}
|
||||
|
||||
public override MapProjection GetProjection(int epsgCode)
|
||||
protected override MapProjection CreateProjection(int epsgCode)
|
||||
{
|
||||
if (CoordinateSystemWkts.TryGetValue(epsgCode, out string wkt))
|
||||
{
|
||||
|
|
@ -57,7 +57,7 @@ namespace MapControl.Projections
|
|||
and <= MapControl.Wgs84UtmProjection.LastZoneNorthEpsgCode => new Wgs84UtmProjection(c % 100, Hemisphere.North),
|
||||
var c when c is >= MapControl.Wgs84UtmProjection.FirstZoneSouthEpsgCode
|
||||
and <= MapControl.Wgs84UtmProjection.LastZoneSouthEpsgCode => new Wgs84UtmProjection(c % 100, Hemisphere.South),
|
||||
_ => base.GetProjection(epsgCode)
|
||||
_ => base.CreateProjection(epsgCode)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue