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 Coordinate
s.
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
p
CoordinateThe Coordinate.
Envelope(Coordinate, Coordinate)
Creates an Envelope
for a region defined by two Coordinates.
public Envelope(Coordinate p1, Coordinate p2)
Parameters
p1
CoordinateThe first Coordinate.
p2
CoordinateThe second Coordinate.
Envelope(CoordinateSequence)
Creates an Envelope
for a region defined by a CoordinateSequence
s.
public Envelope(CoordinateSequence sequence)
Parameters
sequence
CoordinateSequenceThe
CoordinateSequence
.
Envelope(Envelope)
Create an Envelope
from an existing Envelope.
public Envelope(Envelope env)
Parameters
env
EnvelopeThe Envelope to initialize from.
Envelope(IEnumerable<Coordinate>)
Creates an Envelope
for a region defined by an enumeration of Coordinate
s.
public Envelope(IEnumerable<Coordinate> pts)
Parameters
pts
IEnumerable<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
x1
doubleThe first x-value.
x2
doubleThe second x-value.
y1
doubleThe first y-value.
y2
doubleThe 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
null
if 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
true
if thisEnvelope
is 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 Envelope
s 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 Envelope
s 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 Envelope
s 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 Envelope
s 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
env
EnvelopeAn 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
o
objectAn envelope
Returns
Contains(Coordinate)
Tests if the given point lies in or on the envelope.
public bool Contains(Coordinate p)
Parameters
p
Coordinatethe point which this
Envelope
is being checked for containing
Returns
- bool
true
if 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
other
Envelope
Returns
- bool
true if
other
is 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
x
doublethe x-coordinate of the point which this
Envelope
is being checked for containingy
doublethe y-coordinate of the point which this
Envelope
is being checked for containing
Returns
- bool
true
if(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
p
Coordinatethe point which this
Envelope
is being checked for containing
Returns
- bool
true
if 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
other
Envelopethe
Envelope
to check
Returns
- bool
true if this
Envelope
covers theother
Covers(double, double)
Tests if the given point lies in or on the envelope.
public bool Covers(double x, double y)
Parameters
x
doublethe x-coordinate of the point which this
Envelope
is being checked for containingy
doublethe y-coordinate of the point which this
Envelope
is being checked for containing
Returns
- bool
true
if(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
other
EnvelopeThe
Envelope
being checked for disjointness
Returns
- bool
true
if theEnvelope
s 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
env
Envelope
Returns
- double
The distance between this and another
Envelope
.
Equals(Envelope)
public bool Equals(Envelope other)
Parameters
other
Envelope
Returns
Equals(object)
public override bool Equals(object o)
Parameters
o
object
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
distance
doubleThe 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
deltaX
doubleThe distance to expand the envelope along the the X axis.
deltaY
doubleThe 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
p
CoordinateThe 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
other
Envelopethe
Envelope
to expand to include.
ExpandToInclude(double, double)
Enlarges this Envelope
so that it contains
the given Coordinate.
public void ExpandToInclude(double x, double y)
Parameters
x
doubleThe value to lower the minimum x to or to raise the maximum x to.
y
doubleThe 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
other
Envelopethe
Envelope
to 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
p
CoordinateThe Coordinate.
Init(Coordinate, Coordinate)
Initialize an Envelope
for a region defined by two Coordinates.
public void Init(Coordinate p1, Coordinate p2)
Parameters
p1
CoordinateThe first Coordinate.
p2
CoordinateThe second Coordinate.
Init(Envelope)
Initialize an Envelope
from an existing Envelope.
public void Init(Envelope env)
Parameters
env
EnvelopeThe 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
x1
doubleThe first x-value.
x2
doubleThe second x-value.
y1
doubleThe first y-value.
y2
doubleThe second y-value.
Intersection(Envelope)
Computes the intersection of two Envelopes.
public Envelope Intersection(Envelope env)
Parameters
env
EnvelopeThe 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
p
Coordinatethe
Coordinate
to be tested.
Returns
- bool
true
if 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
a
CoordinateA point
b
CoordinateAnother point
Returns
- bool
true
if 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
p1
CoordinateOne extremal point of the envelope.
p2
CoordinateAnother extremal point of the envelope.
q
CoordinatePoint to test for intersection.
Returns
- bool
true
if 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
p1
CoordinateOne extremal point of the envelope Point.
p2
CoordinateAnother extremal point of the envelope Point.
q1
CoordinateOne extremal point of the envelope Q.
q2
CoordinateAnother extremal point of the envelope Q.
Returns
- bool
true
if Q intersects Point
Intersects(Envelope)
Check if the region defined by other
intersects the region of this Envelope
.
public bool Intersects(Envelope other)
Parameters
other
EnvelopeThe
Envelope
which thisEnvelope
is being checked for intersecting.
Returns
- bool
true
if theEnvelope
s 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
true
if the point overlaps thisEnvelope
.
Parse(string)
Method to parse an envelope from its ToString() value
public static Envelope Parse(string envelope)
Parameters
envelope
stringThe 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)