GEOS 3.11.1
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
geos::geom::Envelope Class Reference

An Envelope defines a rectangulare region of the 2D coordinate plane. More...

#include <geos.h>

Public Types

typedef std::unique_ptr< EnvelopePtr
 

Public Member Functions

 Envelope ()
 Creates a null Envelope.
 
 Envelope (double x1, double x2, double y1, double y2)
 Creates an Envelope for a region defined by maximum and minimum values. More...
 
 Envelope (const Coordinate &p1, const Coordinate &p2)
 Creates an Envelope for a region defined by two Coordinates. More...
 
 Envelope (const Coordinate &p)
 Creates an Envelope for a region defined by a single Coordinate. More...
 
 Envelope (const std::string &str)
 Create an Envelope from an Envelope string representation produced by Envelope::toString()
 
bool intersects (const Coordinate &a, const Coordinate &b) const
 Check if the extent defined by two extremal points intersects the extent of this Envelope. More...
 
void init ()
 Initialize to a null Envelope.
 
void init (double x1, double x2, double y1, double y2)
 Initialize an Envelope for a region defined by maximum and minimum values. More...
 
void init (const Coordinate &p1, const Coordinate &p2)
 Initialize an Envelope to a region defined by two Coordinates. More...
 
void init (const Coordinate &p)
 Initialize an Envelope to a region defined by a single Coordinate. More...
 
void setToNull ()
 Makes this Envelope a "null" envelope, that is, the envelope of the empty geometry.
 
bool isNull (void) const
 Returns true if this Envelope is a "null" envelope. More...
 
double getWidth () const
 Returns the difference between the maximum and minimum x values. More...
 
double getHeight () const
 Returns the difference between the maximum and minimum y values. More...
 
double getArea () const
 Gets the area of this envelope. More...
 
double getMaxY () const
 Returns the Envelope maximum y-value. min y > max y indicates that this is a null Envelope.
 
double getMaxX () const
 Returns the Envelope maximum x-value. min x > max x indicates that this is a null Envelope.
 
double getMinY () const
 Returns the Envelope minimum y-value. min y > max y indicates that this is a null Envelope.
 
double getMinX () const
 Returns the Envelope minimum x-value. min x > max x indicates that this is a null Envelope.
 
double getDiameter () const
 
bool centre (Coordinate &centre) const
 Computes the coordinate of the centre of this envelope (as long as it is non-null). More...
 
bool intersection (const Envelope &env, Envelope &result) const
 Computes the intersection of two Envelopes. More...
 
void translate (double transX, double transY)
 Translates this envelope by given amounts in the X and Y direction. More...
 
void expandBy (double deltaX, double deltaY)
 Expands this envelope by a given distance in all directions. Both positive and negative distances are supported. More...
 
void expandBy (double p_distance)
 Expands this envelope by a given distance in all directions. More...
 
void expandToInclude (const Coordinate &p)
 Enlarges the boundary of the Envelope so that it contains p. Does nothing if p is already on or within the boundaries. More...
 
void expandToInclude (double x, double y)
 Enlarges the boundary of the Envelope so that it contains (x,y). More...
 
void expandToInclude (const Envelope *other)
 Enlarges the boundary of the Envelope so that it contains other. More...
 
void expandToInclude (const Envelope &other)
 
bool contains (const Envelope &other) const
 Tests if the Envelope other lies wholly inside this Envelope (inclusive of the boundary). More...
 
bool contains (const Envelope *other) const
 
bool contains (const Coordinate &p) const
 Returns true if the given point lies in or on the envelope. More...
 
bool contains (double x, double y) const
 Returns true if the given point lies in or on the envelope. More...
 
bool intersects (const Coordinate &other) const
 Check if the point p intersects (lies inside) the region of this Envelope. More...
 
bool intersects (double x, double y) const
 Check if the point (x, y) intersects (lies inside) the region of this Envelope. More...
 
bool intersects (const Envelope *other) const
 Check if the region defined by other Envelope intersects the region of this Envelope. More...
 
bool intersects (const Envelope &other) const
 
bool disjoint (const Envelope &other) const
 
bool disjoint (const Envelope *other) const
 
bool covers (double x, double y) const
 Tests if the given point lies in or on the envelope. More...
 
bool covers (const Coordinate *p) const
 Tests if the given point lies in or on the envelope. More...
 
bool covers (const Envelope &other) const
 Tests if the Envelope other lies wholly inside this Envelope (inclusive of the boundary). More...
 
bool covers (const Envelope *other) const
 
bool equals (const Envelope *other) const
 Returns true if the Envelope other spatially equals this Envelope. More...
 
std::string toString () const
 Returns a string of the form Env[minx:maxx,miny:maxy]. More...
 
double distance (const Envelope &env) const
 Computes the distance between this and another Envelope. More...
 
double distanceSquared (const Envelope &env) const
 Computes the square of the distance between this and another Envelope. More...
 
std::size_t hashCode () const
 

Static Public Member Functions

static bool intersects (const Coordinate &p1, const Coordinate &p2, const Coordinate &q)
 Test the point q to see whether it intersects the Envelope defined by p1-p2. More...
 
static bool intersects (const Coordinate &p1, const Coordinate &p2, const Coordinate &q1, const Coordinate &q2)
 Test the envelope defined by p1-p2 for intersection with the envelope defined by q1-q2. More...
 
static double distanceToCoordinate (const Coordinate &c, const Coordinate &p0, const Coordinate &p1)
 Computes the distance between one Coordinate and an Envelope defined by two other Coordinates. The order of the Coordinates used to define the envelope is not significant. More...
 
static double distanceSquaredToCoordinate (const Coordinate &c, const Coordinate &p0, const Coordinate &p1)
 Computes the squared distance between one Coordinate and an Envelope defined by two other Coordinates. The order of the Coordinates used to define the envelope is not significant. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Envelope &o)
 Output operator.
 
bool operator== (const Envelope &a, const Envelope &b)
 Checks if two Envelopes are equal (2D only check)
 
bool operator!= (const Envelope &a, const Envelope &b)
 
bool operator< (const Envelope &a, const Envelope &b)
 

Detailed Description

An Envelope defines a rectangulare region of the 2D coordinate plane.

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_POSITIVE_INFINITY and Double_NEGATIVE_INFINITY.

When Envelope objects are created or initialized, the supplies extent values are automatically sorted into the correct order.

Constructor & Destructor Documentation

◆ Envelope() [1/3]

geos::geom::Envelope::Envelope ( double  x1,
double  x2,
double  y1,
double  y2 
)
inline

Creates an Envelope for a region defined by maximum and minimum values.

Parameters
x1the first x-value
x2the second x-value
y1the first y-value
y2the second y-value

◆ Envelope() [2/3]

geos::geom::Envelope::Envelope ( const Coordinate p1,
const Coordinate p2 
)
inline

Creates an Envelope for a region defined by two Coordinates.

Parameters
p1the first Coordinate
p2the second Coordinate

◆ Envelope() [3/3]

geos::geom::Envelope::Envelope ( const Coordinate p)
inlineexplicit

Creates an Envelope for a region defined by a single Coordinate.

Parameters
pthe Coordinate

Member Function Documentation

◆ centre()

bool geos::geom::Envelope::centre ( Coordinate centre) const

Computes the coordinate of the centre of this envelope (as long as it is non-null).

Parameters
centreThe coordinate to write results into
Returns
false if the center could not be found (null envelope).

◆ contains() [1/3]

bool geos::geom::Envelope::contains ( const Coordinate p) const
inline

Returns true if the given point lies in or on the envelope.

Parameters
pthe point which this Envelope is being checked for containing
Returns
true if the point lies in the interior or on the boundary of this Envelope.

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ contains() [2/3]

bool geos::geom::Envelope::contains ( const Envelope other) const
inline

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

Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.

Parameters
otherthe Envelope to check
Returns
true if other is contained in this Envelope
See also
covers(Envelope)

◆ contains() [3/3]

bool geos::geom::Envelope::contains ( double  x,
double  y 
) const
inline

Returns true if the given point lies in or on the envelope.

Parameters
xthe x-coordinate of the point which this Envelope is being checked for containing
ythe y-coordinate of the point which this Envelope is being checked for containing
Returns
true if (x, y) lies in the interior or on the boundary of this Envelope.

◆ covers() [1/3]

bool geos::geom::Envelope::covers ( const Coordinate p) const
inline

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

Parameters
pthe point which this Envelope is being checked for containing
Returns
true if the point lies in the interior or on the boundary of this Envelope.

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ covers() [2/3]

bool geos::geom::Envelope::covers ( const Envelope other) const

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

Parameters
otherthe Envelope to check
Returns
true if this Envelope covers the other

◆ covers() [3/3]

bool geos::geom::Envelope::covers ( double  x,
double  y 
) const

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

Parameters
xthe x-coordinate of the point which this Envelope is being checked for containing
ythe y-coordinate of the point which this Envelope is being checked for containing
Returns
true if (x, y) lies in the interior or on the boundary of this Envelope.

◆ disjoint()

bool geos::geom::Envelope::disjoint ( const Envelope other) const
inline

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

Parameters
otherthe Envelope being checked for disjointness
Returns
true if the Envelopes are disjoint

◆ distance()

double geos::geom::Envelope::distance ( const Envelope env) const
inline

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.

◆ distanceSquared()

double geos::geom::Envelope::distanceSquared ( const Envelope env) const
inline

Computes the square of 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.

◆ distanceSquaredToCoordinate()

static double geos::geom::Envelope::distanceSquaredToCoordinate ( const Coordinate c,
const Coordinate p0,
const Coordinate p1 
)
inlinestatic

Computes the squared distance between one Coordinate and an Envelope defined by two other Coordinates. The order of the Coordinates used to define the envelope is not significant.

Parameters
cthe coordinate to from which distance should be found
p0first coordinate defining an envelope
p1second coordinate defining an envelope.

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ distanceToCoordinate()

static double geos::geom::Envelope::distanceToCoordinate ( const Coordinate c,
const Coordinate p0,
const Coordinate p1 
)
inlinestatic

Computes the distance between one Coordinate and an Envelope defined by two other Coordinates. The order of the Coordinates used to define the envelope is not significant.

Parameters
cthe coordinate to from which distance should be found
p0first coordinate defining an envelope
p1second coordinate defining an envelope.

◆ equals()

bool geos::geom::Envelope::equals ( const Envelope other) const

Returns true if the Envelope other spatially equals this Envelope.

Parameters
otherthe Envelope which this Envelope is being checked for equality
Returns
true if this and other Envelope objects are spatially equal

◆ expandBy() [1/2]

void geos::geom::Envelope::expandBy ( double  deltaX,
double  deltaY 
)

Expands this envelope by a given distance in all directions. Both positive and negative distances are supported.

Parameters
deltaXthe distance to expand the envelope along the X axis
deltaYthe distance to expand the envelope along the Y axis

◆ expandBy() [2/2]

void geos::geom::Envelope::expandBy ( double  p_distance)
inline

Expands this envelope by a given distance in all directions.

Both positive and negative distances are supported.

Parameters
p_distancethe distance to expand the envelope

◆ expandToInclude() [1/3]

void geos::geom::Envelope::expandToInclude ( const Coordinate p)
inline

Enlarges the boundary of the Envelope so that it contains p. Does nothing if p is already on or within the boundaries.

Parameters
pthe Coordinate to include

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ expandToInclude() [2/3]

void geos::geom::Envelope::expandToInclude ( const Envelope other)
inline

Enlarges the boundary of the Envelope so that it contains other.

Does nothing if other is wholly on or within the boundaries.

Parameters
otherthe Envelope to merge with

◆ expandToInclude() [3/3]

void geos::geom::Envelope::expandToInclude ( double  x,
double  y 
)
inline

Enlarges the boundary of the Envelope so that it contains (x,y).

Does nothing if (x,y) is already on or within the boundaries.

Parameters
xthe value to lower the minimum x to or to raise the maximum x to
ythe value to lower the minimum y to or to raise the maximum y to

◆ getArea()

double geos::geom::Envelope::getArea ( ) const
inline

Gets the area of this envelope.

Returns
the area of the envelope
0.0 if the envelope is null

◆ getDiameter()

double geos::geom::Envelope::getDiameter ( ) const
inline

Gets the length of the diameter (diagonal) of the envelope.

Returns
the diameter length

◆ getHeight()

double geos::geom::Envelope::getHeight ( ) const
inline

Returns the difference between the maximum and minimum y values.

Returns
max y - min y, or 0 if this is a null Envelope

◆ getWidth()

double geos::geom::Envelope::getWidth ( ) const
inline

Returns the difference between the maximum and minimum x values.

Returns
max x - min x, or 0 if this is a null Envelope

◆ init() [1/3]

void geos::geom::Envelope::init ( const Coordinate p)
inline

Initialize an Envelope to a region defined by a single Coordinate.

Parameters
pthe Coordinate

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ init() [2/3]

void geos::geom::Envelope::init ( const Coordinate p1,
const Coordinate p2 
)
inline

Initialize an Envelope to a region defined by two Coordinates.

Parameters
p1the first Coordinate
p2the second Coordinate

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ init() [3/3]

void geos::geom::Envelope::init ( double  x1,
double  x2,
double  y1,
double  y2 
)
inline

Initialize an Envelope for a region defined by maximum and minimum values.

Parameters
x1the first x-value
x2the second x-value
y1the first y-value
y2the second y-value

◆ intersection()

bool geos::geom::Envelope::intersection ( const Envelope env,
Envelope result 
) const

Computes the intersection of two Envelopes.

Parameters
envthe envelope to intersect with
resultthe envelope representing the intersection of the envelopes (this will be the null envelope if either argument is null, or they do not intersect)
Returns
false if not intersection is found

◆ intersects() [1/6]

bool geos::geom::Envelope::intersects ( const Coordinate a,
const Coordinate b 
) const

Check if the extent defined by two extremal points intersects the extent of this Envelope.

Parameters
aa point
banother point
Returns
true if the extents intersect

◆ intersects() [2/6]

bool geos::geom::Envelope::intersects ( const Coordinate other) const
inline

Check if the point p intersects (lies inside) the region of this Envelope.

Parameters
otherthe Coordinate to be tested
Returns
true if the point intersects this Envelope

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ intersects() [3/6]

static bool geos::geom::Envelope::intersects ( const Coordinate p1,
const Coordinate p2,
const Coordinate q 
)
static

Test the point q to see whether it intersects the Envelope defined by p1-p2.

Parameters
p1one extremal point of the envelope
p2another extremal point of the envelope
qthe point to test for intersection
Returns
true if q intersects the envelope p1-p2

◆ intersects() [4/6]

static bool geos::geom::Envelope::intersects ( const Coordinate p1,
const Coordinate p2,
const Coordinate q1,
const Coordinate q2 
)
inlinestatic

Test the envelope defined by p1-p2 for intersection with the envelope defined by q1-q2.

Parameters
p1one extremal point of the envelope P
p2another extremal point of the envelope P
q1one extremal point of the envelope Q
q2another extremal point of the envelope Q
Returns
true if Q intersects P

References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.

◆ intersects() [5/6]

bool geos::geom::Envelope::intersects ( const Envelope other) const
inline

Check if the region defined by other Envelope intersects the region of this Envelope.

Parameters
otherthe Envelope which this Envelope is being checked for intersection
Returns
true if the Envelopes intersects

◆ intersects() [6/6]

bool geos::geom::Envelope::intersects ( double  x,
double  y 
) const
inline

Check if the point (x, y) intersects (lies inside) the region of this Envelope.

Parameters
xthe x-ordinate of the point
ythe y-ordinate of the point
Returns
true if the point intersects this Envelope

◆ isNull()

bool geos::geom::Envelope::isNull ( void  ) const
inline

Returns true if this Envelope is a "null" envelope.

Returns
true if this Envelope is uninitialized or is the envelope of the empty geometry.

◆ toString()

std::string geos::geom::Envelope::toString ( ) const

Returns a string of the form Env[minx:maxx,miny:maxy].

Returns
a string of the form Env[minx:maxx,miny:maxy]

◆ translate()

void geos::geom::Envelope::translate ( double  transX,
double  transY 
)

Translates this envelope by given amounts in the X and Y direction.

Parameters
transXthe amount to translate along the X axis
transYthe amount to translate along the Y axis

Friends And Related Function Documentation

◆ operator<

bool operator< ( const Envelope a,
const Envelope b 
)
friend

Strict weak ordering operator for Envelope This is the C++ equivalent of JTS's compareTo


The documentation for this class was generated from the following file: