Package com.esri.core.geometry
Class Envelope2D
- java.lang.Object
-
- com.esri.core.geometry.Envelope2D
-
- All Implemented Interfaces:
java.io.Serializable
public final class Envelope2D extends java.lang.Object implements java.io.Serializable
An axis parallel 2-dimensional rectangle.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Envelope2D()
Envelope2D(double _xmin, double _ymin, double _xmax, double _ymax)
Envelope2D(Envelope2D other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) double
_boundaryDistance(Point2D pt)
(package private) double
_calculateToleranceFromEnvelope()
(package private) int
_clipCode(Point2D p)
(package private) int
_envelopeSide(Point2D pt)
(package private) Point2D
_snapClip(Point2D pt)
(package private) Point2D
_snapToBoundary(Point2D pt)
void
centerAt(double x, double y)
void
centerAt(Point c)
(package private) void
centerAt(Point2D pt)
int
clipLine(Point2D p1, Point2D p2)
(package private) int
clipLine(Point2D p0, Point2D p1, int lineExtension, double[] segParams, double[] boundaryDistances)
(package private) boolean
clipLineAuxiliary(double denominator, double numerator, double[] segParams)
static Envelope2D
construct(double _xmin, double _ymin, double _xmax, double _ymax)
static Envelope2D
construct(Envelope2D other)
boolean
contains(double x, double y)
boolean
contains(Envelope2D other)
Returns True if the envelope contains the other envelope (boundary inclusive).boolean
contains(Point p)
boolean
contains(Point2D p)
boolean
containsExclusive(double x, double y)
Returns True if the envelope contains the point (boundary exclusive).(package private) boolean
containsExclusive(Envelope2D other)
Returns True if the envelope contains the other envelope (boundary exclusive).boolean
containsExclusive(Point2D pt)
Returns True if the envelope contains the point (boundary exclusive).double
distance(Envelope2D other)
Calculates minimum distance from this envelope to the other.double
distance(Point2D pt2D)
Calculates minimum distance from this envelope to the point.boolean
equals(java.lang.Object _other)
int
estimateMemorySize()
double
getArea()
Point2D
getCenter()
Gets the center point of the envelope.double
getCenterX()
double
getCenterY()
double
getHeight()
Envelope2D
getInflated(double dx, double dy)
double
getLength()
Point2D
getLowerLeft()
Point2D
getLowerRight()
Point2D
getUpperLeft()
Point2D
getUpperRight()
double
getWidth()
int
hashCode()
void
inflate(double dx, double dy)
boolean
intersect(Envelope2D other)
Intersects this envelope with the other and stores result in this envelope.boolean
isDegenerate(double tolerance)
Returns True, envelope is degenerate (Width or Height are less than tolerance).boolean
isEmpty()
boolean
isIntersecting(double xmin_, double ymin_, double xmax_, double ymax_)
Checks if this envelope intersects the other.boolean
isIntersecting(Envelope2D other)
Checks if this envelope intersects the other.boolean
isIntersectingNE(Envelope2D other)
Checks if this envelope intersects the other assuming neither one is empty.boolean
isPointOnBoundary(Point2D pt, double tolerance)
boolean
isValid()
Returns True if this envelope is valid (empty, or has xmin less or equal to xmax, or ymin less or equal to ymax).void
merge(double x, double y)
void
merge(Envelope2D other)
void
merge(Point2D pt)
void
merge(Point3D pt)
void
mergeNE(double x, double y)
Merges a point with this envelope without checking if the envelope is empty.void
move(double dx, double dy)
Moves the Envelope by given distance.void
normalize()
void
offset(double dx, double dy)
void
queryCenter(Point2D center)
Point2D
queryCorner(int index)
Queries a corner of the envelope.void
queryCorners(Point2D[] corners)
Queries corners into a given array.void
queryCornersReversed(Point2D[] corners)
Queries corners into a given array in reversed order.void
queryIntervalX(Envelope1D env1D)
void
queryIntervalY(Envelope1D env1D)
void
queryLowerLeft(Point2D pt)
void
queryLowerRight(Point2D pt)
void
queryUpperLeft(Point2D pt)
void
queryUpperRight(Point2D pt)
private void
readObject(java.io.ObjectInputStream in)
private void
readObjectNoData()
void
reaspect(double arWidth, double arHeight)
void
scale(double f)
void
setCoords(double _x, double _y)
void
setCoords(double _xmin, double _ymin, double _xmax, double _ymax)
void
setCoords(Envelope1D xinterval, Envelope1D yinterval)
void
setCoords(Envelope2D envSrc)
void
setCoords(Point2D pt)
void
setCoords(Point2D center, double width, double height)
void
setEmpty()
void
setFromPoints(Point2D[] points)
Sets the envelope from the array of points.void
setFromPoints(Point2D[] points, int count)
void
setInfinite()
double
sqrDistance(double xmin_, double ymin_, double xmax_, double ymax_)
Calculates minimum squared distance from this envelope to the other.double
sqrDistance(Envelope2D other)
Calculates minimum squared distance from this envelope to the other.double
sqrDistance(Point2D pt2D)
Calculates minimum squared distance from this envelope to the point.double
sqrMaxDistance(Envelope2D other)
Returns squared max distance between two bounding boxes.private void
writeObject(java.io.ObjectOutputStream out)
void
zoom(double factorX, double factorY)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
XLESSXMIN
private static final int XLESSXMIN
- See Also:
- Constant Field Values
-
YLESSYMIN
private static final int YLESSYMIN
- See Also:
- Constant Field Values
-
XMASK
private static final int XMASK
- See Also:
- Constant Field Values
-
YMASK
private static final int YMASK
- See Also:
- Constant Field Values
-
xmin
public double xmin
-
ymin
public double ymin
-
xmax
public double xmax
-
ymax
public double ymax
-
-
Constructor Detail
-
Envelope2D
public Envelope2D()
-
Envelope2D
public Envelope2D(double _xmin, double _ymin, double _xmax, double _ymax)
-
Envelope2D
public Envelope2D(Envelope2D other)
-
-
Method Detail
-
construct
public static Envelope2D construct(double _xmin, double _ymin, double _xmax, double _ymax)
-
construct
public static Envelope2D construct(Envelope2D other)
-
estimateMemorySize
public int estimateMemorySize()
-
setCoords
public void setCoords(double _x, double _y)
-
setCoords
public void setCoords(double _xmin, double _ymin, double _xmax, double _ymax)
-
setCoords
public void setCoords(Point2D center, double width, double height)
-
setCoords
public void setCoords(Point2D pt)
-
setCoords
public void setCoords(Envelope2D envSrc)
-
getInflated
public Envelope2D getInflated(double dx, double dy)
-
setFromPoints
public void setFromPoints(Point2D[] points)
Sets the envelope from the array of points. The envelope will be set to empty if the array is null.- Parameters:
points
- The points to set the envelope from. No element in the array can be null.
-
setEmpty
public void setEmpty()
-
setInfinite
public void setInfinite()
-
isEmpty
public boolean isEmpty()
-
setCoords
public void setCoords(Envelope1D xinterval, Envelope1D yinterval)
-
merge
public void merge(double x, double y)
-
mergeNE
public void mergeNE(double x, double y)
Merges a point with this envelope without checking if the envelope is empty. Use with care.- Parameters:
x
- The x coord of the pointy
- the y coord in the point
-
merge
public void merge(Point2D pt)
-
merge
public void merge(Point3D pt)
-
merge
public void merge(Envelope2D other)
-
inflate
public void inflate(double dx, double dy)
-
scale
public void scale(double f)
-
zoom
public void zoom(double factorX, double factorY)
-
isIntersecting
public boolean isIntersecting(Envelope2D other)
Checks if this envelope intersects the other.- Parameters:
other
- The other envelope.- Returns:
- True if this envelope intersects the other.
-
isIntersectingNE
public boolean isIntersectingNE(Envelope2D other)
Checks if this envelope intersects the other assuming neither one is empty.- Parameters:
other
- The other envelope.- Returns:
- True if this envelope intersects the other. Assumes this and other envelopes are not empty.
-
isIntersecting
public boolean isIntersecting(double xmin_, double ymin_, double xmax_, double ymax_)
Checks if this envelope intersects the other.- Parameters:
xmin_
-ymin_
-xmax_
-ymax_
-- Returns:
- True if this envelope intersects the other.
-
intersect
public boolean intersect(Envelope2D other)
Intersects this envelope with the other and stores result in this envelope.- Parameters:
other
- The other envelope.- Returns:
- True if this envelope intersects the other, otherwise sets this envelope to empty state and returns False.
-
queryCorner
public Point2D queryCorner(int index)
Queries a corner of the envelope.- Parameters:
index
- Indicates a corner of the envelope.0 means lower left or (xmin, ymin)
1 means upper left or (xmin, ymax)
2 means upper right or (xmax, ymax)
3 means lower right or (xmax, ymin)
- Returns:
- Point at a corner of the envelope.
-
queryCorners
public void queryCorners(Point2D[] corners)
Queries corners into a given array. The array length must be at least 4. Starts from the lower left corner and goes clockwise.- Parameters:
corners
- The array of four points.
-
queryCornersReversed
public void queryCornersReversed(Point2D[] corners)
Queries corners into a given array in reversed order. The array length must be at least 4. Starts from the lower left corner and goes counterclockwise.- Parameters:
corners
- The array of four points.
-
getArea
public double getArea()
-
getLength
public double getLength()
-
setFromPoints
public void setFromPoints(Point2D[] points, int count)
-
reaspect
public void reaspect(double arWidth, double arHeight)
-
getCenterX
public double getCenterX()
-
getCenterY
public double getCenterY()
-
getWidth
public double getWidth()
-
getHeight
public double getHeight()
-
move
public void move(double dx, double dy)
Moves the Envelope by given distance.- Parameters:
dx
-dy
-
-
centerAt
public void centerAt(double x, double y)
-
centerAt
void centerAt(Point2D pt)
-
offset
public void offset(double dx, double dy)
-
normalize
public void normalize()
-
queryLowerLeft
public void queryLowerLeft(Point2D pt)
-
queryLowerRight
public void queryLowerRight(Point2D pt)
-
queryUpperLeft
public void queryUpperLeft(Point2D pt)
-
queryUpperRight
public void queryUpperRight(Point2D pt)
-
isValid
public boolean isValid()
Returns True if this envelope is valid (empty, or has xmin less or equal to xmax, or ymin less or equal to ymax).- Returns:
- True if the envelope is valid.
-
getCenter
public Point2D getCenter()
Gets the center point of the envelope. The Center Point occurs at: ((XMin + XMax) / 2, (YMin + YMax) / 2).- Returns:
- the center point
-
queryCenter
public void queryCenter(Point2D center)
-
centerAt
public void centerAt(Point c)
-
getLowerLeft
public Point2D getLowerLeft()
-
getUpperLeft
public Point2D getUpperLeft()
-
getLowerRight
public Point2D getLowerRight()
-
getUpperRight
public Point2D getUpperRight()
-
contains
public boolean contains(Point p)
-
contains
public boolean contains(Point2D p)
-
contains
public boolean contains(double x, double y)
-
contains
public boolean contains(Envelope2D other)
Returns True if the envelope contains the other envelope (boundary inclusive).- Parameters:
other
- The other envelope.- Returns:
- True if this contains the other.
-
containsExclusive
public boolean containsExclusive(double x, double y)
Returns True if the envelope contains the point (boundary exclusive).- Parameters:
x
-y
-- Returns:
- True if this contains the point.
-
containsExclusive
public boolean containsExclusive(Point2D pt)
Returns True if the envelope contains the point (boundary exclusive).
-
containsExclusive
boolean containsExclusive(Envelope2D other)
Returns True if the envelope contains the other envelope (boundary exclusive).- Parameters:
other
- The other envelope- Returns:
- True if this contains the other, boundary exclusive.
-
equals
public boolean equals(java.lang.Object _other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
_boundaryDistance
double _boundaryDistance(Point2D pt)
-
_envelopeSide
int _envelopeSide(Point2D pt)
-
_calculateToleranceFromEnvelope
double _calculateToleranceFromEnvelope()
-
_clipCode
int _clipCode(Point2D p)
-
clipLine
int clipLine(Point2D p0, Point2D p1, int lineExtension, double[] segParams, double[] boundaryDistances)
-
clipLineAuxiliary
boolean clipLineAuxiliary(double denominator, double numerator, double[] segParams)
-
isDegenerate
public boolean isDegenerate(double tolerance)
Returns True, envelope is degenerate (Width or Height are less than tolerance). Note: this returns False for Empty envelope.
-
isPointOnBoundary
public boolean isPointOnBoundary(Point2D pt, double tolerance)
-
distance
public double distance(Envelope2D other)
Calculates minimum distance from this envelope to the other. Returns 0 for empty envelopes.- Parameters:
other
- The other envelope.- Returns:
- Returns the distance
-
distance
public double distance(Point2D pt2D)
Calculates minimum distance from this envelope to the point. Returns 0 for empty envelopes.- Parameters:
pt2D
- The other point.- Returns:
- Returns the distance
-
sqrDistance
public double sqrDistance(Envelope2D other)
Calculates minimum squared distance from this envelope to the other. Returns 0 for empty envelopes.- Parameters:
other
- The other envelope.- Returns:
- Returns the squared distance
-
sqrDistance
public double sqrDistance(double xmin_, double ymin_, double xmax_, double ymax_)
Calculates minimum squared distance from this envelope to the other. Returns 0 for empty envelopes.- Parameters:
xmin_
-ymin_
-xmax_
-ymax_
-- Returns:
- Returns the squared distance.
-
sqrMaxDistance
public double sqrMaxDistance(Envelope2D other)
Returns squared max distance between two bounding boxes. This is furthest distance between points on the two envelopes.- Parameters:
other
- The bounding box to calculate the max distance two.- Returns:
- Squared distance value.
-
sqrDistance
public double sqrDistance(Point2D pt2D)
Calculates minimum squared distance from this envelope to the point. Returns 0 for empty envelopes.- Parameters:
pt2D
- The point.- Returns:
- Returns the squared distance
-
queryIntervalX
public void queryIntervalX(Envelope1D env1D)
-
queryIntervalY
public void queryIntervalY(Envelope1D env1D)
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
readObjectNoData
private void readObjectNoData() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
-