diff --git a/MapControl/Shared/AzimuthalEquidistantProjection.cs b/MapControl/Shared/AzimuthalEquidistantProjection.cs
index 03c26ffe..a403d396 100644
--- a/MapControl/Shared/AzimuthalEquidistantProjection.cs
+++ b/MapControl/Shared/AzimuthalEquidistantProjection.cs
@@ -11,7 +11,7 @@ namespace MapControl
/// Spherical Azimuthal Equidistant Projection - No standard CRS identifier.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.195-197.
///
- public class AzimuthalEquidistantProjection : AzimuthalProjection
+ public class AzimuthalEquidistantProjection : MapProjection
{
public const string DefaultCrsId = "AUTO2:97003"; // proprietary CRS identifier
@@ -22,9 +22,12 @@ namespace MapControl
public AzimuthalEquidistantProjection(string crsId)
{
+ Type = MapProjectionType.Azimuthal;
CrsId = crsId;
}
+ public double EarthRadius { get; set; } = Wgs84MeanRadius;
+
public override Point? LocationToMap(double latitude, double longitude)
{
if (Center.Equals(latitude, longitude))
diff --git a/MapControl/Shared/AzimuthalProjection.cs b/MapControl/Shared/AzimuthalProjection.cs
deleted file mode 100644
index fd29a2cc..00000000
--- a/MapControl/Shared/AzimuthalProjection.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-#if WPF
-using System.Windows;
-#elif AVALONIA
-using Avalonia;
-#endif
-
-namespace MapControl
-{
- ///
- /// Base class for spherical azimuthal map projections.
- ///
- public abstract class AzimuthalProjection : MapProjection
- {
- protected AzimuthalProjection()
- {
- Type = MapProjectionType.Azimuthal;
- }
-
- public double EarthRadius { get; set; } = Wgs84MeanRadius;
-
- public override Rect? BoundingBoxToMap(BoundingBox boundingBox)
- {
- Rect? rect = null;
- var center = LocationToMap(boundingBox.Center);
-
- if (center.HasValue)
- {
- var width = boundingBox.Width * Wgs84MeterPerDegree;
- var height = boundingBox.Height * Wgs84MeterPerDegree;
- var x = center.Value.X - width / 2d;
- var y = center.Value.Y - height / 2d;
-
- rect = new Rect(x, y, width, height);
- }
-
- return rect;
- }
-
- public override BoundingBox MapToBoundingBox(Rect rect)
- {
- BoundingBox boundingBox = null;
- var center = MapToLocation(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
-
- if (center != null)
- {
- boundingBox = new CenteredBoundingBox(center, rect.Width / Wgs84MeterPerDegree, rect.Height / Wgs84MeterPerDegree);
- }
-
- return boundingBox;
- }
- }
-}
diff --git a/MapControl/Shared/BoundingBox.cs b/MapControl/Shared/BoundingBox.cs
index 5d4ad5f2..27a153bd 100644
--- a/MapControl/Shared/BoundingBox.cs
+++ b/MapControl/Shared/BoundingBox.cs
@@ -35,11 +35,6 @@ namespace MapControl
public double West { get; }
public double East { get; }
- public virtual double Width => East - West;
- public virtual double Height => North - South;
-
- public virtual Location Center => new Location((South + North) / 2d, (West + East) / 2d);
-
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", South, West, North, East);
diff --git a/MapControl/Shared/CenteredBoundingBox.cs b/MapControl/Shared/CenteredBoundingBox.cs
deleted file mode 100644
index 54ab920c..00000000
--- a/MapControl/Shared/CenteredBoundingBox.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace MapControl
-{
- public class CenteredBoundingBox(Location center, double width, double height) : BoundingBox
- {
- public override Location Center => center;
- public override double Width { get; } = Math.Max(width, 0d);
- public override double Height { get; } = Math.Max(height, 0d);
- }
-}
diff --git a/MapControl/Shared/GnomonicProjection.cs b/MapControl/Shared/GnomonicProjection.cs
index 0cd6887f..3f21fa51 100644
--- a/MapControl/Shared/GnomonicProjection.cs
+++ b/MapControl/Shared/GnomonicProjection.cs
@@ -11,7 +11,7 @@ namespace MapControl
/// Spherical Gnomonic Projection - AUTO2:97001.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.165-167.
///
- public class GnomonicProjection : AzimuthalProjection
+ public class GnomonicProjection : MapProjection
{
public const string DefaultCrsId = "AUTO2:97001"; // GeoServer non-standard CRS identifier
@@ -22,9 +22,12 @@ namespace MapControl
public GnomonicProjection(string crsId)
{
+ Type = MapProjectionType.Azimuthal;
CrsId = crsId;
}
+ public double EarthRadius { get; set; } = Wgs84MeanRadius;
+
public override Point? LocationToMap(double latitude, double longitude)
{
if (Center.Equals(latitude, longitude))
diff --git a/MapControl/Shared/Location.cs b/MapControl/Shared/Location.cs
index 2ffdfcb1..efd196dd 100644
--- a/MapControl/Shared/Location.cs
+++ b/MapControl/Shared/Location.cs
@@ -38,7 +38,7 @@ namespace MapControl
public override int GetHashCode() => Latitude.GetHashCode() ^ Longitude.GetHashCode();
- public override string ToString() => string.Format(CultureInfo.InvariantCulture, "{0:0.########},{1:0.########}", Latitude, Longitude);
+ public override string ToString() => string.Format(CultureInfo.InvariantCulture, "{0},{1}", Latitude, Longitude);
///
/// Creates a Location instance from a string containing a comma-separated pair of floating point numbers.
diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs
index dd4a4e33..2f8df08c 100644
--- a/MapControl/Shared/MapProjection.cs
+++ b/MapControl/Shared/MapProjection.cs
@@ -122,8 +122,8 @@ namespace MapControl
{
Rect? rect = null;
var rotation = 0d;
- var centerLatitude = latLonBox.Center.Latitude;
- var centerLongitude = latLonBox.Center.Longitude;
+ var centerLatitude = (latLonBox.South + latLonBox.North) / 2d;
+ var centerLongitude = (latLonBox.West + latLonBox.East) / 2d;
Point? center, north, south, west, east;
if ((center = LocationToMap(centerLatitude, centerLongitude)).HasValue &&
diff --git a/MapControl/Shared/OrthographicProjection.cs b/MapControl/Shared/OrthographicProjection.cs
index 67b7a8a3..cbd7e487 100644
--- a/MapControl/Shared/OrthographicProjection.cs
+++ b/MapControl/Shared/OrthographicProjection.cs
@@ -11,7 +11,7 @@ namespace MapControl
/// Spherical Orthographic Projection - AUTO2:42003.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.148-150.
///
- public class OrthographicProjection : AzimuthalProjection
+ public class OrthographicProjection : MapProjection
{
public const string DefaultCrsId = "AUTO2:42003";
@@ -22,9 +22,12 @@ namespace MapControl
public OrthographicProjection(string crsId)
{
+ Type = MapProjectionType.Azimuthal;
CrsId = crsId;
}
+ public double EarthRadius { get; set; } = Wgs84MeanRadius;
+
public override Point? LocationToMap(double latitude, double longitude)
{
if (Center.Equals(latitude, longitude))
diff --git a/MapControl/Shared/StereographicProjection.cs b/MapControl/Shared/StereographicProjection.cs
index 074f3ae9..b573398a 100644
--- a/MapControl/Shared/StereographicProjection.cs
+++ b/MapControl/Shared/StereographicProjection.cs
@@ -11,7 +11,7 @@ namespace MapControl
/// Spherical Stereographic Projection - AUTO2:97002.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.157-160.
///
- public class StereographicProjection : AzimuthalProjection
+ public class StereographicProjection : MapProjection
{
public const string DefaultCrsId = "AUTO2:97002"; // GeoServer non-standard CRS identifier
@@ -22,9 +22,12 @@ namespace MapControl
public StereographicProjection(string crsId)
{
+ Type = MapProjectionType.Azimuthal;
CrsId = crsId;
}
+ public double EarthRadius { get; set; } = Wgs84MeanRadius;
+
public override Point? LocationToMap(double latitude, double longitude)
{
if (Center.Equals(latitude, longitude))