Class ModifiableLocationType

  • All Implemented Interfaces:
    Lenient­Comparable

    public class ModifiableLocationType
    extends Object
    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 Modifiable­Location­Type instances are modifiable, they should not be published directly. Instead, unmodifiable snapshots should be published. The same Modifiable­Location­Type 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.
    ModifiableLocationType area   = new ModifiableLocationType("administrative area");
    ModifiableLocationType town   = new ModifiableLocationType("town");
    ModifiableLocationType street = new ModifiableLocationType("street");
    
    area  .setTheme("local administration");
    town  .setTheme("built environment");
    street.setTheme("access");
    
    area  .setDefinition("area of responsibility of highest level local authority");
    town  .setDefinition("city or town");
    street.setDefinition("thoroughfare providing access to properties");
    
    town  .addParent(area);
    street.addParent(area);
    street.addParent(town);
    A string representation of the area location type is as below:
    administrative area………………… area of responsibility of highest level local authority
      ├─town……………………………………………… city or town
      │   └─street……………………………… thoroughfare providing access to properties
      └─street………………………………………… thoroughfare providing access to properties
    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:
    area.setTerritoryOfUse("Japan");
    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
    See Also:
    Abstract­Location, Referencing­By­Identifiers

    Defined in the sis-referencing-by-identifiers module

    • Constructor Detail

      • ModifiableLocationType

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

      • getName

        public InternationalString getName()
        Returns the name of the location type. This name is specified at construction time and can not be changed.
        Examples: “administrative area”, “town”, “locality”, “street”, “property”.
        Returns:
        name of the location type.
      • getTheme

        public 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.
        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:
        Referencing­By­Identifiers​.get­Theme()
      • 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<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 add­Identification(Char­Sequence) or remove­Identification(Char­Sequence).
        Returns:
        method(s) of uniquely identifying location instances, or an empty list if no value has been defined or can be inherited.
        See Also:
        Abstract­Location​.get­Geographic­Identifier()
      • 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:
        Illegal­Argument­Exception - 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:
        Illegal­Argument­Exception - if the given value is not found.
      • getDefinition

        public 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.
        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 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.
        Returns:
        geographic area within which the location type occurs, or null if no value has been defined or can be inherited.
        See Also:
        Abstract­Reference­System​.get­Domain­Of­Validity()
      • 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.
        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:
        Abstract­Location​.get­Administrator(), Referencing­By­Identifiers​.get­Overall­Owner()
      • 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 Default­Organisation. For an alternative where only the organization name is specified, see set­Owner(Char­Sequence).
        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.
      • getReferenceSystem

        public ReferencingByIdentifiers getReferenceSystem()
        Returns the reference system that comprises this location type. For Modifiable­Location­Types, the reference system is always null. The reference system is defined when the location types are given to the Referencing­By­Identifiers 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​.Reference­System­Using­Identifiers interface. This change is pending GeoAPI revision.
        Returns:
        null.
        See Also:
        Referencing­By­Identifiers​.get­Location­Types()
      • snapshot

        public static List<AbstractLocationType> snapshot​(ReferencingByIdentifiers rs,
                                                          AbstractLocationType... types)
        Creates unmodifiable snapshots of the given location types. This method returns a new collection within which all elements are snapshots of the given location types (in iteration order), except the reference system which is set to the given value.

        The location types returned by this method are serializable if all properties (name, territory of use, etc. are also serializable).

        Parameters:
        rs - the reference system to assign to the new location types, or null if none.
        types - the location types for which to take a snapshot.
        Returns:
        unmodifiable copies of the given location types.
      • equals

        public final boolean equals​(Object object)
        Compares this location type with the specified object for strict equality. This method compares all properties except the value returned by get­Parents() and get­Reference­System(), for avoiding never-ending loops.

        This method is implemented as below:

        return equals(object, ComparisonMode.STRICT);
        Specified by:
        equals in interface Lenient­Comparable
        Overrides:
        equals in class Object
        Parameters:
        object - the object to compare to this.
        Returns:
        true if both objects are equal.
        See Also:
        Comparison­Mode​.STRICT
      • hashCode

        public int hashCode()
        Returns a hash code value for this location type.
        Overrides:
        hash­Code in class Object
        Returns:
        a hash code value for this location type.
      • toString

        public String toString()
        Returns a string representation of this location type and all its children. Current implementation formats a tree with the name and definition of each type, like below:
        administrative area………………… area of responsibility of highest level local authority
          ├─town……………………………………………… city or town
          │   └─street……………………………… thoroughfare providing access to properties
          └─street………………………………………… thoroughfare providing access to properties
        The string representation is mostly for debugging purpose and may change in any future SIS version.
        Overrides:
        to­String in class Object
        Returns:
        a string representation of this location type.