MapProjection properties

This commit is contained in:
Clemens 2022-01-21 23:26:21 +01:00
parent 9a26fdaefc
commit e6b25c2f8d
7 changed files with 31 additions and 71 deletions

View file

@ -23,11 +23,7 @@ namespace MapControl
public EquirectangularProjection()
{
CrsId = DefaultCrsId;
}
public override bool IsNormalCylindrical
{
get { return true; }
IsNormalCylindrical = true;
}
public override Vector GetRelativeScale(Location location)

View file

@ -37,26 +37,17 @@ namespace MapControl
/// <summary>
/// Indicates if this is a normal cylindrical projection.
/// </summary>
public virtual bool IsNormalCylindrical
{
get { return false; }
}
public bool IsNormalCylindrical { get; protected set; }
/// <summary>
/// Indicates if this is a web mercator projection, i.e. compatible with MapTileLayer.
/// </summary>
public virtual bool IsWebMercator
{
get { return false; }
}
public bool IsWebMercator { get; protected set; }
/// <summary>
/// Gets the absolute value of the minimum and maximum latitude that can be transformed.
/// </summary>
public virtual double MaxLatitude
{
get { return 90d; }
}
public double MaxLatitude { get; protected set; } = 90d;
/// <summary>
/// Gets the relative map scale at the specified Location.

View file

@ -17,26 +17,12 @@ namespace MapControl
{
public const string DefaultCrsId = "EPSG:3857";
private static readonly double maxLatitude = YToLatitude(180d);
public WebMercatorProjection()
{
CrsId = DefaultCrsId;
}
public override bool IsNormalCylindrical
{
get { return true; }
}
public override bool IsWebMercator
{
get { return true; }
}
public override double MaxLatitude
{
get { return maxLatitude; }
IsNormalCylindrical = true;
IsWebMercator = true;
MaxLatitude = YToLatitude(180d);
}
public override Vector GetRelativeScale(Location location)

View file

@ -20,21 +20,11 @@ namespace MapControl
public static double ConvergenceTolerance { get; set; } = 1e-6;
public static int MaxIterations { get; set; } = 10;
private static readonly double maxLatitude = YToLatitude(180d);
public WorldMercatorProjection()
{
CrsId = DefaultCrsId;
}
public override bool IsNormalCylindrical
{
get { return true; }
}
public override double MaxLatitude
{
get { return maxLatitude; }
IsNormalCylindrical = true;
MaxLatitude = YToLatitude(180d);
}
public override Vector GetRelativeScale(Location location)

View file

@ -25,8 +25,6 @@ namespace MapControl.Projections
public class GeoApiProjection : MapProjection
{
private ICoordinateSystem coordinateSystem;
private bool isNormalCylindrical;
private bool isWebMercator;
private double scaleFactor;
private string bboxFormat;
@ -83,19 +81,19 @@ namespace MapControl.Projections
var falseEasting = projection.GetParameter("false_easting");
var falseNorthing = projection.GetParameter("false_northing");
isNormalCylindrical =
IsNormalCylindrical =
(centralMeridian == null || centralMeridian.Value == 0d) &&
(centralParallel == null || centralParallel.Value == 0d) &&
(falseEasting == null || falseEasting.Value == 0d) &&
(falseNorthing == null || falseNorthing.Value == 0d);
isWebMercator = CrsId == "EPSG:3857" || CrsId == "EPSG:900913";
IsWebMercator = CrsId == "EPSG:3857" || CrsId == "EPSG:900913";
scaleFactor = 1d;
bboxFormat = "{0},{1},{2},{3}";
}
else
{
isNormalCylindrical = true;
isWebMercator = false;
IsNormalCylindrical = true;
IsWebMercator = false;
scaleFactor = Wgs84MetersPerDegree;
bboxFormat = "{1},{0},{3},{2}";
}
@ -106,16 +104,6 @@ namespace MapControl.Projections
public IMathTransform MapToLocationTransform { get; private set; }
public override bool IsNormalCylindrical
{
get { return isNormalCylindrical; }
}
public override bool IsWebMercator
{
get { return isWebMercator; }
}
public override Point LocationToMap(Location location)
{
if (LocationToMapTransform == null)

View file

@ -76,10 +76,14 @@ namespace MapControl.Projections
= "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\"]],"
+ "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],"
@ -87,7 +91,8 @@ namespace MapControl.Projections
+ "PARAMETER[\"scale_factor\",0.9996],"
+ "PARAMETER[\"false_easting\",500000],"
+ "PARAMETER[\"false_northing\",0],"
+ "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
+ "UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],"
+ "AXIS[\"Easting\",EAST],"
+ "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"{0}\"]]";

View file

@ -20,10 +20,13 @@ namespace MapControl.Projections
WKT = "PROJCS[\"WGS 84 / World Mercator\","
+ "GEOGCS[\"WGS 84\","
+ "DATUM[\"WGS_1984\","
+ "SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],"
+ "SPHEROID[\"WGS 84\",6378137,298.257223563,"
+ "AUTHORITY[\"EPSG\",\"7030\"]],"
+ "AUTHORITY[\"EPSG\",\"6326\"]],"
+ "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],"
+ "PRIMEM[\"Greenwich\",0,"
+ "AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"degree\",0.0174532925199433,"
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
+ "AUTHORITY[\"EPSG\",\"4326\"]],"
+ "PROJECTION[\"Mercator_1SP\"],"
+ "PARAMETER[\"latitude_of_origin\",0],"
@ -31,7 +34,8 @@ namespace MapControl.Projections
+ "PARAMETER[\"scale_factor\",1],"
+ "PARAMETER[\"false_easting\",0],"
+ "PARAMETER[\"false_northing\",0],"
+ "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
+ "UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],"
+ "AXIS[\"Easting\",EAST],"
+ "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"3395\"]]";