Class Envelope
Defines a rectangular region of the 2D coordinate plane.
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
[Serializable]
public class Envelope : IComparable<Envelope>, IIntersectable<Envelope>, IExpandable<Envelope>
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
| Improve this Doc View SourceEnvelope()
Creates a null Envelope
.
Declaration
public Envelope()
Envelope(Coordinate)
Creates an Envelope
for a region defined by a single Coordinate.
Declaration
public Envelope(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | The Coordinate. |
Envelope(Coordinate, Coordinate)
Creates an Envelope
for a region defined by two Coordinates.
Declaration
public Envelope(Coordinate p1, Coordinate p2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p1 | The first Coordinate. |
Coordinate | p2 | The second Coordinate. |
Envelope(CoordinateSequence)
Creates an Envelope
for a region defined by a CoordinateSequence
s.
Declaration
public Envelope(CoordinateSequence sequence)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | sequence | The |
Envelope(Envelope)
Create an Envelope
from an existing Envelope.
Declaration
public Envelope(Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Envelope | env | The Envelope to initialize from. |
Envelope(IEnumerable<Coordinate>)
Creates an Envelope
for a region defined by an enumeration of Coordinate
s.
Declaration
public Envelope(IEnumerable<Coordinate> pts)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Coordinate> | pts | The |
Envelope(Double, Double, Double, Double)
Creates an Envelope
for a region defined by maximum and minimum values.
Declaration
public Envelope(double x1, double x2, double y1, double y2)
Parameters
Type | Name | Description |
---|---|---|
Double | x1 | The first x-value. |
Double | x2 | The second x-value. |
Double | y1 | The first y-value. |
Double | y2 | The second y-value. |
Properties
| Improve this Doc View SourceArea
Gets the area of this envelope.
Declaration
public double Area { get; }
Property Value
Type | Description |
---|---|
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).
Declaration
public Coordinate Centre { get; }
Property Value
Type | Description |
---|---|
Coordinate | The centre coordinate of this envelope,
or |
Diameter
Gets the length of the diameter (diagonal) of the envelope.
Declaration
public double Diameter { get; }
Property Value
Type | Description |
---|---|
Double | The diameter length |
Height
Returns the difference between the maximum and minimum y values.
Declaration
public double Height { get; }
Property Value
Type | Description |
---|---|
Double | max y - min y, or 0 if this is a null |
IsNull
Returns true
if this Envelope
is a "null" envelope.
Declaration
public bool IsNull { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
MaxExtent
Gets the maximum extent of this envelope across both dimensions.
Declaration
public double MaxExtent { get; }
Property Value
Type | Description |
---|---|
Double |
MaxX
Returns the Envelope
s maximum x-value. min x > max x
indicates that this is a null Envelope
.
Declaration
public double MaxX { get; }
Property Value
Type | Description |
---|---|
Double | The maximum x-coordinate. |
MaxY
Returns the Envelope
s maximum y-value. min y > max y
indicates that this is a null Envelope
.
Declaration
public double MaxY { get; }
Property Value
Type | Description |
---|---|
Double | The maximum y-coordinate. |
MinExtent
Gets the minimum extent of this envelope across both dimensions.
Declaration
public double MinExtent { get; }
Property Value
Type | Description |
---|---|
Double |
MinX
Returns the Envelope
s minimum x-value. min x > max x
indicates that this is a null Envelope
.
Declaration
public double MinX { get; }
Property Value
Type | Description |
---|---|
Double | The minimum x-coordinate. |
MinY
Returns the Envelope
s minimum y-value. min y > max y
indicates that this is a null Envelope
.
Declaration
public double MinY { get; }
Property Value
Type | Description |
---|---|
Double | The minimum y-coordinate. |
Width
Returns the difference between the maximum and minimum x values.
Declaration
public double Width { get; }
Property Value
Type | Description |
---|---|
Double | max x - min x, or 0 if this is a null |
Methods
| Improve this Doc View SourceCompareTo(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.
Declaration
public int CompareTo(Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Envelope | env | An envelope |
Returns
Type | Description |
---|---|
Int32 |
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.
Declaration
public int CompareTo(object o)
Parameters
Type | Name | Description |
---|---|---|
Object | o | An envelope |
Returns
Type | Description |
---|---|
Int32 |
Contains(Coordinate)
Tests if the given point lies in or on the envelope.
Declaration
public bool Contains(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | the point which this |
Returns
Type | Description |
---|---|
Boolean |
|
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).
Declaration
public bool Contains(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other |
Returns
Type | Description |
---|---|
Boolean | true if |
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.
Declaration
public bool Contains(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
Double | x | the x-coordinate of the point which this |
Double | y | the y-coordinate of the point which this |
Returns
Type | Description |
---|---|
Boolean |
|
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.
Declaration
public Envelope Copy()
Returns
Type | Description |
---|---|
Envelope |
Covers(Coordinate)
Tests if the given point lies in or on the envelope.
Declaration
public bool Covers(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | the point which this |
Returns
Type | Description |
---|---|
Boolean |
|
Covers(Envelope)
Tests if the Envelope other
lies wholely inside this Envelope
(inclusive of the boundary).
Declaration
public bool Covers(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other | the |
Returns
Type | Description |
---|---|
Boolean | true if this |
Covers(Double, Double)
Tests if the given point lies in or on the envelope.
Declaration
public bool Covers(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
Double | x | the x-coordinate of the point which this |
Double | y | the y-coordinate of the point which this |
Returns
Type | Description |
---|---|
Boolean |
|
Disjoint(Envelope)
Tests if the region defined by other
is disjoint from the region of this Envelope
.
Declaration
public bool Disjoint(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other | The |
Returns
Type | Description |
---|---|
Boolean |
|
See Also
| Improve this Doc View SourceDistance(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.
Declaration
public double Distance(Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Envelope | env |
Returns
Type | Description |
---|---|
Double | The distance between this and another |
Equals(Envelope)
Declaration
public bool Equals(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
Object | o |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceExpandBy(Double)
Expands this envelope by a given distance in all directions. Both positive and negative distances are supported.
Declaration
public void ExpandBy(double distance)
Parameters
Type | Name | Description |
---|---|---|
Double | distance | The 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.
Declaration
public void ExpandBy(double deltaX, double deltaY)
Parameters
Type | Name | Description |
---|---|---|
Double | deltaX | The distance to expand the envelope along the the X axis. |
Double | deltaY | The distance to expand the envelope along the the Y axis. |
ExpandedBy(Envelope)
Enlarges this Envelope
so that it contains
the other
Envelope.
Has no effect if other
is wholly on or
within the envelope.
Declaration
public Envelope ExpandedBy(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other | the |
Returns
Type | Description |
---|---|
Envelope |
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.
Declaration
public void ExpandToInclude(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | The 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.
Declaration
public void ExpandToInclude(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other | the |
ExpandToInclude(Double, Double)
Enlarges this Envelope
so that it contains
the given Coordinate.
Declaration
public void ExpandToInclude(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The value to lower the minimum x to or to raise the maximum x to. |
Double | y | The 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.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceInit()
Initialize to a null Envelope
.
Declaration
public void Init()
Init(Coordinate)
Initialize an Envelope
for a region defined by a single Coordinate.
Declaration
public void Init(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | The Coordinate. |
Init(Coordinate, Coordinate)
Initialize an Envelope
for a region defined by two Coordinates.
Declaration
public void Init(Coordinate p1, Coordinate p2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p1 | The first Coordinate. |
Coordinate | p2 | The second Coordinate. |
Init(Envelope)
Initialize an Envelope
from an existing Envelope.
Declaration
public void Init(Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Envelope | env | The Envelope to initialize from. |
Init(Double, Double, Double, Double)
Initialize an Envelope
for a region defined by maximum and minimum values.
Declaration
public void Init(double x1, double x2, double y1, double y2)
Parameters
Type | Name | Description |
---|---|---|
Double | x1 | The first x-value. |
Double | x2 | The second x-value. |
Double | y1 | The first y-value. |
Double | y2 | The second y-value. |
Intersection(Envelope)
Computes the intersection of two Envelopes.
Declaration
public Envelope Intersection(Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Envelope | env | The envelope to intersect with |
Returns
Type | Description |
---|---|
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
.
Declaration
public bool Intersects(Coordinate p)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p | the |
Returns
Type | Description |
---|---|
Boolean |
|
Intersects(Coordinate, Coordinate)
Tests if the extent defined by two extremal points
intersects the extent of this Envelope
.
Declaration
public bool Intersects(Coordinate a, Coordinate b)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | a | A point |
Coordinate | b | Another point |
Returns
Type | Description |
---|---|
Boolean |
|
Intersects(Coordinate, Coordinate, Coordinate)
Test the point q to see whether it intersects the Envelope defined by p1-p2.
Declaration
public static bool Intersects(Coordinate p1, Coordinate p2, Coordinate q)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p1 | One extremal point of the envelope. |
Coordinate | p2 | Another extremal point of the envelope. |
Coordinate | q | Point to test for intersection. |
Returns
Type | Description |
---|---|
Boolean |
|
Intersects(Coordinate, Coordinate, Coordinate, Coordinate)
Tests whether the envelope defined by p1-p2 and the envelope defined by q1-q2 intersect.
Declaration
public static bool Intersects(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p1 | One extremal point of the envelope Point. |
Coordinate | p2 | Another extremal point of the envelope Point. |
Coordinate | q1 | One extremal point of the envelope Q. |
Coordinate | q2 | Another extremal point of the envelope Q. |
Returns
Type | Description |
---|---|
Boolean |
|
Intersects(Envelope)
Check if the region defined by other
intersects the region of this Envelope
.
Declaration
public bool Intersects(Envelope other)
Parameters
Type | Name | Description |
---|---|---|
Envelope | other | The |
Returns
Type | Description |
---|---|
Boolean |
|
Intersects(Double, Double)
Check if the point (x, y)
overlaps (lies inside) the region of this Envelope
.
Declaration
public bool Intersects(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
Double | x | the x-ordinate of the point. |
Double | y | the y-ordinate of the point. |
Returns
Type | Description |
---|---|
Boolean |
|
Parse(String)
Method to parse an envelope from its ToString() value
Declaration
public static Envelope Parse(string envelope)
Parameters
Type | Name | Description |
---|---|---|
String | envelope | The envelope string |
Returns
Type | Description |
---|---|
Envelope | The envelope |
SetToNull()
Makes this Envelope
a "null" envelope..
Declaration
public void SetToNull()
ToString()
Function to get a textual representation of this envelope
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A textual representation of this envelope |
Overrides
| Improve this Doc View SourceTranslate(Double, Double)
Translates this envelope by given amounts in the X and Y direction.
Declaration
public void Translate(double transX, double transY)
Parameters
Type | Name | Description |
---|---|---|
Double | transX | The amount to translate along the X axis. |
Double | transY | The amount to translate along the Y axis. |