public class DefaultGeographicBoundingBox extends AbstractGeographicExtent implements GeographicBoundingBox
In addition to the standard properties, SIS provides the following methods:
setBounds(double, double, double, double)
for setting the extent from (λ,φ) values.setBounds(Envelope)
for setting the extent from the given envelope.setBounds(GeographicBoundingBox)
for setting the extent from an other bounding box.add(GeographicBoundingBox)
for expanding this extent to include an other bounding box.intersect(GeographicBoundingBox)
for the intersection between the two bounding boxes.org.apache.sis.geometry
package provides various Envelope
classes serving a simular purpose.
The main difference is that envelopes can be expressed in any Coordinate Reference System (for example using any map projection), may have any number of dimensions, axes may have
any direction (some maps are south-oriented)
and may use any units of measurement. By contrast, geographic bounding box are restricted to two-dimensional
geographic CRS with latitude and longitude in decimal degrees, inside the [-90 … +90]° and [-180 … +180]° range
respectively, increasing toward north and east respectively, and longitude measured from the international
reference meridian (Greenwich on Earth). However GeographicBoundingBox
said nothing about the
geodetic datum. Consequently this bounding
box should be used only as a convenient way to give an approximate description of a location.
Users can assume a precision of about 0.01° for the latitude and longitude values in this class.
If more precision is desired, an Envelope
should be considered instead.
XML
instead.GeneralEnvelope
,
Serialized FormDefined in the sis-metadata
module
identifiers, LOGGER
Constructor and Description |
---|
DefaultGeographicBoundingBox()
Constructs an initially empty geographic bounding box.
|
DefaultGeographicBoundingBox(double westBoundLongitude,
double eastBoundLongitude,
double southBoundLatitude,
double northBoundLatitude)
Creates a geographic bounding box initialized to the specified values.
|
DefaultGeographicBoundingBox(GeographicBoundingBox object)
Constructs a new instance initialized with the values from the specified metadata object.
|
Modifier and Type | Method and Description |
---|---|
void |
add(GeographicBoundingBox box)
Adds a geographic bounding box to this box.
|
static DefaultGeographicBoundingBox |
castOrCopy(GeographicBoundingBox object)
Returns a SIS metadata implementation with the values of the given arbitrary implementation.
|
boolean |
equals(Object object,
ComparisonMode mode)
Compares this geographic bounding box with the specified object for equality.
|
double |
getEastBoundLongitude()
Returns the eastern-most coordinate of the limit of the dataset extent.
|
double |
getNorthBoundLatitude()
Returns the northern-most, coordinate of the limit of the dataset extent.
|
double |
getSouthBoundLatitude()
Returns the southern-most coordinate of the limit of the dataset extent.
|
double |
getWestBoundLongitude()
Returns the western-most coordinate of the limit of the dataset extent.
|
void |
intersect(GeographicBoundingBox box)
Sets this bounding box to the intersection of this box with the specified one.
|
boolean |
isEmpty()
Returns
true if this metadata is empty. |
void |
setBounds(double westBoundLongitude,
double eastBoundLongitude,
double southBoundLatitude,
double northBoundLatitude)
Sets the bounding box to the specified values.
|
void |
setBounds(Envelope envelope)
Constructs a geographic bounding box from the specified envelope.
|
void |
setBounds(GeographicBoundingBox box)
Sets the bounding box to the same values than the specified box.
|
void |
setEastBoundLongitude(double newValue)
Sets the eastern-most coordinate of the limit of the dataset extent.
|
void |
setNorthBoundLatitude(double newValue)
Sets the northern-most, coordinate of the limit of the dataset extent.
|
void |
setSouthBoundLatitude(double newValue)
Sets the southern-most coordinate of the limit of the dataset extent.
|
void |
setWestBoundLongitude(double newValue)
Sets the western-most coordinate of the limit of the dataset extent.
|
castOrCopy, getInclusion, setInclusion
getIdentifierMap, getIdentifiers, getStandard
checkWritePermission, clone, collectionType, copyCollection, copyList, copySet, freeze, isModifiable, nonNullCollection, nonNullList, nonNullSet, singleton, unmodifiable, writeCollection, writeList, writeSet
asMap, asTreeTable, equals, getInterface, hashCode, prune, toString
getInclusion
public DefaultGeographicBoundingBox()
Double.NaN
.public DefaultGeographicBoundingBox(double westBoundLongitude, double eastBoundLongitude, double southBoundLatitude, double northBoundLatitude) throws IllegalArgumentException
true
.
Caution: Arguments are expected in the same order than they appear in the ISO 19115 specification. This is different than the order commonly found in the Java2D world, which is rather (xmin, ymin, xmax, ymax).
westBoundLongitude
- The minimal λ value.eastBoundLongitude
- The maximal λ value.southBoundLatitude
- The minimal φ value.northBoundLatitude
- The maximal φ value.IllegalArgumentException
- If (south bound > north bound).
Note that NaN values are allowed.setBounds(double, double, double, double)
public DefaultGeographicBoundingBox(GeographicBoundingBox object)
object
- The metadata to copy values from, or null
if none.castOrCopy(GeographicBoundingBox)
public static DefaultGeographicBoundingBox castOrCopy(GeographicBoundingBox object)
null
, then this method returns null
.DefaultGeographicBoundingBox
, then it is returned unchanged.DefaultGeographicBoundingBox
instance is created using the
copy constructor
and returned. Note that this is a shallow copy operation, since the other
metadata contained in the given object are not recursively copied.object
- The object to get as a SIS implementation, or null
if none.null
if the argument was null.@ValueRange(minimum=-180.0, maximum=180.0) public double getWestBoundLongitude()
Note that the returned value is greater than the east bound longitude if this box is spanning over the anti-meridian.
getWestBoundLongitude
in interface GeographicBoundingBox
public void setWestBoundLongitude(double newValue)
newValue
- The western-most longitude between -180° and +180° inclusive,
or NaN to undefine.@ValueRange(minimum=-180.0, maximum=180.0) public double getEastBoundLongitude()
Note that the returned value is smaller than the west bound longitude if this box is spanning over the anti-meridian.
getEastBoundLongitude
in interface GeographicBoundingBox
public void setEastBoundLongitude(double newValue)
newValue
- The eastern-most longitude between -180° and +180° inclusive,
or NaN to undefine.@ValueRange(minimum=-90.0, maximum=90.0) public double getSouthBoundLatitude()
getSouthBoundLatitude
in interface GeographicBoundingBox
public void setSouthBoundLatitude(double newValue)
Double.NaN
.newValue
- The southern-most latitude between -90° and +90° inclusive,
or NaN to undefine.@ValueRange(minimum=-90.0, maximum=90.0) public double getNorthBoundLatitude()
getNorthBoundLatitude
in interface GeographicBoundingBox
public void setNorthBoundLatitude(double newValue)
Double.NaN
.newValue
- The northern-most latitude between -90° and +90° inclusive,
or NaN to undefine.public void setBounds(double westBoundLongitude, double eastBoundLongitude, double southBoundLatitude, double northBoundLatitude) throws IllegalArgumentException
Caution: Arguments are expected in the same order than they appear in the ISO 19115 specification. This is different than the order commonly found in the Java2D world, which is rather (xmin, ymin, xmax, ymax).
westBoundLongitude
- The minimal λ value.eastBoundLongitude
- The maximal λ value.southBoundLatitude
- The minimal φ value.northBoundLatitude
- The maximal φ value.IllegalArgumentException
- If (south bound > north bound).
Note that NaN values are allowed.public void setBounds(Envelope envelope) throws TransformException
When coordinate transformation is required, the target geographic CRS is not necessarily WGS84. This method preserves the same ellipsoid than in the envelope CRS when possible. This is because geographic bounding box are only approximative and the ISO specification do not mandates a particular CRS, so we avoid transformations that are not strictly necessary.
Note: this method is available only if the referencing module is on the classpath.
envelope
- The envelope to use for setting this geographic bounding box.UnsupportedOperationException
- if the referencing module is not on the classpath.TransformException
- if the envelope can not be transformed to a geographic extent.DefaultExtent.addElements(Envelope)
,
DefaultVerticalExtent.setBounds(Envelope)
,
DefaultTemporalExtent.setBounds(Envelope)
public void setBounds(GeographicBoundingBox box)
box
- The geographic bounding box to use for setting the values of this box.public void add(GeographicBoundingBox box)
GeneralEnvelope
.
The reason is that computations on GeographicBoundingBox
instances are rare (Envelope
instances
are preferred for this purpose). Usually, GeographicBoundingBox
values come directly from some metadata
structure. Consequently NaN values in GeographicBoundingBox
means "information is unknown"
more often than "not yet calculated".box
- The geographic bounding box to add to this box.GeneralEnvelope.add(Envelope)
public void intersect(GeographicBoundingBox box) throws IllegalArgumentException
If there is no intersection between the two bounding boxes, then this method sets both longitudes and/or both latitudes to NaN. If either this box or the specified box has NaN bounds, then the corresponding bounds of the intersection result will bet set to NaN.
box
- The geographic bounding box to intersect with this box.IllegalArgumentException
- If the inclusion status is not the same for both boxes.Extents.intersection(GeographicBoundingBox, GeographicBoundingBox)
,
GeneralEnvelope.intersect(Envelope)
public boolean isEmpty()
true
if this metadata is empty. This metadata is considered empty if
every bound values are NaN. Note that this is different than
the Java2D or envelope definition of "emptiness", since we
don't test if the area is greater than zero - this method is a metadata test, not a
geometric test.isEmpty
in interface Emptiable
isEmpty
in class AbstractMetadata
true
if this metadata does not define any bound value.AbstractEnvelope.isAllNaN()
public boolean equals(Object object, ComparisonMode mode)
equals
in interface LenientComparable
equals
in class AbstractMetadata
object
- The object to compare for equality.mode
- The strictness level of the comparison.true
if the given object is equal to this box.Utilities.deepEquals(Object, Object, ComparisonMode)
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.