public class Envelope extends Object implements Comparable, Serializable
Geometry
,
e.g. the minimum and maximum x and y values of the Coordinate
s.
Envelopes support infinite or half-infinite regions, by using the values of
Double.POSITIVE_INFINITY
and Double.NEGATIVE_INFINITY
.
Envelope objects may have a null value.
When Envelope objects are created or initialized, the supplies extent values are automatically sorted into the correct order.
Constructor and Description |
---|
Envelope()
Creates a null
Envelope . |
Envelope(Coordinate p)
Creates an
Envelope for a region defined by a single Coordinate. |
Envelope(Coordinate p1,
Coordinate p2)
Creates an
Envelope for a region defined by two Coordinates. |
Envelope(double x1,
double x2,
double y1,
double y2)
Creates an
Envelope for a region defined by maximum and minimum values. |
Envelope(Envelope env)
Create an
Envelope from an existing Envelope. |
Modifier and Type | Method and Description |
---|---|
Coordinate |
centre()
Computes the coordinate of the centre of this envelope (as long as it is non-null
|
int |
compareTo(Object o)
Compares two envelopes using lexicographic ordering.
|
boolean |
contains(Coordinate p)
Tests if the given point lies in or on the envelope.
|
boolean |
contains(double x,
double y)
Tests if the given point lies in or on the envelope.
|
boolean |
contains(Envelope other)
Tests if the
Envelope other
lies wholely inside this Envelope (inclusive of the boundary). |
boolean |
containsProperly(Envelope other)
Tests if an envelope is properly contained in this one.
|
Envelope |
copy()
Creates a copy of this envelope object.
|
boolean |
covers(Coordinate p)
Tests if the given point lies in or on the envelope.
|
boolean |
covers(double x,
double y)
Tests if the given point lies in or on the envelope.
|
boolean |
covers(Envelope other)
Tests if the
Envelope other
lies wholely inside this Envelope (inclusive of the boundary). |
boolean |
disjoint(Envelope other)
Tests if the region defined by
other
is disjoint from the region of this Envelope . |
double |
distance(Envelope env)
Computes the distance between this and another
Envelope . |
boolean |
equals(Object other) |
void |
expandBy(double distance)
Expands this envelope by a given distance in all directions.
|
void |
expandBy(double deltaX,
double deltaY)
Expands this envelope by a given distance in all directions.
|
void |
expandToInclude(Coordinate p)
Enlarges this
Envelope so that it contains
the given Coordinate . |
void |
expandToInclude(double x,
double y)
Enlarges this
Envelope so that it contains
the given point. |
void |
expandToInclude(Envelope other)
Enlarges this
Envelope so that it contains
the other Envelope. |
double |
getArea()
Gets the area of this envelope.
|
double |
getDiameter()
Gets the length of the diameter (diagonal) of the envelope.
|
double |
getHeight()
Returns the difference between the maximum and minimum y values.
|
double |
getMaxX()
Returns the
Envelope s maximum x-value. |
double |
getMaxY()
Returns the
Envelope s maximum y-value. |
double |
getMinX()
Returns the
Envelope s minimum x-value. |
double |
getMinY()
Returns the
Envelope s minimum y-value. |
double |
getWidth()
Returns the difference between the maximum and minimum x values.
|
int |
hashCode() |
void |
init()
Initialize to a null
Envelope . |
void |
init(Coordinate p)
Initialize an
Envelope to a region defined by a single Coordinate. |
void |
init(Coordinate p1,
Coordinate p2)
Initialize an
Envelope to a region defined by two Coordinates. |
void |
init(double x1,
double x2,
double y1,
double y2)
Initialize an
Envelope for a region defined by maximum and minimum values. |
void |
init(Envelope env)
Initialize an
Envelope from an existing Envelope. |
Envelope |
intersection(Envelope env)
Computes the intersection of two
Envelope s. |
boolean |
intersects(Coordinate p)
Tests if the point
p
intersects (lies inside) the region of this Envelope . |
boolean |
intersects(Coordinate a,
Coordinate b)
Tests if the extent defined by two extremal points
intersects the extent of this
Envelope . |
static boolean |
intersects(Coordinate p1,
Coordinate p2,
Coordinate q)
Test the point q to see whether it intersects the Envelope defined by p1-p2
|
static boolean |
intersects(Coordinate p1,
Coordinate p2,
Coordinate q1,
Coordinate q2)
Tests whether the envelope defined by p1-p2
and the envelope defined by q1-q2
intersect.
|
boolean |
intersects(double x,
double y)
Check if the point
(x, y)
intersects (lies inside) the region of this Envelope . |
boolean |
intersects(Envelope other)
Tests if the region defined by
other
intersects the region of this Envelope . |
boolean |
isNull()
Returns
true if this Envelope is a "null"
envelope. |
double |
maxExtent()
Gets the maximum extent of this envelope across both dimensions.
|
double |
minExtent()
Gets the minimum extent of this envelope across both dimensions.
|
boolean |
overlaps(Coordinate p)
Deprecated.
Use #intersects instead.
|
boolean |
overlaps(double x,
double y)
Deprecated.
Use #intersects instead.
|
boolean |
overlaps(Envelope other)
Deprecated.
Use #intersects instead. In the future, #overlaps may be
changed to be a true overlap check; that is, whether the intersection is
two-dimensional.
|
void |
setToNull()
Makes this
Envelope a "null" envelope, that is, the envelope
of the empty geometry. |
String |
toString() |
void |
translate(double transX,
double transY)
Translates this envelope by given amounts in the X and Y direction.
|
public Envelope()
Envelope
.public Envelope(double x1, double x2, double y1, double y2)
Envelope
for a region defined by maximum and minimum values.x1
- the first x-valuex2
- the second x-valuey1
- the first y-valuey2
- the second y-valuepublic Envelope(Coordinate p1, Coordinate p2)
Envelope
for a region defined by two Coordinates.p1
- the first Coordinatep2
- the second Coordinatepublic Envelope(Coordinate p)
Envelope
for a region defined by a single Coordinate.p
- the Coordinatepublic Envelope(Envelope env)
Envelope
from an existing Envelope.env
- the Envelope to initialize frompublic static boolean intersects(Coordinate p1, Coordinate p2, Coordinate q)
p1
- one extremal point of the envelopep2
- another extremal point of the envelopeq
- the point to test for intersectiontrue
if q intersects the envelope p1-p2public static boolean intersects(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
p1
- one extremal point of the envelope Pp2
- another extremal point of the envelope Pq1
- one extremal point of the envelope Qq2
- another extremal point of the envelope Qtrue
if Q intersects Ppublic void init()
Envelope
.public void init(double x1, double x2, double y1, double y2)
Envelope
for a region defined by maximum and minimum values.x1
- the first x-valuex2
- the second x-valuey1
- the first y-valuey2
- the second y-valuepublic Envelope copy()
public void init(Coordinate p1, Coordinate p2)
Envelope
to a region defined by two Coordinates.p1
- the first Coordinatep2
- the second Coordinatepublic void init(Coordinate p)
Envelope
to a region defined by a single Coordinate.p
- the coordinatepublic void init(Envelope env)
Envelope
from an existing Envelope.env
- the Envelope to initialize frompublic void setToNull()
Envelope
a "null" envelope, that is, the envelope
of the empty geometry.public boolean isNull()
true
if this Envelope
is a "null"
envelope.true
if this Envelope
is uninitialized
or is the envelope of the empty geometry.public double getWidth()
Envelope
public double getHeight()
Envelope
public double getDiameter()
public double getMinX()
Envelope
s minimum x-value. min x > max x
indicates that this is a null Envelope
.public double getMaxX()
Envelope
s maximum x-value. min x > max x
indicates that this is a null Envelope
.public double getMinY()
Envelope
s minimum y-value. min y > max y
indicates that this is a null Envelope
.public double getMaxY()
Envelope
s maximum y-value. min y > max y
indicates that this is a null Envelope
.public double getArea()
public double minExtent()
public double maxExtent()
public void expandToInclude(Coordinate p)
Envelope
so that it contains
the given Coordinate
.
Has no effect if the point is already on or within the envelope.p
- the Coordinate to expand to includepublic void expandBy(double distance)
distance
- the distance to expand the envelopepublic void expandBy(double deltaX, double deltaY)
deltaX
- the distance to expand the envelope along the the X axisdeltaY
- the distance to expand the envelope along the the Y axispublic void expandToInclude(double x, double y)
Envelope
so that it contains
the given point.
Has no effect if the point is already on or within the envelope.x
- the value to lower the minimum x to or to raise the maximum x toy
- the value to lower the minimum y to or to raise the maximum y topublic void expandToInclude(Envelope other)
Envelope
so that it contains
the other
Envelope.
Has no effect if other
is wholly on or
within the envelope.other
- the Envelope
to expand to includepublic void translate(double transX, double transY)
transX
- the amount to translate along the X axistransY
- the amount to translate along the Y axispublic Coordinate centre()
null
if the envelope is nullpublic Envelope intersection(Envelope env)
Envelope
s.env
- the envelope to intersect withpublic boolean intersects(Envelope other)
other
intersects the region of this Envelope
.
A null envelope never intersects.
other
- the Envelope
which this Envelope
is
being checked for intersectingtrue
if the Envelope
s intersectpublic boolean intersects(Coordinate a, Coordinate b)
Envelope
.a
- a pointb
- another pointtrue
if the extents intersectpublic boolean disjoint(Envelope other)
other
is disjoint from the region of this Envelope
.
A null envelope is always disjoint.
other
- the Envelope
being checked for disjointnesstrue
if the Envelope
s are disjointintersects(Envelope)
public boolean overlaps(Envelope other)
public boolean intersects(Coordinate p)
p
intersects (lies inside) the region of this Envelope
.p
- the Coordinate
to be testedtrue
if the point intersects this Envelope
public boolean overlaps(Coordinate p)
public boolean intersects(double x, double y)
(x, y)
intersects (lies inside) the region of this Envelope
.x
- the x-ordinate of the pointy
- the y-ordinate of the pointtrue
if the point overlaps this Envelope
public boolean overlaps(double x, double y)
public boolean contains(Envelope other)
Envelope other
lies wholely 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 checkother
is contained in this Envelope
covers(Envelope)
public boolean contains(Coordinate p)
Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
p
- the point which this Envelope
is
being checked for containingtrue
if the point lies in the interior or
on the boundary of this Envelope
.covers(Coordinate)
public boolean contains(double x, double y)
Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
x
- the x-coordinate of the point which this Envelope
is
being checked for containingy
- the y-coordinate of the point which this Envelope
is
being checked for containingtrue
if (x, y)
lies in the interior or
on the boundary of this Envelope
.covers(double, double)
public boolean containsProperly(Envelope other)
other
- the envelope to testpublic boolean covers(double x, double y)
x
- the x-coordinate of the point which this Envelope
is
being checked for containingy
- the y-coordinate of the point which this Envelope
is
being checked for containingtrue
if (x, y)
lies in the interior or
on the boundary of this Envelope
.public boolean covers(Coordinate p)
p
- the point which this Envelope
is
being checked for containingtrue
if the point lies in the interior or
on the boundary of this Envelope
.public boolean covers(Envelope other)
Envelope other
lies wholely inside this Envelope
(inclusive of the boundary).other
- the Envelope
to checkEnvelope
covers the other
public double distance(Envelope env)
Envelope
.
The distance between overlapping Envelopes is 0. Otherwise, the
distance is the Euclidean distance between the closest points.public int compareTo(Object o)
compareTo
in interface Comparable
o
- an Envelope objectCopyright © 2024. All rights reserved.