Click or drag to resize

MapRectangle Class

For geographical use cases, the type Rect is insufficient for different reasons. Especially the convention, the top value contains a lower coordinate value compared to the bottom value, often leads to implementing issues. Therefore, this class provides the compass directions as bounding properties directly.

Another aspect is the paradigm of a center based reference point (compared to the edge-based format of type Rect).

Inheritance Hierarchy

Namespace:  Ptv.XServer.Controls.Map
Assembly:  Ptv.XServer.Controls.Map (in Ptv.XServer.Controls.Map.dll) Version: 1.7.10.0
Syntax
public class MapRectangle

The MapRectangle type exposes the following members.

Constructors
  NameDescription
Public methodMapRectangle
Initializes a new instance of the MapRectangle class, by setting all boundaries to an empty state. This approach is helpful, when Point objects are inserted by the Union methods.
Public methodMapRectangle(IEnumerablePoint)
Initializes a new instance of the MapRectangle class. The resulting object represents the smallest rectangle containing all points provided by the point enumeration, i.e. the new object represents the minimal bounding rectangle of the point collection. The ordering of the points inside the enumeration has no influence on the result.
Public methodMapRectangle(Point)
Initializes a new instance of the MapRectangle class, by setting the West and East boundaries to point.X, as well as the North and South boundaries to point.Y. Therefore, the Width and Height properties have a value of 0.
Public methodMapRectangle(Rect)
Initializes a new instance of the MapRectangle class, by transforming the location and size of parameter rect into boundaries of the new instance.
Public methodMapRectangle(MapRectangle)
Initializes a new instance of the MapRectangle class, by copying the boundaries of parameter originalRectangle.
Public methodMapRectangle(Point, Point)
Initializes a new instance of the MapRectangle class. The resulting object represents the smallest rectangle containing both points, i.e. both points define the boundaries directly. The ordering of the parameters has no influence on the result.
Public methodMapRectangle(Point, Size)
Initializes a new instance of the MapRectangle class. The resulting object is defined by the center and sizeparameter.
Public methodMapRectangle(Double, Double, Double, Double)
Initializes a new instance of the MapRectangle class, by setting the boundaries directly. No checks are made for avoiding a lower east value compared to the west value. The same is true for the north/south pair.
Top
Properties
  NameDescription
Public propertyCenter
Gets or sets the center of the rectangle. If the rectangle is empty, the point (Double.NaN, Double.NaN) is returned. If the center is set to an empty rectangle, the value becomes the new center, the width and height of the rectangle are set to 0. If the rectangle was not empty, the center is changed, but the width and height remain unchanged.
Public propertyEast
Gets or sets the East boundary of the rectangle. The rectangle is empty, if the value is lower than the West boundary value. No checks are made to avoid a lower value compared to the West boundary.
Public propertyHeight
Gets or sets the height of the rectangle. If the height is set, the rectangle's center remains the same.
Public propertyIsEmpty
Gets a value indicating whether the rectangle is empty. This is true, if the width or height value is lower 0.
Public propertyNorth
Gets or sets the North boundary of the rectangle. The rectangle is empty, if the value is lower than the South boundary value. No checks are made to avoid a higher value compared to the South boundary.
Public propertyNorthEast
Gets the NorthEast point of the rectangle.
Public propertyNorthWest
Gets the NorthWest point of the rectangle.
Public propertySouth
Gets or sets the South boundary of the rectangle. The rectangle is empty, if the value is higher than the North boundary value. No checks are made to avoid a higher value compared to the North boundary.
Public propertySouthEast
Gets the SouthEast point of the rectangle.
Public propertySouthWest
Gets the SouthWest point of the rectangle.
Public propertyWest
Gets or sets the West boundary of the rectangle. The rectangle is empty, if the value is higher than the East boundary value. No checks are made to avoid a higher value compared to the East boundary.
Public propertyWidth
Gets or sets the width of the rectangle. If the width is set, the rectangle's center remains the same.
Top
Methods
  NameDescription
Public methodContains(Point)
Checks whether the point parameter is within the rectangle, inclusive its edges.
Public methodContains(MapRectangle)
Checks whether the rect parameter is located completely within the rectangle, inclusive its edges.
Public methodEquals(Object)
Compares this rectangle with the passed in object.
(Overrides ObjectEquals(Object).)
Public methodEquals(MapRectangle)
Compares this Rect with the passed in object.
Public methodStatic memberEquals(MapRectangle, MapRectangle)
Compares two MapRectangle instances for object equality.
Public methodGetHashCode
Returns the HashCode for this object.
(Overrides ObjectGetHashCode.)
Public methodInflate(Double)
Inflates the object horizontally and vertically by specifying one single factor, applied to both dimensions. The width and height of the rectangle is multiplied by this factor.
Public methodInflate(Double, Double)
Inflates the object horizontally and vertically by specifying two different factors for each dimension. The width and height of the rectangle is multiplied by these factors.
Public methodInflateHorizontally
Inflates the object horizontally by specifying a factor. The width of the rectangle is multiplied by this factor.
Public methodInflateVertically
Inflates the object vertically by specifying a factor. The height of the rectangle is multiplied by this factor.
Public methodIntersect
Updates this rectangle to be the intersection of this and parameter rect. If either this or rect are empty, the result is empty as well.
Public methodIntersectsWith
Checks whether the parameter rect intersects with this rectangle. If one edge is coincident, it is considered an intersection.
Public methodTranslate
Translates the rectangle horizontally and vertically, if it is not empty. All boundaries are changed.
Public methodTranslateHorizontally
Translates the rectangle horizontally, if it is not empty. The properties West and East are changed.
Public methodTranslateVertically
Translates the rectangle vertically, if it is not empty. The properties South and North are changed.
Public methodUnion(Point)
Updates this rectangle to be the union of this and parameter point. I.e. the rectangle boundaries and the point itself are included in the new boundaries. If point has Double.IsNaN coordinates, the boundaries remain unchanged. If this is empty, the boundaries are adapted to the point's coordinates (width and height will be 0).
Public methodUnion(MapRectangle)
Updates this rectangle to be the union of this and parameter rect. I.e. the rectangle boundaries of this and rect are included in the new boundaries. If rect is empty, the boundaries remain unchanged. If this is empty, the new boundaries are adapted to the rect's boundaries.
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Translates the rectangle parameter rect horizontally and vertically, if it is not empty. All its boundaries are changed.
Public operatorStatic memberBitwiseAnd
Calculates the result of the intersection of rect1 and rect2. If one of them is empty, the result is empty as well.
Public operatorStatic memberBitwiseOr(MapRectangle, MapRectangle)
Unifies both rectangles rect1 and rect2.
Public operatorStatic memberBitwiseOr(MapRectangle, Point)
Unifies the rectangle rect and point. If point has Double.IsNaN coordinates, the resulting rectangle has the same values as rect. If rect is empty, the boundaries of the resulting rectangle are adapted to the point's coordinates (width and height will be 0).
Public operatorStatic memberEquality
Compares two rectangle instances for exact equality.
Public operatorStatic memberInequality
Compares two rectangle instances for exact inequality.
Public operatorStatic memberMultiply
Inflates the object horizontally and vertically by specifying two different factors for each dimension. The width and height of the rectangle is multiplied by these factors.
Top
Extension Methods
  NameDescription
Public Extension MethodToJson
Converts an object to a JSON string representation.
(Defined by JSONWriter.)
Top
See Also