Class BoundingBox
Bounding box type with double precision
Inheritance
Implements
Inherited Members
Namespace: Mapsui.Geometries
Assembly: Mapsui.Geometries.dll
Syntax
public class BoundingBox : IEquatable<BoundingBox>
Remarks
The Bounding Box represents a box whose sides are parallel to the two axes of the coordinate system.
Constructors
| Improve this Doc View SourceBoundingBox()
Declaration
public BoundingBox()
BoundingBox(BoundingBox)
Declaration
public BoundingBox(BoundingBox boundingBox)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | boundingBox |
BoundingBox(Point, Point)
Initializes a bounding box
Declaration
public BoundingBox(Point minPoint, Point maxPoint)
Parameters
Type | Name | Description |
---|---|---|
Point | minPoint | Lower left corner |
Point | maxPoint | Upper right corner |
BoundingBox(IEnumerable<BoundingBox>)
Initializes a new Bounding Box based on the bounds from a set of bounding boxes
Declaration
public BoundingBox(IEnumerable<BoundingBox> boundingBoxes)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<BoundingBox> | boundingBoxes |
BoundingBox(IEnumerable<Geometry>)
Initializes a new Bounding Box based on the bounds from a set of geometries
Declaration
public BoundingBox(IEnumerable<Geometry> objects)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Geometry> | objects | list of objects |
BoundingBox(Double, Double, Double, Double)
Initializes a bounding box
Declaration
public BoundingBox(double minX, double minY, double maxX, double maxY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | minX | left |
System.Double | minY | bottom |
System.Double | maxX | right |
System.Double | maxY | top |
Remarks
In case min values are larger than max values, the parameters will be swapped to ensure correct min/max boundary
Properties
| Improve this Doc View SourceBottom
Gets the bottom boundary
Declaration
public double Bottom { get; }
Property Value
Type | Description |
---|---|
System.Double |
BottomLeft
Declaration
public Point BottomLeft { get; }
Property Value
Type | Description |
---|---|
Point |
BottomRight
Declaration
public Point BottomRight { get; }
Property Value
Type | Description |
---|---|
Point |
Centroid
Returns the center of the bounding box
Declaration
public Point Centroid { get; }
Property Value
Type | Description |
---|---|
Point |
Height
Returns the height of the bounding box
Declaration
public double Height { get; }
Property Value
Type | Description |
---|---|
System.Double | Height of boundingbox |
Left
Gets the left boundary
Declaration
public double Left { get; }
Property Value
Type | Description |
---|---|
System.Double |
LongestAxis
Intersection scalar (used for weighting in building the tree)
Declaration
public uint LongestAxis { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Max
Gets or sets the upper right corner.
Declaration
public Point Max { get; set; }
Property Value
Type | Description |
---|---|
Point |
MaxX
Declaration
public double MaxX { get; }
Property Value
Type | Description |
---|---|
System.Double |
MaxY
Declaration
public double MaxY { get; }
Property Value
Type | Description |
---|---|
System.Double |
Min
Gets or sets the lower left corner.
Declaration
public Point Min { get; set; }
Property Value
Type | Description |
---|---|
Point |
MinX
Declaration
public double MinX { get; }
Property Value
Type | Description |
---|---|
System.Double |
MinY
Declaration
public double MinY { get; }
Property Value
Type | Description |
---|---|
System.Double |
Right
Gets the right boundary
Declaration
public double Right { get; }
Property Value
Type | Description |
---|---|
System.Double |
Top
Gets the top boundary
Declaration
public double Top { get; }
Property Value
Type | Description |
---|---|
System.Double |
TopLeft
Declaration
public Point TopLeft { get; }
Property Value
Type | Description |
---|---|
Point |
TopRight
Declaration
public Point TopRight { get; }
Property Value
Type | Description |
---|---|
Point |
Width
Returns the width of the bounding box
Declaration
public double Width { get; }
Property Value
Type | Description |
---|---|
System.Double | Width of boundingbox |
Methods
| Improve this Doc View SourceCheckMinMax()
Checks whether min values are actually smaller than max values and in that case swaps them.
Declaration
public bool CheckMinMax()
Returns
Type | Description |
---|---|
System.Boolean | true if the bounding was changed |
Clone()
Creates a copy of the BoundingBox
Declaration
public BoundingBox Clone()
Returns
Type | Description |
---|---|
BoundingBox |
Contains(BoundingBox)
Returns true if this instance contains the BoundingBox
Declaration
public bool Contains(BoundingBox r)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | r | BoundingBox |
Returns
Type | Description |
---|---|
System.Boolean | True it contains |
Contains(Point)
Checks whether a point lies within the bounding box
Declaration
public bool Contains(Point p)
Parameters
Type | Name | Description |
---|---|---|
Point | p | Point |
Returns
Type | Description |
---|---|
System.Boolean | true if point is within |
Distance(BoundingBox)
Computes the minimum distance between this and another BoundingBox. The distance between overlapping bounding boxes is 0. Otherwise, the distance is the Euclidean distance between the closest points.
Declaration
public virtual double Distance(BoundingBox box)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | box | Box to calculate distance to |
Returns
Type | Description |
---|---|
System.Double | The distance between this and another BoundingBox. |
Distance(Point)
Computes the minimum distance between this BoundingBox and a Point
Declaration
public virtual double Distance(Point p)
Parameters
Type | Name | Description |
---|---|---|
Point | p | Point to calculate distance to. |
Returns
Type | Description |
---|---|
System.Double | Minimum distance. |
Equals(BoundingBox)
Checks whether the values of this instance is equal to the values of another instance.
Declaration
public bool Equals(BoundingBox other)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | other | BoundingBox to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | True if equal |
Equals(Object)
Indicates whether the current object is equal to another object of the same type.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetArea()
Returns the area of the BoundingBox
Declaration
public double GetArea()
Returns
Type | Description |
---|---|
System.Double | Area of box |
GetCentroid()
Declaration
[Obsolete("Use the Centroid field instead")]
public Point GetCentroid()
Returns
Type | Description |
---|---|
Point |
GetHashCode()
Returns a hash code for the specified object
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the specified object |
Overrides
GetIntersectingArea(BoundingBox)
Gets the intersecting area between two boundingboxes
Declaration
public double GetIntersectingArea(BoundingBox r)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | r | BoundingBox |
Returns
Type | Description |
---|---|
System.Double | Area |
Grow(Double)
Increases the size of the boundingbox by the givent amount in all directions
Declaration
public BoundingBox Grow(double amount)
Parameters
Type | Name | Description |
---|---|---|
System.Double | amount | Amount to grow in all directions |
Returns
Type | Description |
---|---|
BoundingBox |
Grow(Double, Double)
Increases the size of the boundingbox by the givent amount in horizontal and vertical directions
Declaration
public BoundingBox Grow(double amountInX, double amountInY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | amountInX | Amount to grow in horizontal direction |
System.Double | amountInY | Amount to grow in vertical direction |
Returns
Type | Description |
---|---|
BoundingBox |
Intersects(BoundingBox)
Determines whether the boundingbox intersects another boundingbox
Declaration
public bool Intersects(BoundingBox box)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | box |
Returns
Type | Description |
---|---|
System.Boolean |
Join(BoundingBox)
Computes the joined boundingbox of this instance and another boundingbox
Declaration
public BoundingBox Join(BoundingBox box)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | box | Boundingbox to join with |
Returns
Type | Description |
---|---|
BoundingBox | Boundingbox containing both boundingboxes |
Join(BoundingBox, BoundingBox)
Computes the joined boundingbox of two boundingboxes
Declaration
public static BoundingBox Join(BoundingBox box1, BoundingBox box2)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | box1 | |
BoundingBox | box2 |
Returns
Type | Description |
---|---|
BoundingBox |
Join(BoundingBox[])
Computes the joined BoundingBox of an array of boundingboxes.
Declaration
public static BoundingBox Join(BoundingBox[] boxes)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox[] | boxes | Boxes to join |
Returns
Type | Description |
---|---|
BoundingBox | Combined BoundingBox |
Offset(Point)
Moves/translates the BoundingBox along the the specified vector
Declaration
public void Offset(Point vector)
Parameters
Type | Name | Description |
---|---|---|
Point | vector | Offset vector |
Offset(Double, Double)
Declaration
public void Offset(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | |
System.Double | y |
Rotate(Double)
Calculates a new quad by rotating this bounding box about its center by the specified angle clockwise
Declaration
public Quad Rotate(double degrees)
Parameters
Type | Name | Description |
---|---|---|
System.Double | degrees | Angle about which to rotate (degrees) |
Returns
Type | Description |
---|---|
Quad | Returns the calculated quad |
ToString()
Returns a string representation of the boundingbox as LowerLeft + UpperRight formatted as "MinX,MinY MaxX,MaxY"
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | MinX,MinY MaxX,MaxY |
Overrides
Touches(BoundingBox)
Returns true if this instance touches the BoundingBox
Declaration
public bool Touches(BoundingBox r)
Parameters
Type | Name | Description |
---|---|---|
BoundingBox | r | BoundingBox |
Returns
Type | Description |
---|---|
System.Boolean | True it touches |
Touches(Point)
Returns true if this instance touches the Point
Declaration
public bool Touches(Point p)
Parameters
Type | Name | Description |
---|---|---|
Point | p | Geometry |
Returns
Type | Description |
---|---|
System.Boolean | True if touches |