sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1784262 - in /sis/branches/JDK8/core: sis-referencing-by-identifiers/ sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ sis-referencing/src/main/java/org/apache/sis/referencing/crs/
Date Fri, 24 Feb 2017 11:00:42 GMT
Author: desruisseaux
Date: Fri Feb 24 11:00:42 2017
New Revision: 1784262

URL: http://svn.apache.org/viewvc?rev=1784262&view=rev
Log:
Base class for ISO 19112 SI_SpatialReferenceSystemUsingGeographicIdentifiers.

Added:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/   (props changed)
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java

Propchange: sis/branches/JDK8/core/sis-referencing-by-identifiers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Feb 24 11:00:42 2017
@@ -0,0 +1,10 @@
+.project
+.settings
+.classpath
+.jetproperties
+.wtpmodules
+target
+bin
+cobertura.ser
+nbproject
+nbactions.xml

Added: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java?rev=1784262&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
(added)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
[UTF-8] Fri Feb 24 11:00:42 2017
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.gazetteer;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Objects;
+import javax.xml.bind.annotation.XmlTransient;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Party;
+import org.opengis.referencing.gazetteer.LocationType;
+import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.util.collection.Containers;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
+import org.apache.sis.util.iso.Types;
+
+
+/**
+ * Base class of reference systems that describe locations using geographic identifiers instead
than coordinates.
+ *
+ * <div class="section">Immutability and thread safety</div>
+ * This base class is immutable and thus thread-safe if the property <em>values</em>
(not necessarily the map itself)
+ * given to the constructor are also immutable. Most SIS subclasses and related classes are
immutable under similar
+ * conditions. This means that unless otherwise noted in the javadoc, {@code ReferencingByIdentifiers}
instances
+ * created using only SIS factories and static constants can be shared by many objects and
passed between threads
+ * without synchronization.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+@XmlTransient
+public abstract class ReferencingByIdentifiers extends AbstractReferenceSystem implements
ReferenceSystemUsingIdentifiers {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = 5353942546043471933L;
+
+    /**
+     * Property used to characterize the spatial reference system.
+     */
+    private final InternationalString theme;
+
+    /**
+     * Authority with overall responsibility for the spatial reference system.
+     */
+    private final Party overallOwner;
+
+    /**
+     * Creates a reference system from the given properties.
+     * The properties given in argument follow the same rules than for the
+     * {@linkplain AbstractReferenceSystem#AbstractReferenceSystem(Map) super-class constructor}.
+     * The following table is a reminder of main (not all) properties:
+     *
+     * <table class="sis">
+     *   <caption>Recognized properties (non exhaustive list)</caption>
+     *   <tr>
+     *     <th>Property name</th>
+     *     <th>Value type</th>
+     *     <th>Returned by</th>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#THEME_KEY}</td>
+     *     <td>{@link String} or {@link InternationalString}</td>
+     *     <td>{@link #getTheme()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers#OVERALL_OWNER_KEY}</td>
+     *     <td>{@link Party}</td>
+     *     <td>{@link #getOverallOwner()}</td>
+     *   </tr>
+     *   <tr>
+     *     <th colspan="3" class="hsep">Defined in parent class (reminder)</th>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
+     *     <td>{@link org.opengis.metadata.Identifier} or {@link String}</td>
+     *     <td>{@link #getName()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
+     *     <td>{@link org.opengis.util.GenericName} or {@link CharSequence} (optionally
as array)</td>
+     *     <td>{@link #getAlias()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
+     *     <td>{@link org.opengis.metadata.Identifier} (optionally as array)</td>
+     *     <td>{@link #getIdentifiers()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getRemarks()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.ReferenceSystem#DOMAIN_OF_VALIDITY_KEY}</td>
+     *     <td>{@link org.opengis.metadata.extent.Extent}</td>
+     *     <td>{@link #getDomainOfValidity()}</td>
+     *   </tr>
+     *   <tr>
+     *     <td>{@value org.opengis.referencing.ReferenceSystem#SCOPE_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getScope()}</td>
+     *   </tr>
+     * </table>
+     *
+     * @param properties  the properties to be given to the coordinate reference system.
+     */
+    public ReferencingByIdentifiers(final Map<String,?> properties) {
+        super(properties);
+        theme = Types.toInternationalString(properties, THEME_KEY);
+        overallOwner = Containers.property(properties, OVERALL_OWNER_KEY, Party.class);
+    }
+
+    /**
+     * Returns the GeoAPI interface implemented by this class.
+     * The default implementation returns {@code ReferenceSystemUsingIdentifiers.class}.
+     *
+     * @return the GeoAPI interface implemented by this class.
+     */
+    @Override
+    public Class<? extends ReferenceSystemUsingIdentifiers> getInterface() {
+        return ReferenceSystemUsingIdentifiers.class;
+    }
+
+    /**
+     * Property used to characterize the spatial reference system.
+     *
+     * @return property used to characterize the spatial reference system.
+     */
+    @Override
+    public InternationalString getTheme() {
+        return theme;
+    }
+
+    /**
+     * Authority with overall responsibility for the spatial reference system.
+     *
+     * @return authority with overall responsibility for the spatial reference system.
+     */
+    @Override
+    public Party getOverallOwner() {
+        return overallOwner;
+    }
+
+    /**
+     * Description of location type(s) in the spatial reference system.
+     *
+     * @return description of location type(s) in the spatial reference system.
+     */
+    @Override
+    public abstract Collection<LocationType> getLocationType();
+
+    /**
+     * Compares this reference system with the specified object for equality.
+     * If the {@code mode} argument value is {@link ComparisonMode#STRICT STRICT} or
+     * {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then all available properties are
+     * compared including the {@linkplain #getTheme() theme} and
+     * the {@linkplain #getOverallOwner() overall owner}.
+     *
+     * @param  object  the object to compare to {@code this}.
+     * @param  mode    {@link ComparisonMode#STRICT STRICT} for performing a strict comparison,
or
+     *                 {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing
only
+     *                 properties relevant to location identifications.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public boolean equals(final Object object, final ComparisonMode mode) {
+        if (!super.equals(object, mode)) {
+            return false;
+        }
+        switch (mode) {
+            case STRICT: {
+                final ReferencingByIdentifiers that = (ReferencingByIdentifiers) object;
+                return Objects.equals(theme,        that.theme) &&
+                       Objects.equals(overallOwner, that.overallOwner);
+            }
+            case BY_CONTRACT: {
+                final ReferenceSystemUsingIdentifiers that = (ReferenceSystemUsingIdentifiers)
object;
+                return Utilities.deepEquals(getTheme(),        that.getTheme(),        mode)
&&
+                       Utilities.deepEquals(getOverallOwner(), that.getOverallOwner(), mode);
+            }
+            default: {
+                // Theme and owner are metadata, so they can be ignored.
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Invoked by {@code hashCode()} for computing the hash code when first needed.
+     * See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
+     * for more information.
+     *
+     * @return the hash code value. This value may change in any future Apache SIS version.
+     */
+    @Override
+    protected long computeHashCode() {
+        return super.computeHashCode() + Objects.hash(theme, overallOwner);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1784262&r1=1784261&r2=1784262&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] Fri Feb 24 11:00:42 2017
@@ -169,7 +169,7 @@ public class AbstractCRS extends Abstrac
      *   </tr>
      * </table>
      *
-     * @param properties  The properties to be given to the coordinate reference system.
+     * @param properties  the properties to be given to the coordinate reference system.
      * @param cs          the coordinate system.
      */
     public AbstractCRS(final Map<String,?> properties, final CoordinateSystem cs) {



Mime
View raw message