Table of Contents

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

p Coordinate

The Coordinate.

Envelope(Coordinate, Coordinate)

Creates an Envelope for a region defined by two Coordinates.

public Envelope(Coordinate p1, Coordinate p2)

Parameters

p1 Coordinate

The first Coordinate.

p2 Coordinate

The second Coordinate.

Envelope(CoordinateSequence)

Creates an Envelope for a region defined by a CoordinateSequences.

public Envelope(CoordinateSequence sequence)

Parameters

sequence CoordinateSequence

The CoordinateSequence.

Envelope(Envelope)

Create an Envelope from an existing Envelope.

public Envelope(Envelope env)

Parameters

env Envelope

The 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

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 double

The first x-value.

x2 double

The second x-value.

y1 double

The first y-value.

y2 double

The 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 this Envelope 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

double

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

double

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

env Envelope

An envelope

Returns

int

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 object

An envelope

Returns

int

Contains(Coordinate)

Tests if the given point lies in or on the envelope.

public bool Contains(Coordinate p)

Parameters

p Coordinate

the point which this Envelope is being checked for containing

Returns

bool

true if the point lies in the interior or on the boundary of this Envelope.

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 this Envelope

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 double

the x-coordinate of the point which this Envelope is being checked for containing

y double

the 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 this Envelope.

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

Envelope

Covers(Coordinate)

Tests if the given point lies in or on the envelope.

public bool Covers(Coordinate p)

Parameters

p Coordinate

the point which this Envelope is being checked for containing

Returns

bool

true if the point lies in the interior or on the boundary of this Envelope.

Covers(Envelope)

Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary).

public bool Covers(Envelope other)

Parameters

other Envelope

the Envelope to check

Returns

bool

true if this Envelope covers the other

Covers(double, double)

Tests if the given point lies in or on the envelope.

public bool Covers(double x, double y)

Parameters

x double

the x-coordinate of the point which this Envelope is being checked for containing

y double

the 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 this Envelope.

Disjoint(Envelope)

Tests if the region defined by other is disjoint from the region of this Envelope.

public bool Disjoint(Envelope other)

Parameters

other Envelope

The Envelope being checked for disjointness

Returns

bool

true if the Envelopes 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

bool

Equals(object)

public override bool Equals(object o)

Parameters

o object

Returns

bool

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 double

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.

public void ExpandBy(double deltaX, double deltaY)

Parameters

deltaX double

The distance to expand the envelope along the the X axis.

deltaY double

The 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 Coordinate

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.

public void ExpandToInclude(Envelope other)

Parameters

other Envelope

the 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 double

The value to lower the minimum x to or to raise the maximum x to.

y double

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.

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 Envelope

the Envelope to expand to include.

Returns

Envelope

GetHashCode()

public override int GetHashCode()

Returns

int

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 Coordinate

The Coordinate.

Init(Coordinate, Coordinate)

Initialize an Envelope for a region defined by two Coordinates.

public void Init(Coordinate p1, Coordinate p2)

Parameters

p1 Coordinate

The first Coordinate.

p2 Coordinate

The second Coordinate.

Init(Envelope)

Initialize an Envelope from an existing Envelope.

public void Init(Envelope env)

Parameters

env Envelope

The 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 double

The first x-value.

x2 double

The second x-value.

y1 double

The first y-value.

y2 double

The second y-value.

Intersection(Envelope)

Computes the intersection of two Envelopes.

public Envelope Intersection(Envelope env)

Parameters

env Envelope

The 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 Coordinate

the Coordinate to be tested.

Returns

bool

true if the point overlaps this Envelope.

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 Coordinate

A point

b Coordinate

Another 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 Coordinate

One extremal point of the envelope.

p2 Coordinate

Another extremal point of the envelope.

q Coordinate

Point 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 Coordinate

One extremal point of the envelope Point.

p2 Coordinate

Another extremal point of the envelope Point.

q1 Coordinate

One extremal point of the envelope Q.

q2 Coordinate

Another 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 Envelope

The Envelope which this Envelope is being checked for intersecting.

Returns

bool

true if the Envelopes 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

x double

the x-ordinate of the point.

y double

the y-ordinate of the point.

Returns

bool

true if the point overlaps this Envelope.

Parse(string)

Method to parse an envelope from its ToString() value

public static Envelope Parse(string envelope)

Parameters

envelope string

The 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)

Parameters

transX double

The amount to translate along the X axis.

transY double

The amount to translate along the Y axis.