Class Envelope
- Namespace
- NetTopologySuite.Geometries
- Assembly
- NetTopologySuite.dll
Defines a rectangular region of the 2D coordinate plane.
public class Envelope : IComparable<Envelope>, IIntersectable<Envelope>, IExpandable<Envelope>
- Inheritance
-
Envelope
- Implements
- Inherited Members
Remarks
It is often used to represent the bounding box of a Geometry,
e.g. the minimum and maximum x and y values of the Coordinates.
Note that Envelopes support infinite or half-infinite regions, by using the values of
Double.PositiveInfinity and Double.NegativeInfinity.
When Envelope objects are created or initialized,
the supplied extent values are automatically sorted into the correct order.
Constructors
Envelope()
Creates a null Envelope.
public Envelope()
Envelope(Coordinate)
Creates an Envelope for a region defined by a single Coordinate.
public Envelope(Coordinate p)
Parameters
pCoordinateThe Coordinate.
Envelope(Coordinate, Coordinate)
Creates an Envelope for a region defined by two Coordinates.
public Envelope(Coordinate p1, Coordinate p2)
Parameters
p1CoordinateThe first Coordinate.
p2CoordinateThe second Coordinate.
Envelope(CoordinateSequence)
Creates an Envelope for a region defined by a CoordinateSequences.
public Envelope(CoordinateSequence sequence)
Parameters
sequenceCoordinateSequenceThe
CoordinateSequence.
Envelope(Envelope)
Create an Envelope from an existing Envelope.
public Envelope(Envelope env)
Parameters
envEnvelopeThe Envelope to initialize from.
Envelope(IEnumerable<Coordinate>)
Creates an Envelope for a region defined by an enumeration of Coordinates.
public Envelope(IEnumerable<Coordinate> pts)
Parameters
ptsIEnumerable<Coordinate>The
Coordinates.
Envelope(double, double, double, double)
Creates an Envelope for a region defined by maximum and minimum values.
public Envelope(double x1, double x2, double y1, double y2)
Parameters
x1doubleThe first x-value.
x2doubleThe second x-value.
y1doubleThe first y-value.
y2doubleThe second y-value.
Properties
Area
Gets the area of this envelope.
public double Area { get; }
Property Value
- double
The area of the envelope, or 0.0 if envelope is null
Centre
Computes the coordinate of the centre of this envelope (as long as it is non-null).
public Coordinate Centre { get; }
Property Value
- Coordinate
The centre coordinate of this envelope, or
nullif the envelope is null.
Diameter
Gets the length of the diameter (diagonal) of the envelope.
public double Diameter { get; }
Property Value
- double
The diameter length
Height
Returns the difference between the maximum and minimum y values.
public double Height { get; }
Property Value
- double
max y - min y, or 0 if this is a null
Envelope.
IsNull
Returns true if this Envelope is a "null" envelope.
public bool IsNull { get; }
Property Value
- bool
trueif thisEnvelopeis uninitialized or is the envelope of the empty point.
MaxExtent
Gets the maximum extent of this envelope across both dimensions.
public double MaxExtent { get; }
Property Value
MaxX
Returns the Envelopes maximum x-value. min x > max x
indicates that this is a null Envelope.
public double MaxX { get; }
Property Value
- double
The maximum x-coordinate.
MaxY
Returns the Envelopes maximum y-value. min y > max y
indicates that this is a null Envelope.
public double MaxY { get; }
Property Value
- double
The maximum y-coordinate.
MinExtent
Gets the minimum extent of this envelope across both dimensions.
public double MinExtent { get; }
Property Value
MinX
Returns the Envelopes minimum x-value. min x > max x
indicates that this is a null Envelope.
public double MinX { get; }
Property Value
- double
The minimum x-coordinate.
MinY
Returns the Envelopes minimum y-value. min y > max y
indicates that this is a null Envelope.
public double MinY { get; }
Property Value
- double
The minimum y-coordinate.
Width
Returns the difference between the maximum and minimum x values.
public double Width { get; }
Property Value
- double
max x - min x, or 0 if this is a null
Envelope.
Methods
CompareTo(Envelope)
Compares two envelopes using lexicographic ordering. The ordering comparison is based on the usual numerical comparison between the sequence of ordinates. Null envelopes are less than all non-null envelopes.
public int CompareTo(Envelope env)
Parameters
envEnvelopeAn envelope
Returns
CompareTo(object)
Compares two envelopes using lexicographic ordering. The ordering comparison is based on the usual numerical comparison between the sequence of ordinates. Null envelopes are less than all non-null envelopes.
public int CompareTo(object o)
Parameters
oobjectAn envelope
Returns
Contains(Coordinate)
Tests if the given point lies in or on the envelope.
public bool Contains(Coordinate p)
Parameters
pCoordinatethe point which this
Envelopeis being checked for containing
Returns
- bool
trueif the point lies in the interior or on the boundary of thisEnvelope.
Remarks
Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
Contains(Envelope)
Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary).
public bool Contains(Envelope other)
Parameters
otherEnvelope
Returns
- bool
true if
otheris contained in thisEnvelope
Remarks
Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
Contains(double, double)
Tests if the given point lies in or on the envelope.
public bool Contains(double x, double y)
Parameters
xdoublethe x-coordinate of the point which this
Envelopeis being checked for containingydoublethe y-coordinate of the point which this
Envelopeis being checked for containing
Returns
- bool
trueif(x, y)lies in the interior or on the boundary of thisEnvelope.
Remarks
Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
Copy()
Creates a deep copy of the current envelope.
public Envelope Copy()
Returns
Covers(Coordinate)
Tests if the given point lies in or on the envelope.
public bool Covers(Coordinate p)
Parameters
pCoordinatethe point which this
Envelopeis being checked for containing
Returns
- bool
trueif the point lies in the interior or on the boundary of thisEnvelope.
Covers(Envelope)
Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary).
public bool Covers(Envelope other)
Parameters
otherEnvelopethe
Envelopeto check
Returns
- bool
true if this
Envelopecovers theother
Covers(double, double)
Tests if the given point lies in or on the envelope.
public bool Covers(double x, double y)
Parameters
xdoublethe x-coordinate of the point which this
Envelopeis being checked for containingydoublethe y-coordinate of the point which this
Envelopeis being checked for containing
Returns
- bool
trueif(x, y)lies in the interior or on the boundary of thisEnvelope.
Disjoint(Envelope)
Tests if the region defined by other
is disjoint from the region of this Envelope.
public bool Disjoint(Envelope other)
Parameters
otherEnvelopeThe
Envelopebeing checked for disjointness
Returns
- bool
trueif theEnvelopes are disjoint
- See Also
Distance(Envelope)
Computes the distance between this and another
Envelope.
The distance between overlapping Envelopes is 0. Otherwise, the
distance is the Euclidean distance between the closest points.
public double Distance(Envelope env)
Parameters
envEnvelope
Returns
- double
The distance between this and another
Envelope.
Equals(Envelope)
public bool Equals(Envelope other)
Parameters
otherEnvelope
Returns
Equals(object)
public override bool Equals(object o)
Parameters
oobject
Returns
ExpandBy(double)
Expands this envelope by a given distance in all directions. Both positive and negative distances are supported.
public void ExpandBy(double distance)
Parameters
distancedoubleThe distance to expand the envelope.
ExpandBy(double, double)
Expands this envelope by a given distance in all directions. Both positive and negative distances are supported.
public void ExpandBy(double deltaX, double deltaY)
Parameters
deltaXdoubleThe distance to expand the envelope along the the X axis.
deltaYdoubleThe distance to expand the envelope along the the Y axis.
ExpandToInclude(Coordinate)
Enlarges this Envelope so that it contains
the given Coordinate.
Has no effect if the point is already on or within the envelope.
public void ExpandToInclude(Coordinate p)
Parameters
pCoordinateThe Coordinate.
ExpandToInclude(Envelope)
Enlarges this Envelope so that it contains
the other Envelope.
Has no effect if other is wholly on or
within the envelope.
public void ExpandToInclude(Envelope other)
Parameters
otherEnvelopethe
Envelopeto expand to include.
ExpandToInclude(double, double)
Enlarges this Envelope so that it contains
the given Coordinate.
public void ExpandToInclude(double x, double y)
Parameters
xdoubleThe value to lower the minimum x to or to raise the maximum x to.
ydoubleThe value to lower the minimum y to or to raise the maximum y to.
Remarks
Has no effect if the point is already on or within the envelope.
ExpandedBy(Envelope)
Enlarges this Envelope so that it contains
the other Envelope.
Has no effect if other is wholly on or
within the envelope.
public Envelope ExpandedBy(Envelope other)
Parameters
otherEnvelopethe
Envelopeto expand to include.
Returns
GetHashCode()
public override int GetHashCode()
Returns
Init()
Initialize to a null Envelope.
public void Init()
Init(Coordinate)
Initialize an Envelope for a region defined by a single Coordinate.
public void Init(Coordinate p)
Parameters
pCoordinateThe Coordinate.
Init(Coordinate, Coordinate)
Initialize an Envelope for a region defined by two Coordinates.
public void Init(Coordinate p1, Coordinate p2)
Parameters
p1CoordinateThe first Coordinate.
p2CoordinateThe second Coordinate.
Init(Envelope)
Initialize an Envelope from an existing Envelope.
public void Init(Envelope env)
Parameters
envEnvelopeThe Envelope to initialize from.
Init(double, double, double, double)
Initialize an Envelope for a region defined by maximum and minimum values.
public void Init(double x1, double x2, double y1, double y2)
Parameters
x1doubleThe first x-value.
x2doubleThe second x-value.
y1doubleThe first y-value.
y2doubleThe second y-value.
Intersection(Envelope)
Computes the intersection of two Envelopes.
public Envelope Intersection(Envelope env)
Parameters
envEnvelopeThe envelope to intersect with
Returns
- Envelope
A new Envelope representing the intersection of the envelopes (this will be the null envelope if either argument is null, or they do not intersect
Intersects(Coordinate)
Check if the point p overlaps (lies inside) the region of this Envelope.
public bool Intersects(Coordinate p)
Parameters
pCoordinatethe
Coordinateto be tested.
Returns
- bool
trueif the point overlaps thisEnvelope.
Intersects(Coordinate, Coordinate)
Tests if the extent defined by two extremal points
intersects the extent of this Envelope.
public bool Intersects(Coordinate a, Coordinate b)
Parameters
aCoordinateA point
bCoordinateAnother point
Returns
- bool
trueif the extents intersect
Intersects(Coordinate, Coordinate, Coordinate)
Test the point q to see whether it intersects the Envelope defined by p1-p2.
public static bool Intersects(Coordinate p1, Coordinate p2, Coordinate q)
Parameters
p1CoordinateOne extremal point of the envelope.
p2CoordinateAnother extremal point of the envelope.
qCoordinatePoint to test for intersection.
Returns
- bool
trueif q intersects the envelope p1-p2.
Intersects(Coordinate, Coordinate, Coordinate, Coordinate)
Tests whether the envelope defined by p1-p2 and the envelope defined by q1-q2 intersect.
public static bool Intersects(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
Parameters
p1CoordinateOne extremal point of the envelope Point.
p2CoordinateAnother extremal point of the envelope Point.
q1CoordinateOne extremal point of the envelope Q.
q2CoordinateAnother extremal point of the envelope Q.
Returns
- bool
trueif Q intersects Point
Intersects(Envelope)
Check if the region defined by other
intersects the region of this Envelope.
public bool Intersects(Envelope other)
Parameters
otherEnvelopeThe
Envelopewhich thisEnvelopeis being checked for intersecting.
Returns
- bool
trueif theEnvelopes intersect.
Intersects(double, double)
Check if the point (x, y) overlaps (lies inside) the region of this Envelope.
public bool Intersects(double x, double y)
Parameters
Returns
- bool
trueif the point overlaps thisEnvelope.
Parse(string)
Method to parse an envelope from its ToString() value
public static Envelope Parse(string envelope)
Parameters
envelopestringThe envelope string
Returns
- Envelope
The envelope
SetToNull()
Makes this Envelope a "null" envelope..
public void SetToNull()
ToString()
Function to get a textual representation of this envelope
public override string ToString()
Returns
- string
A textual representation of this envelope
Translate(double, double)
Translates this envelope by given amounts in the X and Y direction.
public void Translate(double transX, double transY)