mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Add BoundingBox.HasValidBounds
This commit is contained in:
parent
45cda387e4
commit
849a4e206c
|
|
@ -58,9 +58,9 @@ namespace MapControl
|
||||||
public virtual double Height => North - South;
|
public virtual double Height => North - South;
|
||||||
|
|
||||||
public virtual Location Center =>
|
public virtual Location Center =>
|
||||||
double.IsNaN(South) || double.IsNaN(North) || double.IsNaN(West) || double.IsNaN(East)
|
HasValidBounds ? new Location((South + North) / 2d, (West + East) / 2d) : null;
|
||||||
? null
|
|
||||||
: new Location((South + North) / 2d, (West + East) / 2d);
|
public virtual bool HasValidBounds => South < North && West < East;
|
||||||
|
|
||||||
public static BoundingBox Parse(string boundingBox)
|
public static BoundingBox Parse(string boundingBox)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ namespace MapControl
|
||||||
height = Math.Max(h, 0d);
|
height = Math.Max(h, 0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HasValidBounds => false;
|
||||||
public override Location Center => center;
|
public override Location Center => center;
|
||||||
public override double Width => width;
|
public override double Width => width;
|
||||||
public override double Height => height;
|
public override double Height => height;
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
MapRect mapRect = null;
|
MapRect mapRect = null;
|
||||||
|
|
||||||
if (!double.IsNaN(boundingBox.South) && !double.IsNaN(boundingBox.West) &&
|
if (boundingBox.HasValidBounds)
|
||||||
!double.IsNaN(boundingBox.North) && !double.IsNaN(boundingBox.East))
|
|
||||||
{
|
{
|
||||||
var p1 = LocationToMap(new Location(boundingBox.South, boundingBox.West));
|
var p1 = LocationToMap(new Location(boundingBox.South, boundingBox.West));
|
||||||
var p2 = LocationToMap(new Location(boundingBox.North, boundingBox.East));
|
var p2 = LocationToMap(new Location(boundingBox.North, boundingBox.East));
|
||||||
|
|
@ -87,6 +86,8 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else if (boundingBox.Center != null)
|
else if (boundingBox.Center != null)
|
||||||
{
|
{
|
||||||
|
// boundingBox is a CenteredBoundingBox
|
||||||
|
//
|
||||||
var center = LocationToMap(boundingBox.Center);
|
var center = LocationToMap(boundingBox.Center);
|
||||||
|
|
||||||
if (center.HasValue)
|
if (center.HasValue)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue