mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Added MapProjectionFactory
This commit is contained in:
parent
67b87acb44
commit
e2fcc1db2c
12 changed files with 87 additions and 17 deletions
|
|
@ -11,9 +11,11 @@ namespace MapControl
|
|||
{
|
||||
public class AutoEquirectangularProjection : MapProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42004";
|
||||
|
||||
public AutoEquirectangularProjection()
|
||||
{
|
||||
CrsId = "AUTO2:42004";
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class EquirectangularProjection : MapProjection
|
||||
{
|
||||
public const string DefaultCrsId = "EPSG:4326";
|
||||
|
||||
public EquirectangularProjection()
|
||||
{
|
||||
CrsId = "EPSG:4326";
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class GnomonicProjection : AzimuthalProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:97001"; // GeoServer non-standard CRS ID
|
||||
|
||||
public GnomonicProjection()
|
||||
{
|
||||
CrsId = "AUTO2:97001"; // GeoServer non-standard CRS ID
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ using System.Windows.Media;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class GroundOverlayPanel : MapPanel
|
||||
public class GroundOverlay : MapPanel
|
||||
{
|
||||
class LatLonBox : BoundingBox
|
||||
{
|
||||
|
|
@ -56,8 +56,8 @@ namespace MapControl
|
|||
}
|
||||
|
||||
public static readonly DependencyProperty SourcePathProperty = DependencyProperty.Register(
|
||||
nameof(SourcePath), typeof(string), typeof(GroundOverlayPanel),
|
||||
new PropertyMetadata(null, async (o, e) => await ((GroundOverlayPanel)o).SourcePathPropertyChanged((string)e.NewValue)));
|
||||
nameof(SourcePath), typeof(string), typeof(GroundOverlay),
|
||||
new PropertyMetadata(null, async (o, e) => await ((GroundOverlay)o).SourcePathPropertyChanged((string)e.NewValue)));
|
||||
|
||||
public string SourcePath
|
||||
{
|
||||
|
|
@ -22,6 +22,8 @@ namespace MapControl
|
|||
public const double Wgs84Flattening = 1d / 298.257223563;
|
||||
public static readonly double Wgs84Eccentricity = Math.Sqrt((2d - Wgs84Flattening) * Wgs84Flattening);
|
||||
|
||||
public static MapProjectionFactory Factory { get; set; } = new MapProjectionFactory();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the WMS 1.3.0 CRS identifier.
|
||||
/// </summary>
|
||||
|
|
|
|||
51
MapControl/Shared/MapProjectionFactory.cs
Normal file
51
MapControl/Shared/MapProjectionFactory.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2022 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class MapProjectionFactory
|
||||
{
|
||||
public virtual MapProjection CreateProjection(string projectionDefinition)
|
||||
{
|
||||
MapProjection projection = null;
|
||||
|
||||
switch (projectionDefinition)
|
||||
{
|
||||
case WorldMercatorProjection.DefaultCrsId:
|
||||
projection = new WorldMercatorProjection();
|
||||
break;
|
||||
|
||||
case WebMercatorProjection.DefaultCrsId:
|
||||
projection = new WebMercatorProjection();
|
||||
break;
|
||||
|
||||
case EquirectangularProjection.DefaultCrsId:
|
||||
projection = new EquirectangularProjection();
|
||||
break;
|
||||
|
||||
case OrthographicProjection.DefaultCrsId:
|
||||
projection = new OrthographicProjection();
|
||||
break;
|
||||
|
||||
case AutoEquirectangularProjection.DefaultCrsId:
|
||||
projection = new AutoEquirectangularProjection();
|
||||
break;
|
||||
|
||||
case GnomonicProjection.DefaultCrsId:
|
||||
projection = new GnomonicProjection();
|
||||
break;
|
||||
|
||||
case StereographicProjection.DefaultCrsId:
|
||||
projection = new StereographicProjection();
|
||||
break;
|
||||
|
||||
case "EPSG:97003": // proprietary CRS ID
|
||||
projection = new AzimuthalEquidistantProjection { CrsId = projectionDefinition };
|
||||
break;
|
||||
}
|
||||
|
||||
return projection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class OrthographicProjection : AzimuthalProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42003";
|
||||
|
||||
public OrthographicProjection()
|
||||
{
|
||||
CrsId = "AUTO2:42003";
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class StereographicProjection : AzimuthalProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:97002"; // GeoServer non-standard CRS ID
|
||||
|
||||
public StereographicProjection()
|
||||
{
|
||||
CrsId = "AUTO2:97002"; // GeoServer non-standard CRS ID
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override Point LocationToMap(Location location)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class WebMercatorProjection : MapProjection
|
||||
{
|
||||
public const string DefaultCrsId = "EPSG:3857";
|
||||
|
||||
private static readonly double maxLatitude = YToLatitude(180d);
|
||||
|
||||
public WebMercatorProjection()
|
||||
{
|
||||
CrsId = "EPSG:3857";
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class WorldMercatorProjection : MapProjection
|
||||
{
|
||||
public const string DefaultCrsId = "EPSG:3395";
|
||||
|
||||
public static double ConvergenceTolerance { get; set; } = 1e-6;
|
||||
public static int MaxIterations { get; set; } = 10;
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ namespace MapControl
|
|||
|
||||
public WorldMercatorProjection()
|
||||
{
|
||||
CrsId = "EPSG:3395";
|
||||
CrsId = DefaultCrsId;
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue