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() public EquirectangularProjection()
{ {
CrsId = DefaultCrsId; CrsId = DefaultCrsId;
} IsNormalCylindrical = true;
public override bool IsNormalCylindrical
{
get { return true; }
} }
public override Vector GetRelativeScale(Location location) public override Vector GetRelativeScale(Location location)

View file

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

View file

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

View file

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

View file

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

View file

@ -76,10 +76,14 @@ namespace MapControl.Projections
= "PROJCS[\"ETRS89 / UTM zone {1}N\"," = "PROJCS[\"ETRS89 / UTM zone {1}N\","
+ "GEOGCS[\"ETRS89\"," + "GEOGCS[\"ETRS89\","
+ "DATUM[\"European_Terrestrial_Reference_System_1989\"," + "DATUM[\"European_Terrestrial_Reference_System_1989\","
+ "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," + "SPHEROID[\"GRS 1980\",6378137,298.257222101,"
+ "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]]," + "AUTHORITY[\"EPSG\",\"7019\"]],"
+ "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," + "TOWGS84[0,0,0,0,0,0,0],"
+ "UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]," + "AUTHORITY[\"EPSG\",\"6258\"]],"
+ "PRIMEM[\"Greenwich\",0,"
+ "AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"degree\",0.0174532925199433,"
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
+ "AUTHORITY[\"EPSG\",\"4258\"]]," + "AUTHORITY[\"EPSG\",\"4258\"]],"
+ "PROJECTION[\"Transverse_Mercator\"]," + "PROJECTION[\"Transverse_Mercator\"],"
+ "PARAMETER[\"latitude_of_origin\",0]," + "PARAMETER[\"latitude_of_origin\",0],"
@ -87,7 +91,8 @@ namespace MapControl.Projections
+ "PARAMETER[\"scale_factor\",0.9996]," + "PARAMETER[\"scale_factor\",0.9996],"
+ "PARAMETER[\"false_easting\",500000]," + "PARAMETER[\"false_easting\",500000],"
+ "PARAMETER[\"false_northing\",0]," + "PARAMETER[\"false_northing\",0],"
+ "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]]," + "UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],"
+ "AXIS[\"Easting\",EAST]," + "AXIS[\"Easting\",EAST],"
+ "AXIS[\"Northing\",NORTH]," + "AXIS[\"Northing\",NORTH],"
+ "AUTHORITY[\"EPSG\",\"{0}\"]]"; + "AUTHORITY[\"EPSG\",\"{0}\"]]";

View file

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