diff --git a/MapControl/Shared/EquirectangularProjection.cs b/MapControl/Shared/EquirectangularProjection.cs index 5946ed9d..f773995f 100644 --- a/MapControl/Shared/EquirectangularProjection.cs +++ b/MapControl/Shared/EquirectangularProjection.cs @@ -35,12 +35,16 @@ namespace MapControl public override Point LocationToMap(double latitude, double longitude) { - return new Point(MeterPerDegree * longitude, MeterPerDegree * latitude); + return new Point( + EquatorialRadius * Math.PI / 180d * longitude, + EquatorialRadius * Math.PI / 180d * latitude); } public override Location MapToLocation(double x, double y) { - return new Location(y / MeterPerDegree, x / MeterPerDegree); + return new Location( + y / EquatorialRadius * 180d / Math.PI, + x / EquatorialRadius * 180d / Math.PI); } } } diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index c218a13c..94097b9f 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -53,8 +53,6 @@ namespace MapControl /// public double EquatorialRadius { get; set; } = Wgs84EquatorialRadius; - public double MeterPerDegree => EquatorialRadius * Math.PI / 180d; - /// /// Gets the relative transform at the specified geographic coordinates. /// The returned Matrix represents the local relative scale and rotation. diff --git a/MapControl/Shared/WebMercatorProjection.cs b/MapControl/Shared/WebMercatorProjection.cs index d2f4cc03..12f68f4b 100644 --- a/MapControl/Shared/WebMercatorProjection.cs +++ b/MapControl/Shared/WebMercatorProjection.cs @@ -37,15 +37,15 @@ namespace MapControl public override Point LocationToMap(double latitude, double longitude) { return new Point( - MeterPerDegree * longitude, - MeterPerDegree * LatitudeToY(latitude)); + EquatorialRadius * Math.PI / 180d * longitude, + EquatorialRadius * Math.PI / 180d * LatitudeToY(latitude)); } public override Location MapToLocation(double x, double y) { return new Location( - YToLatitude(y / MeterPerDegree), - x / MeterPerDegree); + YToLatitude(y / EquatorialRadius * 180d / Math.PI), + x / EquatorialRadius * 180d / Math.PI); } public static double LatitudeToY(double latitude) diff --git a/MapControl/Shared/WorldMercatorProjection.cs b/MapControl/Shared/WorldMercatorProjection.cs index 943944a8..0d03ad16 100644 --- a/MapControl/Shared/WorldMercatorProjection.cs +++ b/MapControl/Shared/WorldMercatorProjection.cs @@ -39,15 +39,15 @@ namespace MapControl public override Point LocationToMap(double latitude, double longitude) { return new Point( - MeterPerDegree * longitude, - MeterPerDegree * LatitudeToY(latitude)); + EquatorialRadius * Math.PI / 180d * longitude, + EquatorialRadius * Math.PI / 180d * LatitudeToY(latitude)); } public override Location MapToLocation(double x, double y) { return new Location( - YToLatitude(y / MeterPerDegree), - x / MeterPerDegree); + YToLatitude(y / EquatorialRadius * 180d / Math.PI), + x / EquatorialRadius * 180d / Math.PI); } public static double RelativeScale(double latitude)