LatLonBox transformation

This commit is contained in:
ClemensFischer 2024-09-09 16:44:45 +02:00
parent f143bdb5e6
commit 8efcee2585
10 changed files with 145 additions and 145 deletions

View file

@ -21,13 +21,12 @@ namespace MapControl
{
}
public BoundingBox(double latitude1, double longitude1, double latitude2, double longitude2, double rotation = 0d)
public BoundingBox(double latitude1, double longitude1, double latitude2, double longitude2)
{
South = Math.Min(Math.Max(Math.Min(latitude1, latitude2), -90d), 90d);
North = Math.Min(Math.Max(Math.Max(latitude1, latitude2), -90d), 90d);
West = Math.Min(longitude1, longitude2);
East = Math.Max(longitude1, longitude2);
Rotation = rotation;
}
public BoundingBox(Location location1, Location location2)
@ -39,7 +38,6 @@ namespace MapControl
public double North { get; }
public double West { get; }
public double East { get; }
public double Rotation { get; }
public virtual double Width => East - West;
public virtual double Height => North - South;
@ -47,7 +45,7 @@ namespace MapControl
public virtual Location Center => new Location((South + North) / 2d, (West + East) / 2d);
/// <summary>
/// Creates a BoundingBox instance from a string containing a comma-separated sequence of four floating point numbers.
/// Creates a BoundingBox instance from a string containing a comma-separated sequence of four or five floating point numbers.
/// </summary>
public static BoundingBox Parse(string boundingBox)
{
@ -67,7 +65,9 @@ namespace MapControl
? double.Parse(values[4], NumberStyles.Float, CultureInfo.InvariantCulture)
: 0d;
return new BoundingBox(
// always return a LatLonBox, i.e. a BoundingBox with optional rotation, as used by GeoImage and GroundOverlay
//
return new LatLonBox(
double.Parse(values[0], NumberStyles.Float, CultureInfo.InvariantCulture),
double.Parse(values[1], NumberStyles.Float, CultureInfo.InvariantCulture),
double.Parse(values[2], NumberStyles.Float, CultureInfo.InvariantCulture),