Class SimpleLocation
java.lang.Object
org.apache.sis.referencing.gazetteer.AbstractLocation
org.apache.sis.referencing.gazetteer.SimpleLocation
- All Implemented Interfaces:
org.opengis.geometry.coordinate.Position
,org.opengis.geometry.DirectPosition
,org.opengis.geometry.Envelope
,org.opengis.metadata.extent.GeographicBoundingBox
,org.opengis.metadata.extent.GeographicExtent
- Direct Known Subclasses:
GeohashReferenceSystem.Decoder
,SimpleLocation.Projected
class SimpleLocation
extends AbstractLocation
implements org.opengis.geometry.DirectPosition, org.opengis.geometry.Envelope, org.opengis.metadata.extent.GeographicBoundingBox
A location described by an unmodifiable direct position that defines the centroid of an envelope.
This class encompasses most information in a single object, which make it lightweight to create
(less pressure on the garbage collector). However, this is not a clear separation of responsibility,
so this class should not be in public API.
Subclasses must override the following methods if the above coordinate reference system is not a geographic CRS with (longitude, latitude) axes in degrees:
- Since:
- 0.8
- Version:
- 0.8
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
ASimpleLocation
for non-geographic CRS. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
The easternmost bound of the envelope, orNaN
if not yet computed.protected double
The northernmost bound of the envelope, orNaN
if not yet computed.protected double
The westernmost bound of the envelope, orNaN
if not yet computed.protected double
The southernmost bound of the envelope, orNaN
if not yet computed. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleLocation
(AbstractLocationType type, CharSequence identifier) Creates a new location for the given geographic identifier. -
Method Summary
Modifier and TypeMethodDescription(package private) final void
convert
(org.opengis.referencing.operation.MathTransform mt, double[] buffer) Converts the current envelope using the given math transform.final double[]
Returns the coordinates of the centroid.org.opengis.referencing.crs.CoordinateReferenceSystem
Returns the coordinate reference system the envelope and the position.final int
Returns the number of dimensions, which is fixed to 2.final org.opengis.geometry.DirectPosition
Returns the direct position, which is itself.double
Returns the easternmost longitude in degrees.final org.opengis.geometry.Envelope
Returns an envelope that encompass the location.org.opengis.metadata.extent.GeographicExtent
Returns a description of the location instance.final Boolean
Indication of whether the bounding polygon encompasses an area covered by the data (inclusion) or an area where data is not present (exclusion).final org.opengis.geometry.DirectPosition
Returns a copy of the lower-left corner.final double
getMaximum
(int dimension) Returns the maximal coordinate value for the specified dimension.final double
getMedian
(int dimension) Returns the median coordinate value for the specified dimension.final double
getMinimum
(int dimension) Returns the minimal coordinate value for the specified dimension.double
Returns the northernmost latitude in degrees.final double
getOrdinate
(int dimension) Returns the centroid coordinate value for the specified dimension.final org.opengis.geometry.coordinate.Position
Returns coordinates of a centroid point for the location instance.double
Returns the southernmost latitude in degrees.final double
getSpan
(int dimension) Returns the envelope width or height along the specified dimension.final org.opengis.geometry.DirectPosition
Returns a copy of the upper-right corner.double
Returns the westernmost longitude in degrees.private static String
indexOutOfBounds
(int dimension) Returns the error message for an index out of bounds.final void
setOrdinate
(int dimension, double value) Do not allow modification of the direct position.Methods inherited from class org.apache.sis.referencing.gazetteer.AbstractLocation
getAdministrator, getAlternativeGeographicIdentifiers, getChildren, getGeographicIdentifier, getLocationType, getParents, getTemporalExtent, setTypeToChild, toString, type
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.geometry.DirectPosition
equals, hashCode
-
Field Details
-
minX
protected double minXThe westernmost bound of the envelope, orNaN
if not yet computed.- See Also:
-
minY
protected double minYThe southernmost bound of the envelope, orNaN
if not yet computed.- See Also:
-
maxX
protected double maxXThe easternmost bound of the envelope, orNaN
if not yet computed.- See Also:
-
maxY
protected double maxYThe northernmost bound of the envelope, orNaN
if not yet computed.- See Also:
-
-
Constructor Details
-
SimpleLocation
SimpleLocation(AbstractLocationType type, CharSequence identifier) Creates a new location for the given geographic identifier. This constructor acceptsnull
arguments, but this is not recommended.- Parameters:
type
- the description of the nature of this geographic identifier.identifier
- the geographic identifier to be returned byAbstractLocation.getGeographicIdentifier()
.
-
-
Method Details
-
getGeographicExtent
public org.opengis.metadata.extent.GeographicExtent getGeographicExtent()Returns a description of the location instance. In this simple implementation, this instance is its own geographic extent.- Overrides:
getGeographicExtent
in classAbstractLocation
- Returns:
- description of the location instance, or
null
if none. - See Also:
-
getEnvelope
public final org.opengis.geometry.Envelope getEnvelope()Returns an envelope that encompass the location. In this simple implementation, this instance is its own envelope.- Overrides:
getEnvelope
in classAbstractLocation
- Returns:
- envelope that encompass the location, or
null
if none.
-
getPosition
public final org.opengis.geometry.coordinate.Position getPosition()Returns coordinates of a centroid point for the location instance. In this simple implementation, this instance is its own centroid coordinate.- Overrides:
getPosition
in classAbstractLocation
- Returns:
- coordinates of a representative point for the location instance, or
null
if none.
-
getDirectPosition
public final org.opengis.geometry.DirectPosition getDirectPosition()Returns the direct position, which is itself.- Specified by:
getDirectPosition
in interfaceorg.opengis.geometry.coordinate.Position
-
getCoordinateReferenceSystem
public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()Returns the coordinate reference system the envelope and the position. Default implementation returnsCommonCRS.defaultGeographic()
. Subclasses must override this method if they use another CRS.- Specified by:
getCoordinateReferenceSystem
in interfaceorg.opengis.geometry.DirectPosition
- Specified by:
getCoordinateReferenceSystem
in interfaceorg.opengis.geometry.Envelope
-
getDimension
public final int getDimension()Returns the number of dimensions, which is fixed to 2.- Specified by:
getDimension
in interfaceorg.opengis.geometry.DirectPosition
- Specified by:
getDimension
in interfaceorg.opengis.geometry.Envelope
-
getCoordinate
public final double[] getCoordinate()Returns the coordinates of the centroid.- Specified by:
getCoordinate
in interfaceorg.opengis.geometry.DirectPosition
-
getOrdinate
public final double getOrdinate(int dimension) Returns the centroid coordinate value for the specified dimension.- Specified by:
getOrdinate
in interfaceorg.opengis.geometry.DirectPosition
-
getMinimum
public final double getMinimum(int dimension) Returns the minimal coordinate value for the specified dimension.- Specified by:
getMinimum
in interfaceorg.opengis.geometry.Envelope
-
getMaximum
public final double getMaximum(int dimension) Returns the maximal coordinate value for the specified dimension.- Specified by:
getMaximum
in interfaceorg.opengis.geometry.Envelope
-
getMedian
public final double getMedian(int dimension) Returns the median coordinate value for the specified dimension.- Specified by:
getMedian
in interfaceorg.opengis.geometry.Envelope
-
getSpan
public final double getSpan(int dimension) Returns the envelope width or height along the specified dimension.- Specified by:
getSpan
in interfaceorg.opengis.geometry.Envelope
-
indexOutOfBounds
Returns the error message for an index out of bounds. -
getLowerCorner
public final org.opengis.geometry.DirectPosition getLowerCorner()Returns a copy of the lower-left corner.- Specified by:
getLowerCorner
in interfaceorg.opengis.geometry.Envelope
-
getUpperCorner
public final org.opengis.geometry.DirectPosition getUpperCorner()Returns a copy of the upper-right corner.- Specified by:
getUpperCorner
in interfaceorg.opengis.geometry.Envelope
-
setOrdinate
public final void setOrdinate(int dimension, double value) Do not allow modification of the direct position.- Specified by:
setOrdinate
in interfaceorg.opengis.geometry.DirectPosition
-
getInclusion
Indication of whether the bounding polygon encompasses an area covered by the data (inclusion) or an area where data is not present (exclusion). The value is fixed totrue
.- Specified by:
getInclusion
in interfaceorg.opengis.metadata.extent.GeographicExtent
-
getWestBoundLongitude
public double getWestBoundLongitude()Returns the westernmost longitude in degrees. Default implementation assumes that the coordinate reference system is geographic with (longitude, latitude) axes in degrees. Subclasses must override if this is not the case.- Specified by:
getWestBoundLongitude
in interfaceorg.opengis.metadata.extent.GeographicBoundingBox
-
getEastBoundLongitude
public double getEastBoundLongitude()Returns the easternmost longitude in degrees. Default implementation assumes that the coordinate reference system is geographic with (longitude, latitude) axes in degrees. Subclasses must override if this is not the case.- Specified by:
getEastBoundLongitude
in interfaceorg.opengis.metadata.extent.GeographicBoundingBox
-
getSouthBoundLatitude
public double getSouthBoundLatitude()Returns the southernmost latitude in degrees. Default implementation assumes that the coordinate reference system is geographic with (longitude, latitude) axes in degrees. Subclasses must override if this is not the case.- Specified by:
getSouthBoundLatitude
in interfaceorg.opengis.metadata.extent.GeographicBoundingBox
-
getNorthBoundLatitude
public double getNorthBoundLatitude()Returns the northernmost latitude in degrees. Default implementation assumes that the coordinate reference system is geographic with (longitude, latitude) axes in degrees. Subclasses must override if this is not the case.- Specified by:
getNorthBoundLatitude
in interfaceorg.opengis.metadata.extent.GeographicBoundingBox
-
convert
final void convert(org.opengis.referencing.operation.MathTransform mt, double[] buffer) throws org.opengis.referencing.operation.TransformException Converts the current envelope using the given math transform. The given transform usually performs nothing more than axis swapping or unit conversions.- Parameters:
mt
- the math transform to use for conversion.buffer
- a temporary buffer of length 8 or more.- Throws:
org.opengis.referencing.operation.TransformException
- if an error occurred while converting the points.
-