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 Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    A SimpleLocation for non-geographic CRS.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The easternmost bound of the envelope, or NaN if not yet computed.
    protected double
    The northernmost bound of the envelope, or NaN if not yet computed.
    protected double
    The westernmost bound of the envelope, or NaN if not yet computed.
    protected double
    The southernmost bound of the envelope, or NaN if not yet computed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new location for the given geographic identifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    (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 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

  • Constructor Details

    • SimpleLocation

      SimpleLocation(AbstractLocationType type, CharSequence identifier)
      Creates a new location for the given geographic identifier. This constructor accepts null arguments, but this is not recommended.
      Parameters:
      type - the description of the nature of this geographic identifier.
      identifier - the geographic identifier to be returned by AbstractLocation.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 class AbstractLocation
      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 class AbstractLocation
      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 class AbstractLocation
      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 interface org.opengis.geometry.coordinate.Position
    • getCoordinateReferenceSystem

      public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns the coordinate reference system the envelope and the position. Default implementation returns CommonCRS.defaultGeographic(). Subclasses must override this method if they use another CRS.
      Specified by:
      getCoordinateReferenceSystem in interface org.opengis.geometry.DirectPosition
      Specified by:
      getCoordinateReferenceSystem in interface org.opengis.geometry.Envelope
    • getDimension

      public final int getDimension()
      Returns the number of dimensions, which is fixed to 2.
      Specified by:
      getDimension in interface org.opengis.geometry.DirectPosition
      Specified by:
      getDimension in interface org.opengis.geometry.Envelope
    • getCoordinate

      public final double[] getCoordinate()
      Returns the coordinates of the centroid.
      Specified by:
      getCoordinate in interface org.opengis.geometry.DirectPosition
    • getOrdinate

      public final double getOrdinate(int dimension)
      Returns the centroid coordinate value for the specified dimension.
      Specified by:
      getOrdinate in interface org.opengis.geometry.DirectPosition
    • getMinimum

      public final double getMinimum(int dimension)
      Returns the minimal coordinate value for the specified dimension.
      Specified by:
      getMinimum in interface org.opengis.geometry.Envelope
    • getMaximum

      public final double getMaximum(int dimension)
      Returns the maximal coordinate value for the specified dimension.
      Specified by:
      getMaximum in interface org.opengis.geometry.Envelope
    • getMedian

      public final double getMedian(int dimension)
      Returns the median coordinate value for the specified dimension.
      Specified by:
      getMedian in interface org.opengis.geometry.Envelope
    • getSpan

      public final double getSpan(int dimension)
      Returns the envelope width or height along the specified dimension.
      Specified by:
      getSpan in interface org.opengis.geometry.Envelope
    • indexOutOfBounds

      private static String indexOutOfBounds(int dimension)
      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 interface org.opengis.geometry.Envelope
    • getUpperCorner

      public final org.opengis.geometry.DirectPosition getUpperCorner()
      Returns a copy of the upper-right corner.
      Specified by:
      getUpperCorner in interface org.opengis.geometry.Envelope
    • setOrdinate

      public final void setOrdinate(int dimension, double value)
      Do not allow modification of the direct position.
      Specified by:
      setOrdinate in interface org.opengis.geometry.DirectPosition
    • getInclusion

      public final Boolean 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 to true.
      Specified by:
      getInclusion in interface org.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 interface org.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 interface org.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 interface org.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 interface org.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.