diff --git a/MapControl/Shared/AutoEquirectangularProjection.cs b/MapControl/Shared/AutoEquirectangularProjection.cs index 6949e530..45153bd5 100644 --- a/MapControl/Shared/AutoEquirectangularProjection.cs +++ b/MapControl/Shared/AutoEquirectangularProjection.cs @@ -18,19 +18,19 @@ namespace MapControl public override Point LocationToMap(Location location) { - var xScale = UnitsPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d); + var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d); return new Point( xScale * (location.Longitude - Center.Longitude), - UnitsPerDegree * location.Latitude); + Wgs84MetersPerDegree * location.Latitude); } public override Location MapToLocation(Point point) { - var xScale = UnitsPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d); + var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d); return new Location( - point.Y / UnitsPerDegree, + point.Y / Wgs84MetersPerDegree, point.X / xScale + Center.Longitude); } } diff --git a/MapControl/Shared/AzimuthalEquidistantProjection.cs b/MapControl/Shared/AzimuthalEquidistantProjection.cs index fd77c207..02c7a130 100644 --- a/MapControl/Shared/AzimuthalEquidistantProjection.cs +++ b/MapControl/Shared/AzimuthalEquidistantProjection.cs @@ -27,7 +27,7 @@ namespace MapControl GetAzimuthDistance(Center, location, out azimuth, out distance); - var mapDistance = distance * UnitsPerDegree * 180d / Math.PI; + var mapDistance = distance * Wgs84EquatorialRadius; return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth)); } @@ -42,7 +42,7 @@ namespace MapControl var azimuth = Math.Atan2(point.X, point.Y); var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y); - var distance = mapDistance / (UnitsPerDegree * 180d / Math.PI); + var distance = mapDistance / Wgs84EquatorialRadius; return GetLocation(Center, azimuth, distance); } diff --git a/MapControl/Shared/EquirectangularProjection.cs b/MapControl/Shared/EquirectangularProjection.cs index 6a853388..2ffd632c 100644 --- a/MapControl/Shared/EquirectangularProjection.cs +++ b/MapControl/Shared/EquirectangularProjection.cs @@ -33,23 +33,23 @@ namespace MapControl public override Point LocationToMap(Location location) { return new Point( - location.Longitude * UnitsPerDegree, - location.Latitude * UnitsPerDegree); + Wgs84MetersPerDegree * location.Longitude, + Wgs84MetersPerDegree * location.Latitude); } public override Location MapToLocation(Point point) { return new Location( - point.Y / UnitsPerDegree, - point.X / UnitsPerDegree); + point.Y / Wgs84MetersPerDegree, + point.X / Wgs84MetersPerDegree); } public override string GetBboxValue(Rect rect) { return string.Format(CultureInfo.InvariantCulture, CrsId == "CRS:84" ? "{0},{1},{2},{3}" : "{1},{0},{3},{2}", - rect.X / UnitsPerDegree, rect.Y / UnitsPerDegree, - (rect.X + rect.Width) / UnitsPerDegree, (rect.Y + rect.Height) / UnitsPerDegree); + rect.X / Wgs84MetersPerDegree, rect.Y / Wgs84MetersPerDegree, + (rect.X + rect.Width) / Wgs84MetersPerDegree, (rect.Y + rect.Height) / Wgs84MetersPerDegree); } } } diff --git a/MapControl/Shared/GnomonicProjection.cs b/MapControl/Shared/GnomonicProjection.cs index be7976cb..7fb1aec7 100644 --- a/MapControl/Shared/GnomonicProjection.cs +++ b/MapControl/Shared/GnomonicProjection.cs @@ -31,7 +31,7 @@ namespace MapControl GetAzimuthDistance(Center, location, out azimuth, out distance); var mapDistance = distance < Math.PI / 2d - ? Math.Tan(distance) * UnitsPerDegree * 180d / Math.PI + ? Math.Tan(distance) * Wgs84EquatorialRadius : double.PositiveInfinity; return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth)); @@ -47,7 +47,7 @@ namespace MapControl var azimuth = Math.Atan2(point.X, point.Y); var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y); - var distance = Math.Atan(mapDistance / (UnitsPerDegree * 180d / Math.PI)); + var distance = Math.Atan(mapDistance / Wgs84EquatorialRadius); return GetLocation(Center, azimuth, distance); } diff --git a/MapControl/Shared/MapGraticule.cs b/MapControl/Shared/MapGraticule.cs index b06bfef1..19cb9773 100644 --- a/MapControl/Shared/MapGraticule.cs +++ b/MapControl/Shared/MapGraticule.cs @@ -30,7 +30,7 @@ namespace MapControl private double GetLineDistance() { - var pixelPerDegree = ParentMap.ViewTransform.Scale * ParentMap.MapProjection.UnitsPerDegree; + var pixelPerDegree = ParentMap.ViewTransform.Scale * MapProjection.Wgs84MetersPerDegree; var minDistance = MinLineDistance / pixelPerDegree; var scale = 1d; diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index 640a706f..ab593779 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -56,15 +56,6 @@ namespace MapControl get { return 90d; } } - /// - /// Gets the scale factor from geographic to cartesian coordinates, on the line of true scale of a - /// cylindrical projection (usually the equator), or at the projection center of an azimuthal projection. - /// - public virtual double UnitsPerDegree - { - get { return Wgs84MetersPerDegree; } - } - /// /// Gets the relative map scale at the specified Location. /// diff --git a/MapControl/Shared/OrthographicProjection.cs b/MapControl/Shared/OrthographicProjection.cs index 595669d5..354c3817 100644 --- a/MapControl/Shared/OrthographicProjection.cs +++ b/MapControl/Shared/OrthographicProjection.cs @@ -29,11 +29,10 @@ namespace MapControl var lat0 = Center.Latitude * Math.PI / 180d; var lat = location.Latitude * Math.PI / 180d; var dLon = (location.Longitude - Center.Longitude) * Math.PI / 180d; - var s = UnitsPerDegree * 180d / Math.PI; return new Point( - s * Math.Cos(lat) * Math.Sin(dLon), - s * (Math.Cos(lat0) * Math.Sin(lat) - Math.Sin(lat0) * Math.Cos(lat) * Math.Cos(dLon))); + Wgs84EquatorialRadius * Math.Cos(lat) * Math.Sin(dLon), + Wgs84EquatorialRadius * (Math.Cos(lat0) * Math.Sin(lat) - Math.Sin(lat0) * Math.Cos(lat) * Math.Cos(dLon))); } public override Location MapToLocation(Point point) @@ -43,9 +42,8 @@ namespace MapControl return new Location(Center.Latitude, Center.Longitude); } - var s = UnitsPerDegree * 180d / Math.PI; - var x = point.X / s; - var y = point.Y / s; + var x = point.X / Wgs84EquatorialRadius; + var y = point.Y / Wgs84EquatorialRadius; var r2 = x * x + y * y; if (r2 > 1d) diff --git a/MapControl/Shared/StereographicProjection.cs b/MapControl/Shared/StereographicProjection.cs index dd442cc6..2be46afc 100644 --- a/MapControl/Shared/StereographicProjection.cs +++ b/MapControl/Shared/StereographicProjection.cs @@ -30,7 +30,7 @@ namespace MapControl GetAzimuthDistance(Center, location, out azimuth, out distance); - var mapDistance = Math.Tan(distance / 2d) * 2d * UnitsPerDegree * 180d / Math.PI; + var mapDistance = Math.Tan(distance / 2d) * 2d * Wgs84EquatorialRadius; return new Point(mapDistance * Math.Sin(azimuth), mapDistance * Math.Cos(azimuth)); } @@ -45,7 +45,7 @@ namespace MapControl var azimuth = Math.Atan2(point.X, point.Y); var mapDistance = Math.Sqrt(point.X * point.X + point.Y * point.Y); - var distance = 2d * Math.Atan(mapDistance / (2d * UnitsPerDegree * 180d / Math.PI)); + var distance = 2d * Math.Atan(mapDistance / (2d * Wgs84EquatorialRadius)); return GetLocation(Center, azimuth, distance); } diff --git a/MapControl/Shared/WebMercatorProjection.cs b/MapControl/Shared/WebMercatorProjection.cs index 3fe98c26..d73355db 100644 --- a/MapControl/Shared/WebMercatorProjection.cs +++ b/MapControl/Shared/WebMercatorProjection.cs @@ -42,15 +42,15 @@ namespace MapControl public override Point LocationToMap(Location location) { return new Point( - UnitsPerDegree * location.Longitude, - UnitsPerDegree * LatitudeToY(location.Latitude)); + Wgs84MetersPerDegree * location.Longitude, + Wgs84MetersPerDegree * LatitudeToY(location.Latitude)); } public override Location MapToLocation(Point point) { return new Location( - YToLatitude(point.Y / UnitsPerDegree), - point.X / UnitsPerDegree); + YToLatitude(point.Y / Wgs84MetersPerDegree), + point.X / Wgs84MetersPerDegree); } public static double LatitudeToY(double latitude) diff --git a/MapControl/Shared/WorldMercatorProjection.cs b/MapControl/Shared/WorldMercatorProjection.cs index 4d3ddcdb..2008619f 100644 --- a/MapControl/Shared/WorldMercatorProjection.cs +++ b/MapControl/Shared/WorldMercatorProjection.cs @@ -42,15 +42,15 @@ namespace MapControl public override Point LocationToMap(Location location) { return new Point( - UnitsPerDegree * location.Longitude, - UnitsPerDegree * LatitudeToY(location.Latitude)); + Wgs84MetersPerDegree * location.Longitude, + Wgs84MetersPerDegree * LatitudeToY(location.Latitude)); } public override Location MapToLocation(Point point) { return new Location( - YToLatitude(point.Y / UnitsPerDegree), - point.X / UnitsPerDegree); + YToLatitude(point.Y / Wgs84MetersPerDegree), + point.X / Wgs84MetersPerDegree); } public static double LatitudeToY(double latitude) diff --git a/MapProjections/Shared/GeoApiProjection.cs b/MapProjections/Shared/GeoApiProjection.cs index 8ae69229..1fb3d506 100644 --- a/MapProjections/Shared/GeoApiProjection.cs +++ b/MapProjections/Shared/GeoApiProjection.cs @@ -110,11 +110,6 @@ namespace MapControl.Projections get { return isWebMercator; } } - public override double UnitsPerDegree - { - get { return unitsPerDegree; } - } - public override Point LocationToMap(Location location) { if (LocationToMapTransform == null) diff --git a/MapProjections/Shared/PolarStereographicProjection.cs b/MapProjections/Shared/PolarStereographicProjection.cs index 81d26be9..4fa0cfdd 100644 --- a/MapProjections/Shared/PolarStereographicProjection.cs +++ b/MapProjections/Shared/PolarStereographicProjection.cs @@ -33,11 +33,6 @@ namespace MapControl.Projections this.falseNorthing = falseNorthing; } - public override double UnitsPerDegree - { - get { return scaleFactor * Wgs84MetersPerDegree; } - } - public override Vector GetRelativeScale(Location location) { var lat = (north ? location.Latitude : -location.Latitude) * Math.PI / 180d;