Simplify BoundingBox

This commit is contained in:
ClemensFischer 2022-12-07 22:29:08 +01:00
parent 8bb2555533
commit 142e86da31
2 changed files with 11 additions and 10 deletions

View file

@ -57,19 +57,16 @@ namespace MapControl
public virtual double Width
{
get => East - West;
protected set { }
}
public virtual double Height
{
get => North - South;
protected set { }
}
public virtual Location Center
{
get => new Location((South + North) / 2d, (West + East) / 2d);
protected set { }
}
public static BoundingBox Parse(string boundingBox)

View file

@ -8,15 +8,19 @@ namespace MapControl
{
public class CenteredBoundingBox : BoundingBox
{
public CenteredBoundingBox(Location center, double width, double height)
private readonly Location center;
private readonly double width;
private readonly double height;
public CenteredBoundingBox(Location c, double w, double h)
{
Center = center;
Width = Math.Max(width, 0d);
Height = Math.Max(height, 0d);
center = c;
width = Math.Max(w, 0d);
height = Math.Max(h, 0d);
}
public override double Width { get; protected set; }
public override double Height { get; protected set; }
public override Location Center { get; protected set; }
public override Location Center => center;
public override double Width => width;
public override double Height => height;
}
}