Package org.geolatte.geom
Class Envelope<P extends Position>
- java.lang.Object
-
- org.geolatte.geom.Envelope<P>
-
public class Envelope<P extends Position> extends Object
An envelope or bounding box implementation.An
Envelopeis characterised by a lower-left and an upper-right coordinate.An
Envelopeis empty if the set of enclosed points is empty.An empty Envelope has Double.NaN for its lowerleft/upperright coordinates.
- Author:
- Karel Maesen, Geovise BVBA, 2011
-
-
Constructor Summary
Constructors Constructor Description Envelope(double minC1, double minC2, double maxC1, double maxC2, CoordinateReferenceSystem<P> crs)Create an instance using the specified coordinates andCoordinateReferenceSystem.Envelope(CoordinateReferenceSystem<P> crs)Creates an empty EnvelopEnvelope(P lowerLeft, P upperRight, CoordinateReferenceSystem<P> crs)Creates an instance from specified lower-left and upper-rightPoints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <Q extends Position>
Envelope<Q>as(Class<Q> castToType)booleancontains(Envelope other)Checks whether thisEnvelopecontains the specifiesEnvelope.booleancontains(P p)Checks whether thisEnvelopecontains the specifiesEnvelope.booleanequals(Object o)doubleextentAlongDimension(int i)CoordinateReferenceSystem<P>getCoordinateReferenceSystem()Returns theCoordinateReferenceSystemfor thisEnvelopeprotected doublegetMaxC0()protected doublegetMaxC1()protected doublegetMinC0()protected doublegetMinC1()inthashCode()Envelope<P>intersect(Envelope<P> other)Intersects the specifiedEnvelopewith thisEnvelopeand returns the result.booleanintersects(Envelope<P> other)Checks whether thisEnvelopeintersects the specifiesEnvelope.booleanisEmpty()Checks whether thisEnvelopeis empty.PlowerLeft()Returns the lower-left point of thisEnvelope.PlowerRight()Returns the lower-right point of thisEnvelope.double[]toArray()Returns the lowerleft and upperright coordinates in 2D for this envelope.StringtoString()Envelope<P>union(Envelope<P> other)Creates anEnvelopethat is the set-theoretic union of thisEnvelopewith the specifiedEnvelopePupperLeft()Returns the upper-left point of thisEnvelope.PupperRight()Returns the upper-right point of thisEnvelope.booleanwithin(Envelope<P> other)Checks whether thisEnvelopeis contained within the specifiedEnvelope
-
-
-
Constructor Detail
-
Envelope
public Envelope(CoordinateReferenceSystem<P> crs)
Creates an empty Envelop
-
Envelope
public Envelope(P lowerLeft, P upperRight, CoordinateReferenceSystem<P> crs)
Creates an instance from specified lower-left and upper-rightPoints. If the positions have coordinate dimension > 2, the Z/M coordinate values will be set to 0 in the constructed Envelope- Parameters:
lowerLeft- thePointdesignating the lower-left coordinatesupperRight- thePointdesignating the upper-right coordinates of the envelope.
-
Envelope
public Envelope(double minC1, double minC2, double maxC1, double maxC2, CoordinateReferenceSystem<P> crs)Create an instance using the specified coordinates andCoordinateReferenceSystem. If theCoordinateReferenceSystemhas coordinate dimension > 2, the Z/M coordinate values will be set to 0 in the envelope- Parameters:
minC1- minimum first coordinateminC2- minimum second coordinatemaxC1- maximum first coordinatemaxC2- maximum second coordinatecrs- theCoordinateReferenceSystemfor the coordinates of the envelope.
-
-
Method Detail
-
getCoordinateReferenceSystem
public CoordinateReferenceSystem<P> getCoordinateReferenceSystem()
Returns theCoordinateReferenceSystemfor thisEnvelope- Returns:
-
lowerLeft
public P lowerLeft()
Returns the lower-left point of thisEnvelope.- Returns:
- the lower-left point
-
upperRight
public P upperRight()
Returns the upper-right point of thisEnvelope.- Returns:
- the upper-right point
-
upperLeft
public P upperLeft()
Returns the upper-left point of thisEnvelope.- Returns:
- the upper-left point
-
lowerRight
public P lowerRight()
Returns the lower-right point of thisEnvelope.- Returns:
- the lower-right point
-
toArray
public double[] toArray()
Returns the lowerleft and upperright coordinates in 2D for this envelope.- Returns:
- [ll.x, ll.y, ur.x, ur.y] for Cartesian envelopes; [ll.lon, ll.lat, ur.lon, ur.lat] for Geographic envelopes
-
getMinC0
protected double getMinC0()
-
getMinC1
protected double getMinC1()
-
getMaxC0
protected double getMaxC0()
-
getMaxC1
protected double getMaxC1()
-
union
public Envelope<P> union(Envelope<P> other)
Creates anEnvelopethat is the set-theoretic union of thisEnvelopewith the specifiedEnvelope- Parameters:
other- other Envelope- Returns:
- an
Envelopethat encompasses both operands. - Throws:
IllegalArgumentException- when the operandEnvelopes don't have the same coordinate reference system.
-
intersect
public Envelope<P> intersect(Envelope<P> other)
Intersects the specifiedEnvelopewith thisEnvelopeand returns the result.- Parameters:
other- the Envelope to intersect with this instance- Returns:
- the set-theoretic intersection of this Envelope and the specified Envelope.
- Throws:
IllegalArgumentException- when the specifiedEnvelopedoesn't have the same coordinate reference system as this instance.
-
isEmpty
public boolean isEmpty()
Checks whether thisEnvelopeis empty.- Returns:
- true iff this instance is empty (the empty set).
-
within
public boolean within(Envelope<P> other)
Checks whether thisEnvelopeis contained within the specifiedEnvelope- Parameters:
other- the otherEnvelope- Returns:
- true iff this instance is contained within the specified
Envelope - Throws:
IllegalArgumentException- when the specifiedEnvelopedoesn't have the same coordinate reference system as this instance.
-
extentAlongDimension
public double extentAlongDimension(int i)
-
contains
public boolean contains(Envelope other)
Checks whether thisEnvelopecontains the specifiesEnvelope.- Parameters:
other- the otherEnvelope- Returns:
- true iff this instance contains the specified
Envelope - Throws:
IllegalArgumentException- when the specifiedEnvelopedoesn't have the same coordinate reference system as this instance.
-
contains
public boolean contains(P p)
Checks whether thisEnvelopecontains the specifiesEnvelope.- Parameters:
p- thePoint- Returns:
- true iff this instance contains the specified
Point - Throws:
IllegalArgumentException- when the specifiedPointdoesn't have the same coordinate reference system as this instance.
-
intersects
public boolean intersects(Envelope<P> other)
Checks whether thisEnvelopeintersects the specifiesEnvelope.Two instances intersect when their set-theoretic intersection is non-empty.
- Parameters:
other- the otherEnvelope- Returns:
- true iff this instance intersects with the other
Envelope - Throws:
IllegalArgumentException- when the specifiedEnvelopedoesn't have the same coordinate reference system as this instance.
-
-