Package org.apache.sis.geometry
Class ImmutableEnvelope
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.geometry.AbstractEnvelope
org.apache.sis.geometry.ArrayEnvelope
org.apache.sis.geometry.ImmutableEnvelope
- All Implemented Interfaces:
Serializable
,Emptiable
,org.opengis.geometry.Envelope
An immutable
Envelope
(a minimum bounding box or rectangle) of arbitrary dimension.
This class is final in order to ensure that the immutability contract cannot be broken
(assuming not using Java Native Interface or reflections).
Immutability and thread safety
This final class is immutable and thus inherently thread-safe if theCoordinateReferenceSystem
instance given to the constructor is immutable. This is usually the case in Apache SIS.- Since:
- 0.3
- Version:
- 0.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.geometry.ArrayEnvelope
coordinates, crs
-
Constructor Summary
ConstructorsConstructorDescriptionImmutableEnvelope
(double[] lowerCorner, double[] upperCorner, org.opengis.referencing.crs.CoordinateReferenceSystem crs) Constructs an envelope defined by two corners given as sequences of coordinate values.ImmutableEnvelope
(org.opengis.geometry.DirectPosition lowerCorner, org.opengis.geometry.DirectPosition upperCorner) Constructs an envelope defined by two corners given as direct positions.ImmutableEnvelope
(org.opengis.geometry.Envelope envelope) Creates an immutable envelope with the values of the given envelope.ImmutableEnvelope
(org.opengis.metadata.extent.GeographicBoundingBox box) Constructs a new envelope with the same data than the specified geographic bounding box.ImmutableEnvelope
(org.opengis.referencing.crs.CoordinateReferenceSystem crs, CharSequence wkt) Constructs a new envelope initialized to the values parsed from the given string inBOX
or Well Known Text (WKT) format.ImmutableEnvelope
(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.geometry.Envelope envelope) Creates an immutable envelope with the coordinate values of the given envelope but a different CRS. -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableEnvelope
castOrCopy
(org.opengis.geometry.Envelope envelope) Returns the given envelope as anImmutableEnvelope
instance.Methods inherited from class org.apache.sis.geometry.ArrayEnvelope
beginIndex, endIndex, ensureSameDimension, equals, equalsByAPI, getCoordinateReferenceSystem, getDimension, getLower, getMaximum, getMedian, getMinimum, getSpan, getUpper, hashCode, hashCodeByAPI, illegalRange, isAllNaN, isEmpty, toString, verifyRanges
Methods inherited from class org.apache.sis.geometry.AbstractEnvelope
assertEquals, contains, contains, contains, equals, fixMedian, fixSpan, formatTo, getAxis, getCommonCRS, getCycle, getLowerCorner, getMedian, getSpan, getTimeRange, getUpperCorner, hasNaN, hasNaN, intersects, intersects, isNegativeUnsafe, isWrapAround, isWrapAround, setRange, toSimpleEnvelopes, toString
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
-
Constructor Details
-
ImmutableEnvelope
public ImmutableEnvelope(org.opengis.geometry.DirectPosition lowerCorner, org.opengis.geometry.DirectPosition upperCorner) throws org.opengis.geometry.MismatchedDimensionException, MismatchedReferenceSystemException Constructs an envelope defined by two corners given as direct positions. The envelope CRS will be the CRS of the given positions.- Parameters:
lowerCorner
- the limits in the direction of decreasing coordinate values for each dimension.upperCorner
- the limits in the direction of increasing coordinate values for each dimension.- Throws:
org.opengis.geometry.MismatchedDimensionException
- if the two positions do not have the same dimension.MismatchedReferenceSystemException
- if the CRS of the two position are not equal.
-
ImmutableEnvelope
public ImmutableEnvelope(double[] lowerCorner, double[] upperCorner, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws org.opengis.geometry.MismatchedDimensionException Constructs an envelope defined by two corners given as sequences of coordinate values.- Parameters:
lowerCorner
- the limits in the direction of decreasing coordinate values for each dimension.upperCorner
- the limits in the direction of increasing coordinate values for each dimension.crs
- the CRS to assign to this envelope, ornull
.- Throws:
org.opengis.geometry.MismatchedDimensionException
- if the two sequences do not have the same length, or if the dimension of the given CRS is not equals to the dimension of the given corners.
-
ImmutableEnvelope
public ImmutableEnvelope(org.opengis.metadata.extent.GeographicBoundingBox box) Constructs a new envelope with the same data than the specified geographic bounding box. The coordinate reference system is set to the default geographic CRS. Axis order is (longitude, latitude).- Parameters:
box
- the bounding box to copy.
-
ImmutableEnvelope
public ImmutableEnvelope(org.opengis.geometry.Envelope envelope) Creates an immutable envelope with the values of the given envelope. This constructor can be used when the given envelope is known to not be an instance ofImmutableEnvelope
. In case of doubt, consider usingcastOrCopy(Envelope)
instead.- Parameters:
envelope
- the envelope to copy.- See Also:
-
ImmutableEnvelope
public ImmutableEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs, org.opengis.geometry.Envelope envelope) throws org.opengis.geometry.MismatchedDimensionException Creates an immutable envelope with the coordinate values of the given envelope but a different CRS. This method does not reproject the given envelope. It just assign the given CRS to this envelope without any check, except for the CRS dimension.The main purpose of this method is to assign a non-null CRS when the envelope to copy has a null CRS.
- Parameters:
crs
- the CRS to assign to this envelope, ornull
.envelope
- the envelope from which to copy coordinate values.- Throws:
org.opengis.geometry.MismatchedDimensionException
- if the dimension of the given CRS is not equals to the dimension of the given envelope.
-
ImmutableEnvelope
public ImmutableEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs, CharSequence wkt) throws IllegalArgumentException, org.opengis.geometry.MismatchedDimensionException Constructs a new envelope initialized to the values parsed from the given string inBOX
or Well Known Text (WKT) format. The given string is typically aBOX
element like below: However, this constructor is lenient to other geometry types likePOLYGON
. See the javadoc of theGeneralEnvelope
constructor for more information.- Parameters:
crs
- the coordinate reference system, ornull
if none.wkt
- theBOX
,POLYGON
or other kind of element to parse.- Throws:
IllegalArgumentException
- if the given string cannot be parsed.org.opengis.geometry.MismatchedDimensionException
- if the dimension of the given CRS is not equals to the dimension of the parsed envelope.
-
-
Method Details
-
castOrCopy
Returns the given envelope as anImmutableEnvelope
instance. If the given envelope is already an instance ofImmutableEnvelope
, then it is returned unchanged. Otherwise the coordinate values and the CRS of the given envelope are copied in a new envelope.- Parameters:
envelope
- the envelope to cast, ornull
.- Returns:
- the values of the given envelope as an
ImmutableEnvelope
instance. - See Also:
-