Moved Bounds to seperate Class

This commit is contained in:
glax 2023-05-15 14:07:04 +02:00
parent a5f272dfb9
commit 7c5d87ca76
2 changed files with 33 additions and 29 deletions

33
RenderPath/Bounds.cs Normal file
View File

@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
using OSMDatastructure.Graph;
namespace RenderPath;
public class Bounds
{
[JsonInclude]public float minLat, maxLat, minLon, maxLon;
[JsonConstructor]
public Bounds(float minLat, float minLon, float maxLat, float maxLon)
{
this.minLon = minLon;
this.maxLat = maxLat;
this.maxLon = maxLon;
this.minLat = minLat;
}
public static Bounds FromCoords(float lat1, float lon1, float lat2, float lon2)
{
float minLat = lat1 < lat2 ? lat1 : lat2;
float minLon = lon1 < lon2 ? lon1 : lon2;
float maxLat = lat1 > lat2 ? lat1 : lat2;
float maxLon = lon1 > lon2 ? lon1 : lon2;
return new Bounds(minLat, minLon, maxLat, maxLon);
}
public static Bounds FromCoords(Coordinates c1, Coordinates c2)
{
return FromCoords(c1.latitude, c1.longitude, c2.latitude, c2.longitude);
}
}

View File

@ -18,35 +18,6 @@ public static class Renderer
private static readonly Color RoadPrioStart = Color.FromArgb(200, 100, 100, 100);
private static readonly Color RoadPrioEnd = Color.FromArgb(255, 255, 180, 0);
public class Bounds
{
[JsonInclude]public float minLat, maxLat, minLon, maxLon;
[JsonConstructor]
public Bounds(float minLat, float minLon, float maxLat, float maxLon)
{
this.minLon = minLon;
this.maxLat = maxLat;
this.maxLon = maxLon;
this.minLat = minLat;
}
public static Bounds FromCoords(float lat1, float lon1, float lat2, float lon2)
{
float minLat = lat1 < lat2 ? lat1 : lat2;
float minLon = lon1 < lon2 ? lon1 : lon2;
float maxLat = lat1 > lat2 ? lat1 : lat2;
float maxLon = lon1 > lon2 ? lon1 : lon2;
return new Bounds(minLat, minLon, maxLat, maxLon);
}
public static Bounds FromCoords(Coordinates c1, Coordinates c2)
{
return FromCoords(c1.latitude, c1.longitude, c2.latitude, c2.longitude);
}
}
[SuppressMessage("Interoperability", "CA1416:Plattformkompatibilität überprüfen")]
public static Image DrawPathfinder(Pathfinder pathfinder)
{