Class ModifiableLocationType

java.lang.Object
org.apache.sis.referencing.gazetteer.AbstractLocationType
org.apache.sis.referencing.gazetteer.ModifiableLocationType
All Implemented Interfaces:
LenientComparable
Direct Known Subclasses:
ModifiableLocationTypeAdapter

public class ModifiableLocationType extends AbstractLocationType
Helper class for building the description of a location. Temporary instances of this class can be used during the construction of spatial reference systems using geographic identifiers. Since ModifiableLocationType instances are modifiable, they should not be published directly. Instead, unmodifiable snapshots should be published. The same ModifiableLocationType instance can be used for many snapshots.
Example: the following code creates 3 levels of location types: administrative areas, which contain towns, which themselves contain streets. Note that the street location type has two parents, town and area, because a street can be outside any town and directly under the authority of an administrative area instead. A string representation of the area location type is as below:

Inheritance of property values

According ISO 19112:2003, all properties except the collection of parents and children are mandatory. Those mandatory properties are the name, theme, identifications, definition, territory of use and owner. However, in Apache SIS implementation, only the name is truly mandatory; SIS is tolerant to missing value for all other properties. But in the hope to improve ISO compliance, values of undefined properties are inherited from the parents (if any) provided that all parents define the same values.
Example: if an administrative area is in some territory of use, then all children of the administrative area (namely towns and streets) can reasonably presumed to be in the same territory of use. That territory can be specified only once as below: Then, the towns and streets automatically inherit the same value for that property, unless they are explicitly given another value.

Limitation

This class is not serializable and is not thread-safe. For thread safety or for serialization, a snapshots of this location type should be taken.
Since:
0.8
Version:
0.8
See Also:
  • Field Details

    • name

      private final org.opengis.util.InternationalString name
      Name of the location type.
    • theme

      private org.opengis.util.InternationalString theme
      Property used as the defining characteristic of the location type.
    • identifications

      private final Map<String,org.opengis.util.InternationalString> identifications
      Method(s) of uniquely identifying location instances.
    • definition

      private org.opengis.util.InternationalString definition
      The way in which location instances are defined.
    • territoryOfUse

      private org.opengis.metadata.extent.GeographicExtent territoryOfUse
      Geographic area within which the location type occurs.
    • owner

      private AbstractParty owner
      Name of organization or class of organization able to create and destroy location instances.
    • parents

      private final Map<String,ModifiableLocationType> parents
      Parent location types (location types of which this location type is a sub-division).
    • children

      private final Map<String,ModifiableLocationType> children
      Child location types (location types which sub-divides this location type).
  • Constructor Details

    • ModifiableLocationType

      public ModifiableLocationType(CharSequence name)
      Creates a new location type of the given name.
      Parameters:
      name - the location type name.
  • Method Details

    • getName

      public org.opengis.util.InternationalString getName()
      Returns the name of the location type. This name is specified at construction time and cannot be changed.
      Examples: “administrative area”, “town”, “locality”, “street”, “property”.
      Specified by:
      getName in class AbstractLocationType
      Returns:
      name of the location type.
    • inherit

      private <E> E inherit(Function<ModifiableLocationType,E> property)
      If all parents return the same value for the given property, returns that value. Otherwise returns null.
    • getTheme

      public org.opengis.util.InternationalString getTheme()
      Returns the property used as the defining characteristic of the location type. If no theme has been explicitly set, then this method inherits the value from the parents providing that all parents specify the same theme.
      Specified by:
      getTheme in class AbstractLocationType
      Returns:
      property used as the defining characteristic of the location type, or null if no value has been defined or can be inherited.
      See Also:
    • setTheme

      public void setTheme(CharSequence value)
      Sets the property used as the defining characteristic of the location type.
      Examples: “local administration” for administrative areas, “built environment” for towns or properties, “access” for streets, “electoral”, “postal”.
      Parameters:
      value - the new theme, or null for inheriting a value from the parents.
    • getIdentifications

      public Collection<org.opengis.util.InternationalString> getIdentifications()
      Returns the method(s) of uniquely identifying location instances. If no methods have been explicitly set, then this method inherits the values from the parents providing that all parents specify the same methods.
      Examples: some identification methods are “name”, “code”, “unique street reference number” and “geographic address”. A location using “name” identifications may have the “Spain” geographic identifier, and a location using “postcode” identifications may have the “SW1P 3AD” geographic identifier.
      The collection returned by this method is unmodifiable. For adding or removing an identification, use addIdentification(CharSequence) or removeIdentification(CharSequence).
      Specified by:
      getIdentifications in class AbstractLocationType
      Returns:
      method(s) of uniquely identifying location instances, or an empty list if no value has been defined or can be inherited.
      See Also:
    • addIdentification

      public void addIdentification(CharSequence value)
      Adds a method of uniquely identifying location instances.
      Examples: “name”, “code”, “unique street reference number”, “geographic address”.
      Parameters:
      value - the method to add.
      Throws:
      IllegalArgumentException - if the given value is already defined.
    • removeIdentification

      public void removeIdentification(CharSequence value)
      Removes a method of uniquely identifying location instances.
      Parameters:
      value - the method to remove.
      Throws:
      IllegalArgumentException - if the given value is not found.
    • getDefinition

      public org.opengis.util.InternationalString getDefinition()
      Returns the way in which location instances are defined. If no definition has been explicitly set, then this method inherits the value from the parents providing that all parents specify the same definition.
      Specified by:
      getDefinition in class AbstractLocationType
      Returns:
      the way in which location instances are defined, or null if no value has been defined or can be inherited.
    • setDefinition

      public void setDefinition(CharSequence value)
      Sets the way in which location instances are defined.
      Parameters:
      value - the new identification.
    • getTerritoryOfUse

      public org.opengis.metadata.extent.GeographicExtent getTerritoryOfUse()
      Returns the geographic area within which the location type occurs. If no geographic area has been explicitly set, then this method inherits the value from the parents providing that all parents specify the same geographic area.
      Specified by:
      getTerritoryOfUse in class AbstractLocationType
      Returns:
      geographic area within which the location type occurs, or null if no value has been defined or can be inherited.
      See Also:
    • setTerritoryOfUse

      public void setTerritoryOfUse(org.opengis.metadata.extent.GeographicExtent value)
      Sets the geographic area within which the location type occurs. The given value is typically an instance of DefaultGeographicBoundingBox. For an alternative where only the territory name is specified, see setTerritoryOfUse(String).
      Parameters:
      value - the new geographic extent.
    • setTerritoryOfUse

      public void setTerritoryOfUse(String identifier)
      Sets the name of the geographic area within which the location type occurs.
      Examples: the geographic domain for a location type “rivers” might be “North America”.
      Parameters:
      identifier - the identifier of the geographic extent.
    • getOwner

      public AbstractParty getOwner()
      Returns the name of organization or class of organization able to create and destroy location instances. If no organization has been explicitly set, then this method inherits the value from the parents providing that all parents specify the same organization.
      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.
      Specified by:
      getOwner in class AbstractLocationType
      Returns:
      organization or class of organization able to create and destroy location instances, or null if no value has been defined or can be inherited.
      See Also:
    • setOwner

      public void setOwner(AbstractParty value)
      Sets the organization or class of organization able to create and destroy location instances. The given value is typically an instance of DefaultOrganisation. For an alternative where only the organization name is specified, see setOwner(CharSequence).
      Upcoming API change — generalization
      in a future SIS version, the argument type 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.
      Parameters:
      value - the new owner.
    • setOwner

      public void setOwner(CharSequence name)
      Sets the name of the organization or class of organization able to create and destroy location instances.
      Parameters:
      name - the organization name.
    • getParents

      public final Collection<ModifiableLocationType> getParents()
      Returns the parent location types (location types of which this location type is a sub-division). A location type can have more than one possible parent. For example, the parent of a location type named “street” could be “locality”, “town” or “administrative area”.

      The collection returned by this method is unmodifiable. For adding or removing a parent, use addParent(ModifiableLocationType) or removeParent(ModifiableLocationType).

      Specified by:
      getParents in class AbstractLocationType
      Returns:
      parent location types, or an empty collection if none.
      See Also:
    • getChildren

      public final Collection<ModifiableLocationType> getChildren()
      Returns the child location types (location types which sub-divides this location type). The collection returned by this method is unmodifiable. For adding or removing a child, use child.addParent(this) or child.removeParent(this).
      Specified by:
      getChildren in class AbstractLocationType
      Returns:
      child location types, or an empty collection if none.
      See Also:
    • addParent

      public void addParent(ModifiableLocationType parent)
      Adds the given element to the list of parents.
      Parameters:
      parent - the parent to add.
      Throws:
      IllegalStateException - if this location type already have a parent of the same name.
      IllegalArgumentException - if the given parent already have a child of the same name than this location type.
    • removeParent

      public void removeParent(ModifiableLocationType parent)
      Removes the given element from the list of parent.
      Parameters:
      parent - the parent to remove.
      Throws:
      IllegalArgumentException - if the given parent has not been found.
    • getReferenceSystem

      public ReferencingByIdentifiers getReferenceSystem()
      Returns the reference system that comprises this location type. For ModifiableLocationTypes, the reference system is always null. The reference system is defined when the location types are given to the ReferencingByIdentifiers constructor for example.
      Upcoming API change — generalization
      in a future SIS version, the type of returned element may be generalized to the org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers interface. This change is pending GeoAPI revision.
      Specified by:
      getReferenceSystem in class AbstractLocationType
      Returns:
      null.
      See Also: