mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-20 15:40:16 +01:00
Removed CenteredBoundingBox
This commit is contained in:
parent
7f67e6fe17
commit
2817ecda7d
|
|
@ -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.
|
||||
/// </summary>
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
#if WPF
|
||||
using System.Windows;
|
||||
#elif AVALONIA
|
||||
using Avalonia;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for spherical azimuthal map projections.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
/// </summary>
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Location instance from a string containing a comma-separated pair of floating point numbers.
|
||||
|
|
|
|||
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
/// </summary>
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
/// </summary>
|
||||
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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue