GEOS
3.9.1dev
|
An Envelope defines a rectangulare region of the 2D coordinate plane. More...
#include <geos.h>
Public Types | |
typedef std::unique_ptr< Envelope > | Ptr |
Public Member Functions | |
Envelope () | |
Creates a null Envelope. More... | |
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 Envelope &env) | |
Copy constructor. More... | |
Envelope & | operator= (const Envelope &e) |
Assignment operator. More... | |
Envelope (const std::string &str) | |
Create an Envelope from an Envelope string representation produced by Envelope::toString() More... | |
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 (void) |
Initialize to a null Envelope. More... | |
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 (void) |
Makes this Envelope a "null" envelope, that is, the envelope of the empty geometry. More... | |
bool | isNull (void) const |
Returns true if this Envelope is a "null" envelope. More... | |
double | getWidth (void) const |
Returns the difference between the maximum and minimum x values. More... | |
double | getHeight (void) 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. More... | |
double | getMaxX () const |
Returns the Envelope maximum x-value. min x > max x indicates that this is a null Envelope. More... | |
double | getMinY () const |
Returns the Envelope minimum y-value. min y > max y indicates that this is a null Envelope. More... | |
double | getMinX () const |
Returns the Envelope minimum x-value. min x > max x indicates that this is a null Envelope. More... | |
bool | centre (Coordinate ¢re) 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 &p) 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 (void) 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... | |
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 &p1, const Coordinate &p2) |
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 &p1, const Coordinate &p2) |
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... | |
Private Member Functions | |
std::vector< std::string > | split (const std::string &str, const std::string &delimiters=" ") |
Splits a string into parts based on the supplied delimiters. More... | |
Static Private Member Functions | |
static double | distance (double x0, double y0, double x1, double y1) |
Private Attributes | |
double | minx |
the minimum x-coordinate More... | |
double | maxx |
the maximum x-coordinate More... | |
double | miny |
the minimum y-coordinate More... | |
double | maxy |
the maximum y-coordinate More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Envelope &o) |
Output operator. More... | |
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.
Definition at line 58 of file Envelope.h.
typedef std::unique_ptr<Envelope> geos::geom::Envelope::Ptr |
Definition at line 64 of file Envelope.h.
geos::geom::Envelope::Envelope | ( | ) |
Creates a null Envelope.
geos::geom::Envelope::Envelope | ( | double | x1, |
double | x2, | ||
double | y1, | ||
double | y2 | ||
) |
Creates an Envelope for a region defined by maximum and minimum values.
x1 | the first x-value |
x2 | the second x-value |
y1 | the first y-value |
y2 | the second y-value |
geos::geom::Envelope::Envelope | ( | const Coordinate & | p1, |
const Coordinate & | p2 | ||
) |
Creates an Envelope for a region defined by two Coordinates.
p1 | the first Coordinate |
p2 | the second Coordinate |
geos::geom::Envelope::Envelope | ( | const Coordinate & | p | ) |
Creates an Envelope for a region defined by a single Coordinate.
p | the Coordinate |
geos::geom::Envelope::Envelope | ( | const Envelope & | env | ) |
Copy constructor.
geos::geom::Envelope::Envelope | ( | const std::string & | str | ) |
Create an Envelope from an Envelope string representation produced by Envelope::toString()
bool geos::geom::Envelope::centre | ( | Coordinate & | centre | ) | const |
Computes the coordinate of the centre of this envelope (as long as it is non-null).
centre | The coordinate to write results into |
false
if the center could not be found (null envelope).
|
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.
other | the Envelope to check |
true
if other
is contained in this EnvelopeDefinition at line 335 of file Envelope.h.
|
inline |
Definition at line 341 of file Envelope.h.
|
inline |
Returns true
if the given point lies in or on the envelope.
p | the point which this Envelope is being checked for containing |
true
if the point lies in the interior or on the boundary of this Envelope. Definition at line 354 of file Envelope.h.
References geos::geom::Coordinate::x, and geos::geom::Coordinate::y.
|
inline |
Returns true
if the given point lies in or on the envelope.
x | the x-coordinate of the point which this Envelope is being checked for containing |
y | the y-coordinate of the point which this Envelope is being checked for containing |
true
if (x, y)
lies in the interior or on the boundary of this Envelope. Definition at line 370 of file Envelope.h.
bool geos::geom::Envelope::covers | ( | double | x, |
double | y | ||
) | const |
Tests if the given point lies in or on the envelope.
x | the x-coordinate of the point which this Envelope is being checked for containing |
y | the y-coordinate of the point which this Envelope is being checked for containing |
true
if (x, y)
lies in the interior or on the boundary of this Envelope. bool geos::geom::Envelope::covers | ( | const Coordinate * | p | ) | const |
bool geos::geom::Envelope::covers | ( | const Envelope & | other | ) | const |
|
inline |
Definition at line 439 of file Envelope.h.
bool geos::geom::Envelope::disjoint | ( | const Envelope * | other | ) | const |
bool geos::geom::Envelope::disjoint | ( | const Envelope & | other | ) | const |
double geos::geom::Envelope::distance | ( | const Envelope & | env | ) | const |
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.
|
staticprivate |
double geos::geom::Envelope::distanceSquared | ( | const Envelope & | env | ) | const |
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.
|
static |
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.
c | the coordinate to from which distance should be found |
p1 | first coordinate defining an envelope |
p2 | second coordinate defining an envelope. |
|
static |
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.
c | the coordinate to from which distance should be found |
p1 | first coordinate defining an envelope |
p2 | second coordinate defining an envelope. |
bool geos::geom::Envelope::equals | ( | const Envelope * | other | ) | const |
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.
deltaX | the distance to expand the envelope along the X axis |
deltaY | the distance to expand the envelope along the Y axis |
|
inline |
Expands this envelope by a given distance in all directions.
Both positive and negative distances are supported.
p_distance | the distance to expand the envelope |
Definition at line 286 of file Envelope.h.
void geos::geom::Envelope::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.
p | the Coordinate to include |
void geos::geom::Envelope::expandToInclude | ( | double | x, |
double | y | ||
) |
Enlarges the boundary of the Envelope so that it contains (x,y).
Does nothing if (x,y) is already on or within the boundaries.
x | the value to lower the minimum x to or to raise the maximum x to |
y | the value to lower the minimum y to or to raise the maximum y to |
void geos::geom::Envelope::expandToInclude | ( | const Envelope * | other | ) |
void geos::geom::Envelope::expandToInclude | ( | const Envelope & | other | ) |
|
inline |
Gets the area of this envelope.
Definition at line 212 of file Envelope.h.
Referenced by geos::index::strtree::SimpleSTRnode::area().
double geos::geom::Envelope::getHeight | ( | void | ) | const |
Returns the difference between the maximum and minimum y values.
max y - min y
, or 0 if this is a null Envelope double geos::geom::Envelope::getMaxX | ( | ) | const |
double geos::geom::Envelope::getMaxY | ( | ) | const |
Returns the Envelope maximum y-value. min y > max y
indicates that this is a null Envelope.
Referenced by geos::index::strtree::STRtree::centreY().
double geos::geom::Envelope::getMinX | ( | ) | const |
double geos::geom::Envelope::getMinY | ( | ) | const |
Returns the Envelope minimum y-value. min y > max y
indicates that this is a null Envelope.
Referenced by geos::index::strtree::STRtree::centreY().
double geos::geom::Envelope::getWidth | ( | void | ) | const |
Returns the difference between the maximum and minimum x values.
max x - min x
, or 0 if this is a null Envelope size_t geos::geom::Envelope::hashCode | ( | ) | const |
void geos::geom::Envelope::init | ( | void | ) |
Initialize to a null Envelope.
void geos::geom::Envelope::init | ( | double | x1, |
double | x2, | ||
double | y1, | ||
double | y2 | ||
) |
Initialize an Envelope for a region defined by maximum and minimum values.
x1 | the first x-value |
x2 | the second x-value |
y1 | the first y-value |
y2 | the second y-value |
void geos::geom::Envelope::init | ( | const Coordinate & | p1, |
const Coordinate & | p2 | ||
) |
Initialize an Envelope to a region defined by two Coordinates.
p1 | the first Coordinate |
p2 | the second Coordinate |
void geos::geom::Envelope::init | ( | const Coordinate & | p | ) |
Initialize an Envelope to a region defined by a single Coordinate.
p | the Coordinate |
Computes the intersection of two Envelopes.
env | the envelope to intersect with |
result | the envelope representing the intersection of the envelopes (this will be the null envelope if either argument is null, or they do not intersect) |
|
static |
Test the point q
to see whether it intersects the Envelope defined by p1-p2
.
p1 | one extremal point of the envelope |
p2 | another extremal point of the envelope |
q | the point to test for intersection |
true
if q intersects the envelope p1-p2
|
static |
Test the envelope defined by p1-p2
for intersection with the envelope defined by q1-q2
.
p1 | one extremal point of the envelope P |
p2 | another extremal point of the envelope P |
q1 | one extremal point of the envelope Q |
q2 | another extremal point of the envelope Q |
true
if Q intersects P 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.
a | a point |
b | another point |
true
if the extents intersect bool geos::geom::Envelope::intersects | ( | const Coordinate & | p | ) | const |
Check if the point p intersects (lies inside) the region of this Envelope.
p | the Coordinate to be tested |
bool geos::geom::Envelope::intersects | ( | double | x, |
double | y | ||
) | const |
bool geos::geom::Envelope::intersects | ( | const Envelope * | other | ) | const |
bool geos::geom::Envelope::intersects | ( | const Envelope & | other | ) | const |
bool geos::geom::Envelope::isNull | ( | void | ) | const |
void geos::geom::Envelope::setToNull | ( | void | ) |
Makes this Envelope
a "null" envelope, that is, the envelope of the empty geometry.
|
private |
Splits a string into parts based on the supplied delimiters.
This is a generic function that really belongs in a utility file somewhere
std::string geos::geom::Envelope::toString | ( | void | ) | const |
Returns a string
of the form Env[minx:maxx,miny:maxy]
.
string
of the form Env[minx:maxx,miny:maxy]
void geos::geom::Envelope::translate | ( | double | transX, |
double | transY | ||
) |
Translates this envelope by given amounts in the X and Y direction.
transX | the amount to translate along the X axis |
transY | the amount to translate along the Y axis |
|
friend |
Output operator.
|
private |
the maximum x-coordinate
Definition at line 517 of file Envelope.h.
|
private |
the maximum y-coordinate
Definition at line 523 of file Envelope.h.
|
private |
the minimum x-coordinate
Definition at line 514 of file Envelope.h.
|
private |
the minimum y-coordinate
Definition at line 520 of file Envelope.h.