2025-03-10 15:47:33 +01:00
|
|
|
|
#if WPF
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using System.Windows;
|
2025-08-19 19:43:02 +02:00
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using Avalonia;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
#endif
|
2017-06-25 23:05:48 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Base class for azimuthal map projections.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class AzimuthalProjection : MapProjection
|
|
|
|
|
|
{
|
2022-03-05 18:40:57 +01:00
|
|
|
|
protected AzimuthalProjection()
|
|
|
|
|
|
{
|
|
|
|
|
|
Type = MapProjectionType.Azimuthal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-08 14:03:55 +02:00
|
|
|
|
public override Rect? BoundingBoxToMap(BoundingBox boundingBox)
|
2017-06-25 23:05:48 +02:00
|
|
|
|
{
|
2024-09-09 16:44:45 +02:00
|
|
|
|
Rect? rect = null;
|
2024-09-08 14:03:55 +02:00
|
|
|
|
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;
|
|
|
|
|
|
|
2024-09-09 16:44:45 +02:00
|
|
|
|
rect = new Rect(x, y, width, height);
|
2024-09-08 14:03:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-09 16:44:45 +02:00
|
|
|
|
return rect;
|
2024-09-08 14:03:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-09 16:44:45 +02:00
|
|
|
|
public override BoundingBox MapToBoundingBox(Rect rect)
|
2024-09-08 14:03:55 +02:00
|
|
|
|
{
|
|
|
|
|
|
BoundingBox boundingBox = null;
|
2024-09-09 16:44:45 +02:00
|
|
|
|
var rectCenter = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
|
2024-05-19 17:24:18 +02:00
|
|
|
|
var center = MapToLocation(rectCenter);
|
2022-12-02 16:50:10 +01:00
|
|
|
|
|
2024-09-08 14:03:55 +02:00
|
|
|
|
if (center != null)
|
|
|
|
|
|
{
|
2024-09-09 16:44:45 +02:00
|
|
|
|
boundingBox = new CenteredBoundingBox(center, rect.Width / Wgs84MeterPerDegree, rect.Height / Wgs84MeterPerDegree);
|
2024-09-08 14:03:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return boundingBox;
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|