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 classASimpleLocationfor non-geographic CRS. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleThe easternmost bound of the envelope, orNaNif not yet computed.protected doubleThe northernmost bound of the envelope, orNaNif not yet computed.protected doubleThe westernmost bound of the envelope, orNaNif not yet computed.protected doubleThe southernmost bound of the envelope, orNaNif 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 voidconvert(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.CoordinateReferenceSystemReturns the coordinate reference system the envelope and the position.final intReturns the number of dimensions, which is fixed to 2.final org.opengis.geometry.DirectPositionReturns the direct position, which is itself.doubleReturns the easternmost longitude in degrees.final org.opengis.geometry.EnvelopeReturns an envelope that encompass the location.org.opengis.metadata.extent.GeographicExtentReturns a description of the location instance.final BooleanIndication 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.DirectPositionReturns a copy of the lower-left corner.final doublegetMaximum(int dimension) Returns the maximal coordinate value for the specified dimension.final doublegetMedian(int dimension) Returns the median coordinate value for the specified dimension.final doublegetMinimum(int dimension) Returns the minimal coordinate value for the specified dimension.doubleReturns the northernmost latitude in degrees.final doublegetOrdinate(int dimension) Returns the centroid coordinate value for the specified dimension.final org.opengis.geometry.coordinate.PositionReturns coordinates of a centroid point for the location instance.doubleReturns the southernmost latitude in degrees.final doublegetSpan(int dimension) Returns the envelope width or height along the specified dimension.final org.opengis.geometry.DirectPositionReturns a copy of the upper-right corner.doubleReturns the westernmost longitude in degrees.private static StringindexOutOfBounds(int dimension) Returns the error message for an index out of bounds.final voidsetOrdinate(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, typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.geometry.DirectPosition
equals, hashCode
-
Field Details
-
minX
protected double minXThe westernmost bound of the envelope, orNaNif not yet computed.- See Also:
-
minY
protected double minYThe southernmost bound of the envelope, orNaNif not yet computed.- See Also:
-
maxX
protected double maxXThe easternmost bound of the envelope, orNaNif not yet computed.- See Also:
-
maxY
protected double maxYThe northernmost bound of the envelope, orNaNif not yet computed.- See Also:
-
-
Constructor Details
-
SimpleLocation
SimpleLocation(AbstractLocationType type, CharSequence identifier) Creates a new location for the given geographic identifier. This constructor acceptsnullarguments, 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:
getGeographicExtentin classAbstractLocation- Returns:
- description of the location instance, or
nullif 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:
getEnvelopein classAbstractLocation- Returns:
- envelope that encompass the location, or
nullif 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:
getPositionin classAbstractLocation- Returns:
- coordinates of a representative point for the location instance, or
nullif none.
-
getDirectPosition
public final org.opengis.geometry.DirectPosition getDirectPosition()Returns the direct position, which is itself.- Specified by:
getDirectPositionin 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:
getCoordinateReferenceSystemin interfaceorg.opengis.geometry.DirectPosition- Specified by:
getCoordinateReferenceSystemin interfaceorg.opengis.geometry.Envelope
-
getDimension
public final int getDimension()Returns the number of dimensions, which is fixed to 2.- Specified by:
getDimensionin interfaceorg.opengis.geometry.DirectPosition- Specified by:
getDimensionin interfaceorg.opengis.geometry.Envelope
-
getCoordinate
public final double[] getCoordinate()Returns the coordinates of the centroid.- Specified by:
getCoordinatein interfaceorg.opengis.geometry.DirectPosition
-
getOrdinate
public final double getOrdinate(int dimension) Returns the centroid coordinate value for the specified dimension.- Specified by:
getOrdinatein interfaceorg.opengis.geometry.DirectPosition
-
getMinimum
public final double getMinimum(int dimension) Returns the minimal coordinate value for the specified dimension.- Specified by:
getMinimumin interfaceorg.opengis.geometry.Envelope
-
getMaximum
public final double getMaximum(int dimension) Returns the maximal coordinate value for the specified dimension.- Specified by:
getMaximumin interfaceorg.opengis.geometry.Envelope
-
getMedian
public final double getMedian(int dimension) Returns the median coordinate value for the specified dimension.- Specified by:
getMedianin interfaceorg.opengis.geometry.Envelope
-
getSpan
public final double getSpan(int dimension) Returns the envelope width or height along the specified dimension.- Specified by:
getSpanin 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:
getLowerCornerin interfaceorg.opengis.geometry.Envelope
-
getUpperCorner
public final org.opengis.geometry.DirectPosition getUpperCorner()Returns a copy of the upper-right corner.- Specified by:
getUpperCornerin interfaceorg.opengis.geometry.Envelope
-
setOrdinate
public final void setOrdinate(int dimension, double value) Do not allow modification of the direct position.- Specified by:
setOrdinatein 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:
getInclusionin 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:
getWestBoundLongitudein 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:
getEastBoundLongitudein 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:
getSouthBoundLatitudein 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:
getNorthBoundLatitudein 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.
-