Class AbstractLocation

java.lang.Object
org.apache.sis.referencing.gazetteer.AbstractLocation
Direct Known Subclasses:
SimpleLocation

public abstract class AbstractLocation extends Object
Identifiable geographic place. A geographic place may be identified by a name (for example “Eiffel Tower”), by a postcode, or any other method specified by the location type identifications.

ISO 19112 describes the following properties as mandatory, but Apache SIS relaxes this restriction by providing default values (possibly null) in most cases:

  • geographic identifier (the value, for example a name or code)
  • geographic extent (the position of the identified thing)
  • administrator (who is responsible for this identifier)
  • location type (which specifies the nature of the identifier and its associated geographic location)
The following properties are optional:
  • temporal extent
  • alternative geographic identifier
  • envelope (an Apache SIS extension not in ISO 19112 standard)
  • position (mandatory if the geographic identifier contains insufficient information to identify location)
  • parent location instance
  • child location instance
Since:
0.8
Version:
0.8
See Also:
  • Field Details

    • type

      private AbstractLocationType type
      The description of the nature of this geographic identifier, or null if unspecified.

      This field is non-final for sub-class constructors convenience, but its value should not be changed after Location construction.

      See Also:
    • identifier

      private final CharSequence identifier
      The geographic identifier, or null if unspecified.
      See Also:
  • Constructor Details

    • AbstractLocation

      protected AbstractLocation(ModifiableLocationType type, CharSequence identifier)
      Creates a new location for the given geographic identifier. This constructor accepts null arguments, but this is not recommended.
      Upcoming API change — generalization
      in a future SIS version, the type of type argument may be generalized to the org.opengis.referencing.gazetteer.Location interface. This change is pending GeoAPI revision.
      Parameters:
      type - the description of the nature of this geographic identifier.
      identifier - the geographic identifier to be returned by getGeographicIdentifier().
    • AbstractLocation

      AbstractLocation(AbstractLocationType type, CharSequence identifier)
      Temporary workaround for the lack of LocationType interface and AbstractLocationType being package-private. We do not want to expose AbstractLocationType in public API for now.
  • Method Details

    • setTypeToChild

      final void setTypeToChild()
      Sets the location type to the unique child of current type. This method should be invoked only when the caller know that there is at least one children and that the children class is FinalLocationType (for performance reason).
    • getGeographicIdentifier

      public org.opengis.util.InternationalString getGeographicIdentifier()
      Returns a unique identifier for the location instance. The methods of identifying locations is specified by the location type identifications.
      Examples: if LocationType.getIdentifications() contain “name”, then geographic identifiers may be country names like “Japan” or “France”, or places like “Eiffel Tower”. If location type identifications contain “code”, then geographic identifiers may be “SW1P 3AD” postcode.
      In order to ensure that a geographic identifier is unique within a wider geographic domain, the geographic identifier may need to include an identifier of an instance of a parent location type, for example “Paris, Texas”.
      Returns:
      unique identifier for the location instance.
      See Also:
    • getAlternativeGeographicIdentifiers

      public Collection<? extends org.opengis.util.InternationalString> getAlternativeGeographicIdentifiers()
      Returns other identifier(s) for the location instance. The default implementation returns an empty set.
      Returns:
      other identifier(s) for the location instance, or an empty collection if none.
    • getTemporalExtent

      public org.opengis.metadata.extent.TemporalExtent getTemporalExtent()
      Returns the date of creation of this version of the location instance. The default implementation returns null.
      Returns:
      date of creation of this version of the location instance, or null if none.
    • getGeographicExtent

      public org.opengis.metadata.extent.GeographicExtent getGeographicExtent()
      Returns a description of the location instance. This properties is mandatory according ISO 19112, but Apache SIS nevertheless allows null value. If non-null, SIS implementations typically provide instances of geographic bounding boxes.
      Returns:
      description of the location instance, or null if none.
      See Also:
    • getEnvelope

      public org.opengis.geometry.Envelope getEnvelope()
      Returns an envelope that encompass the location. This property is partially redundant with getGeographicExtent(), except that this method allows envelopes in non-geographic CRS.

      The default implementation copies the getGeographicExtent() in a new envelope associated to the default geographic CRS.

      Returns:
      envelope that encompass the location, or null if none.
    • getPosition

      public org.opengis.geometry.coordinate.Position getPosition()
      Returns coordinates of a representative point for the location instance. This is typically (but not necessarily) the centroid of the location instance.

      The default implementation returns the getEnvelope() median position.

      Returns:
      coordinates of a representative point for the location instance, or null if none.
    • getLocationType

      public final ModifiableLocationType getLocationType()
      Returns a description of the nature of this geographic identifier.
      Upcoming API change — generalization
      in a future SIS version, the type of returned element may be generalized to the org.opengis.referencing.gazetteer.Location interface. This change is pending GeoAPI revision. If applied, this method will be made non-final.
      Returns:
      the nature of the identifier and its associated geographic location.
    • type

      final AbstractLocationType type()
      Workaround for the lack of LocationType interface in GeoAPI 3.0. This workaround will be removed in a future SIS version if the location type interface is introduced in a future GeoAPI version.
    • getAdministrator

      public AbstractParty getAdministrator()
      Returns the organization responsible for defining the characteristics of the location instance. The default implementation returns the owner.
      Upcoming API change — generalization
      in a future SIS version, the type of returned element may be generalized to the org.opengis.metadata.citation.Party interface. This change is pending GeoAPI revision for upgrade from ISO 19115:2003 to ISO 19115:2014.
      Returns:
      organization responsible for defining the characteristics of the location instance, or null.
      See Also:
    • getParents

      public Collection<? extends AbstractLocation> getParents()
      Returns location instances of a different location type, for which this location instance is a sub-division. The default implementation returns an empty list.
      Upcoming API change — generalization
      in a future SIS version, the type of collection elements may be generalized to the org.opengis.referencing.gazetteer.Location interface. This change is pending GeoAPI revision.
      Returns:
      parent locations, or an empty collection if none.
      See Also:
    • getChildren

      public Collection<? extends AbstractLocation> getChildren()
      Returns location instances of a different location type which subdivides this location instance. The default implementation returns an empty list.
      Upcoming API change — generalization
      in a future SIS version, the type of collection elements may be generalized to the org.opengis.referencing.gazetteer.Location interface. This change is pending GeoAPI revision.
      Returns:
      child locations, or an empty collection if none.
      See Also:
    • toString

      public String toString()
      Returns a string representation of this location. This representation is mostly for debugging purpose and may change in any future Apache SIS version.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this location for debugging purpose.