sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1784589 - in /sis/branches/JDK8/core: sis-metadata/src/main/resources/org/apache/sis/metadata/sql/ sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/ sis-referencing-by-identifiers/src/main/java/org/apache/sis/...
Date Mon, 27 Feb 2017 15:45:46 GMT
Author: desruisseaux
Date: Mon Feb 27 15:45:45 2017
New Revision: 1784589

URL: http://svn.apache.org/viewvc?rev=1784589&view=rev
Log:
Initial declaration of MGRS as an ISO 19112 reference system.

Added:
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.properties
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources_fr.properties
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/test/suite/ReferencingByIdentifiersTestSuite.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK8/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -95,7 +95,8 @@ INSERT INTO metadata."CI_Party" (ID, "na
   ('Apache', 'The Apache Software Foundation'),
   ('OGC',    'Open Geospatial Consortium'),
   ('ISO',    'International Organization for Standardization'),
-  ('IOGP',   'International Association of Oil & Gas producers');
+  ('IOGP',   'International Association of Oil & Gas producers'),
+  ('NATO',   'North Atlantic Treaty Organization');
 
 INSERT INTO metadata."CI_Responsibility" (ID, "party", "role") VALUES
   ('Apache', 'Apache', 'principalInvestigator'),

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -67,6 +67,16 @@ public final class Resources extends Ind
         public static final short ChildAlreadyExists_1 = 8;
 
         /**
+         * Grid coordinates
+         */
+        public static final short GridCoordinates = 12;
+
+        /**
+         * Grid zone designator
+         */
+        public static final short GridZoneDesignator = 13;
+
+        /**
          * “{0}” is not a valid grid coordinate.
          */
         public static final short IllegalGridCoordinate_1 = 1;
@@ -116,6 +126,11 @@ public final class Resources extends Ind
          * A location type parent named “{0}” already exists.
          */
         public static final short ParentAlreadyExists_1 = 9;
+
+        /**
+         * 100 km square identifier
+         */
+        public static final short SquareIdentifier100 = 14;
     }
 
     /**
@@ -213,25 +228,6 @@ public final class Resources extends Ind
      * @param  arg0  value to substitute to "{0}".
      * @param  arg1  value to substitute to "{1}".
      * @param  arg2  value to substitute to "{2}".
-     * @return the formatted string for the given key.
-     * @throws MissingResourceException if no object for the given key can be found.
-     */
-    public static String format(final short  key,
-                                final Object arg0,
-                                final Object arg1,
-                                final Object arg2) throws MissingResourceException
-    {
-        return forLocale(null).getString(key, arg0, arg1, arg2);
-    }
-
-    /**
-     * Gets a string for the given key are replace all occurrence of "{0}",
-     * "{1}", with values of {@code arg0}, {@code arg1}, etc.
-     *
-     * @param  key   the key for the desired string.
-     * @param  arg0  value to substitute to "{0}".
-     * @param  arg1  value to substitute to "{1}".
-     * @param  arg2  value to substitute to "{2}".
      * @param  arg3  value to substitute to "{3}".
      * @return the formatted string for the given key.
      * @throws MissingResourceException if no object for the given key can be found.
@@ -249,7 +245,7 @@ public final class Resources extends Ind
      * The international string to be returned by {@link formatInternational}.
      */
     private static final class International extends ResourceInternationalString {
-        private static final long serialVersionUID = 4553487496835099424L;
+        private static final long serialVersionUID = -955665828906534712L;
 
         International(short key)                           {super(key);}
         International(short key, Object args)              {super(key, args);}
@@ -276,11 +272,6 @@ public final class Resources extends Ind
      * validity. If the key is invalid, then a {@link MissingResourceException} may be thrown
      * when a {@link InternationalString#toString(Locale)} method is invoked.
      *
-     * <div class="note"><b>API note:</b>
-     * This method is redundant with the one expecting {@code Object...}, but avoid the creation
-     * of a temporary array. There is no risk of confusion since the two methods delegate
their
-     * work to the same {@code format} method anyway.</div>
-     *
      * @param  key  the key for the desired string.
      * @param  arg  values to substitute to "{0}".
      * @return an international string for the given key.
@@ -288,17 +279,4 @@ public final class Resources extends Ind
     public static InternationalString formatInternational(final short key, final Object arg)
{
         return new International(key, arg);
     }
-
-    /**
-     * Gets an international string for the given key. This method does not check for the
key
-     * validity. If the key is invalid, then a {@link MissingResourceException} may be thrown
-     * when a {@link InternationalString#toString(Locale)} method is invoked.
-     *
-     * @param  key   the key for the desired string.
-     * @param  args  values to substitute to "{0}", "{1}", <i>etc</i>.
-     * @return an international string for the given key.
-     */
-    public static InternationalString formatInternational(final short key, final Object...
args) {
-        return new International(key, args);
-    }
 }

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.properties?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources.properties
[ISO-8859-1] Mon Feb 27 15:45:45 2017
@@ -19,6 +19,15 @@
 # Resources in this file are for "sis-referencing-by-identifiers" usage only and should not
be used by any other module.
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources"
package.
 #
+# Vocabulary
+#
+GridCoordinates                   = Grid coordinates
+GridZoneDesignator                = Grid zone designator
+SquareIdentifier100               = 100\u00a0km square identifier
+
+#
+# Error messages (to be used in exceptions)
+#
 IllegalGridCoordinate_1           = \u201c{0}\u201d is not a valid grid coordinate.
 IllegalLatitudeBand_1             = \u201c{0}\u201d is not a valid latitude band. A letter
was expected.
 IllegalSquareIdentification_1     = \u201c{0}\u201d is not a valid square identification.

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources_fr.properties?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/internal/gazetteer/Resources_fr.properties
[ISO-8859-1] Mon Feb 27 15:45:45 2017
@@ -24,6 +24,15 @@
 #   U+202F NARROW NO-BREAK SPACE  before  ; ! and ?
 #   U+00A0 NO-BREAK SPACE         before  :
 #
+# Vocabulary
+#
+GridCoordinates                   = Coordonn\u00e9es sur la grille
+GridZoneDesignator                = D\u00e9signation de la zone du quadrillage
+SquareIdentifier100               = Identifiant du carr\u00e9 de 100\u00a0km
+
+#
+# Error messages (to be used in exceptions)
+#
 IllegalGridCoordinate_1           = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas une coordonn\u00e9e
de grille valide.
 IllegalLatitudeBand_1             = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas une bande
de latitude valide. Une lettre \u00e9tait attendue.
 IllegalSquareIdentification_1     = \u00ab\u202f{0}\u202f\u00bb n\u2019est pas un identifiant
de carr\u00e9 valide.

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/AbstractLocationType.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/AbstractLocationType.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -21,8 +21,6 @@ import java.util.Arrays;
 import java.util.Objects;
 import java.util.IdentityHashMap;
 import java.util.Map;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
-import org.opengis.referencing.gazetteer.LocationType;
 import org.apache.sis.internal.gazetteer.Resources;
 import org.apache.sis.util.collection.DefaultTreeTable;
 import org.apache.sis.util.collection.TableColumn;
@@ -32,6 +30,10 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Utilities;
 
+// Branch-dependent imports
+import org.opengis.referencing.gazetteer.LocationType;
+import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+
 
 /**
  * Default implementation of {@code toString()}, {@code equals(Object)} and {@code hashCode()}
methods

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/FinalLocationType.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -22,14 +22,16 @@ import java.util.Collection;
 import java.util.Collections;
 import java.io.Serializable;
 import org.opengis.util.InternationalString;
-import org.opengis.metadata.citation.Party;
 import org.opengis.metadata.extent.GeographicExtent;
-import org.opengis.referencing.gazetteer.LocationType;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.metadata.ModifiableMetadata;
 import org.apache.sis.util.ArgumentChecks;
 
+// Branch-dependent imports
+import org.opengis.metadata.citation.Party;
+import org.opengis.referencing.gazetteer.LocationType;
+import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
+
 
 /**
  * Unmodifiable description of a location created as a snapshot of another {@link LocationType}
instance

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.gazet
 
 import java.util.Arrays;
 import java.util.Map;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.ConcurrentModificationException;
 import org.opengis.util.FactoryException;
@@ -36,15 +37,26 @@ import org.apache.sis.referencing.Common
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.referencing.crs.DefaultProjectedCRS;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.metadata.sql.MetadataSource;
+import org.apache.sis.metadata.sql.MetadataStoreException;
 import org.apache.sis.math.MathFunctions;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.StringBuilders;
 import org.apache.sis.util.Utilities;
+import org.apache.sis.util.Workaround;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.geometry.DirectPosition2D;
+import org.apache.sis.internal.system.Modules;
 import org.apache.sis.measure.Latitude;
 
+// Branch-dependent imports
+import org.opengis.metadata.citation.Party;
+import org.opengis.referencing.gazetteer.LocationType;
+
 
 /**
  * The Military Grid Reference System (MGRS).
@@ -65,7 +77,7 @@ import org.apache.sis.measure.Latitude;
  *
  * @see <a href="https://en.wikipedia.org/wiki/Military_Grid_Reference_System">Military
Grid Reference System on Wikipedia</a>
  */
-public class MilitaryGridReferenceSystem {
+public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers {
     /**
      * Height of latitude bands, in degrees.
      * Those bands are labeled from {@code 'C'} to {@code 'X'} inclusive, excluding {@code
'I'} and {@code 'O'}.
@@ -155,9 +167,9 @@ public class MilitaryGridReferenceSystem
      * Creates a new Military Grid Reference System (MGRS) using the default datum.
      * The current Apache SIS version uses the {@linkplain CommonCRS#WGS84 WGS84} datum,
      * but this choice may change in the future if there is a need to adapt to new MGRS specifications.
-     * For a more specific datum, consider using the {@link #MilitaryGridReferenceSystem(CommonCRS)}
constructor.
      */
     public MilitaryGridReferenceSystem() {
+        super(properties(), types());
         datum = CommonCRS.WGS84;
         avoidDatumChange = false;
     }
@@ -166,15 +178,52 @@ public class MilitaryGridReferenceSystem
      * Creates a new Military Grid Reference System (MGRS) using the specified datum.
      * Only the datums enumerated in {@link CommonCRS} are currently supported.
      *
-     * @param  datum  the datum to which to transform coordinates before formatting the MGRS
references,
-     *                or {@code null} for inferring the datum from the CRS associated to
each coordinate.
+     * @param  properties  the properties to be given to the reference system.
+     * @param  datum       the datum to which to transform coordinates before formatting
the MGRS references,
+     *                     or {@code null} for inferring the datum from the CRS associated
to each coordinate.
      */
-    public MilitaryGridReferenceSystem(final CommonCRS datum) {
+    public MilitaryGridReferenceSystem(final Map<String,?> properties, final CommonCRS
datum) {
+        super(properties, types());
         this.datum = (datum != null) ? datum : CommonCRS.WGS84;
         avoidDatumChange = (datum == null);
     }
 
     /**
+     * Work around for RFE #4093999 in Sun's bug database
+     * ("Relax constraint on placement of this()/super() call in constructors").
+     */
+    @Workaround(library="JDK", version="1.8")
+    private static Map<String,?> properties() {
+        final Map<String,Object> properties = new HashMap<>();
+        properties.put(NAME_KEY, "Military Grid Reference System");
+        properties.put(DOMAIN_OF_VALIDITY_KEY, Extents.WORLD);
+        properties.put(THEME_KEY, Vocabulary.formatInternational(Vocabulary.Keys.Mapping));
+        try {
+            properties.put(OVERALL_OWNER_KEY, MetadataSource.getProvided().lookup(Party.class,
"NATO"));
+        } catch (MetadataStoreException e) {
+            Logging.unexpectedException(Logging.getLogger(Modules.REFERENCING_BY_IDENTIFIERS),
+                    MilitaryGridReferenceSystem.class, "<init>", e);
+        }
+        return properties;
+    }
+
+    /**
+     * Work around for RFE #4093999 in Sun's bug database
+     * ("Relax constraint on placement of this()/super() call in constructors").
+     */
+    @Workaround(library="JDK", version="1.8")
+    private static LocationType[] types() {
+        final ModifiableLocationType gzd    = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.GridZoneDesignator));
+        final ModifiableLocationType square = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.SquareIdentifier100));
+        final ModifiableLocationType coord  = new ModifiableLocationType(Resources.formatInternational(Resources.Keys.GridCoordinates));
+        gzd   .addIdentification(Vocabulary.formatInternational(Vocabulary.Keys.Code));
+        coord .addIdentification(Vocabulary.formatInternational(Vocabulary.Keys.Coordinate));
+        square.addParent(gzd);
+        coord .addParent(square);
+        return new LocationType[] {gzd};
+    }
+
+    /**
      * Returns the value to add to the row number in order to have the "A" letter on the
southernmost or
      * northernmost value on Greenwich meridian of the Universal Polar Stereographic (UPS)
projection.
      * If {@code south} is {@code true}, then this is computed from the northernmost value
of UPS South;

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ModifiableLocationType.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -22,9 +22,7 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.ConcurrentModificationException;
 import org.opengis.util.InternationalString;
-import org.opengis.metadata.citation.Party;
 import org.opengis.metadata.extent.GeographicExtent;
-import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicDescription;
 import org.apache.sis.metadata.iso.citation.DefaultOrganisation;
 import org.apache.sis.internal.gazetteer.Resources;
@@ -35,6 +33,8 @@ import org.apache.sis.util.iso.Types;
 
 // Branch-dependent imports
 import java.util.function.Function;
+import org.opengis.metadata.citation.Party;
+import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
 
 
 /**

Modified: 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=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiers.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -21,14 +21,21 @@ 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;
+import org.apache.sis.util.Debug;
+import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.ElementKind;
+import org.apache.sis.internal.referencing.WKTUtilities;
+import org.apache.sis.io.wkt.FormattableObject;
+
+// Branch-dependent imports
+import org.opengis.metadata.citation.Party;
+import org.opengis.referencing.gazetteer.LocationType;
+import org.opengis.referencing.gazetteer.ReferenceSystemUsingIdentifiers;
 
 
 /**
@@ -139,7 +146,7 @@ public class ReferencingByIdentifiers ex
      * {@link ModifiableLocationType#snapshot(ReferenceSystemUsingIdentifiers, LocationType...)}.
      * Changes in the given location types after construction will not affect this {@code
ReferencingByIdentifiers}.
      *
-     * @param properties  the properties to be given to the coordinate reference system.
+     * @param properties  the properties to be given to the reference system.
      * @param types       description of location type(s) in the spatial reference system.
      */
     @SuppressWarnings("ThisEscapedInObjectConstruction")
@@ -252,4 +259,54 @@ public class ReferencingByIdentifiers ex
     protected long computeHashCode() {
         return super.computeHashCode() + Objects.hash(theme, overallOwner, locationTypes);
     }
+
+    /**
+     * Formats a pseudo-<cite>Well Known Text</cite> (WKT) representation for
this object.
+     * The format produced by this method is non-standard and may change in any future Apache
SIS version.
+     *
+     * @param  formatter  the formatter where to format the inner content of this pseudo-WKT
element.
+     * @return an arbitrary keyword for the pseudo-WKT element.
+     */
+    @Debug
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        WKTUtilities.appendName(this, formatter, ElementKind.NAME);
+        if (theme != null) {
+            formatter.newLine();
+            formatter.append(new SubElement("Theme", theme));
+        }
+        if (overallOwner != null) {
+            formatter.newLine();
+            formatter.append(new SubElement("Owner", overallOwner.getName()));
+        }
+        for (final LocationType type : locationTypes) {
+            formatter.newLine();
+            formatter.append(new SubElement("LocationType", type.getName()));
+        }
+        return "ReferenceSystemUsingIdentifiers";
+    }
+
+    /**
+     * A sub-element inside the pseudo-WKT.
+     */
+    private static final class SubElement extends FormattableObject {
+        /** The pseudo-WKT name of the element to format. */
+        private final String name;
+
+        /** The value of the element to format. */
+        private final InternationalString value;
+
+        /** Creates a new citation with the given value. */
+        SubElement(final String name, final InternationalString value) {
+            this.name  = name;
+            this.value = value;
+        }
+
+        /** Formats the sub-element. */
+        @Override
+        protected String formatTo(final Formatter formatter) {
+            formatter.append(value != null ? value.toString(formatter.getLocale()) : null,
null);
+            return name;
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/LocationTypeTest.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/LocationTypeTest.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -17,7 +17,6 @@
 package org.apache.sis.referencing.gazetteer;
 
 import java.util.List;
-import org.opengis.referencing.gazetteer.LocationType;
 import org.opengis.metadata.extent.GeographicDescription;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestUtilities;
@@ -26,6 +25,9 @@ import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
 
+// Branch-dependent imports
+import org.opengis.referencing.gazetteer.LocationType;
+
 
 /**
  * Tests {@link AbstractLocationType}, {@link FinalLocationType} and {@link ModifiableLocationType}.
@@ -37,9 +39,12 @@ import static org.apache.sis.test.Assert
  */
 public final strictfp class LocationTypeTest extends TestCase {
     /**
-     * Create the example given in annex B of ISO 19112:2003.
+     * Creates the example given in annex B of ISO 19112:2003.
+     *
+     * @param  inherit  {@code false} for defining all properties of all location types explicitely
even
+     *                  in case of redundancy, or {@code true} for relying on inheritance
when possible.
      */
-    private static ModifiableLocationType[] create(final boolean inherit) {
+    static ModifiableLocationType[] create(final boolean inherit) {
         /*
          * From larger area to finer one. Each type is the child of the previous type,
          * except "street" which will have all the 3 parents.

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystemTest.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -24,6 +24,7 @@ import org.apache.sis.geometry.DirectPos
 import org.apache.sis.internal.referencing.provider.TransverseMercator;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestUtilities;
 import org.junit.Test;
@@ -39,12 +40,13 @@ import static org.junit.Assert.*;
  * @version 0.8
  * @module
  */
+@DependsOn(ReferencingByIdentifiersTest.class)
 public final strictfp class MilitaryGridReferenceSystemTest extends TestCase {
     /**
      * Returns a coder instance to test.
      */
     private MilitaryGridReferenceSystem.Coder coder() {
-        return new MilitaryGridReferenceSystem(CommonCRS.WGS84).createCoder();
+        return new MilitaryGridReferenceSystem().createCoder();
     }
 
     /**

Added: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java?rev=1784589&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ReferencingByIdentifiersTest.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -0,0 +1,75 @@
+/*
+ * 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.HashMap;
+import org.apache.sis.metadata.iso.citation.DefaultOrganisation;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests {@link ReferencingByIdentifiers}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+@DependsOn(LocationTypeTest.class)
+public final strictfp class ReferencingByIdentifiersTest extends TestCase {
+    /**
+     * Creates the example given in annex B of ISO 19112:2003.
+     *
+     * @param  inherit  {@code false} for defining all properties of all location types explicitely
even
+     *                  in case of redundancy, or {@code true} for relying on inheritance
when possible.
+     */
+    private static ReferencingByIdentifiers create(final boolean inherit) {
+        final Map<String,Object> properties = new HashMap<>();
+        assertNull(properties.put(ReferencingByIdentifiers.NAME_KEY, "UK property addressing"));
+        assertNull(properties.put(ReferencingByIdentifiers.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("UK",
null, null, null)));
+        assertNull(properties.put(ReferencingByIdentifiers.THEME_KEY, "property"));
+        assertNull(properties.put(ReferencingByIdentifiers.OVERALL_OWNER_KEY, new DefaultOrganisation("Office
for National Statistics", null, null, null)));
+        return new ReferencingByIdentifiers(properties, LocationTypeTest.create(inherit));
+    }
+
+    /**
+     * Tests the equality and hash code value computation.
+     */
+    @Test
+    public void testEquals() {
+        final ReferencingByIdentifiers t1 = create(false);
+        final ReferencingByIdentifiers t2 = create(true);
+        assertEquals("hashCode", t1.hashCode(), t2.hashCode());
+        assertEquals("equals", t1, t2);
+    }
+
+    /**
+     * Tests serialization.
+     */
+    @Test
+    @DependsOnMethod("testEquals")
+    public void testSerialization() {
+        assertSerializedEquals(create(true));
+    }
+}

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

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

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/test/suite/ReferencingByIdentifiersTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/test/suite/ReferencingByIdentifiersTestSuite.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/test/suite/ReferencingByIdentifiersTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/test/suite/ReferencingByIdentifiersTestSuite.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -31,6 +31,7 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.referencing.gazetteer.LocationTypeTest.class,
+    org.apache.sis.referencing.gazetteer.ReferencingByIdentifiersTest.class,
     org.apache.sis.referencing.gazetteer.MilitaryGridReferenceSystemTest.class
 })
 public final strictfp class ReferencingByIdentifiersTestSuite extends TestSuite {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -55,6 +55,11 @@ public final class Modules {
     /**
      * The {@value} module name.
      */
+    public static final String REFERENCING_BY_IDENTIFIERS = "org.apache.sis.referencing.gazetteer";
+
+    /**
+     * The {@value} module name.
+     */
     public static final String STORAGE = "org.apache.sis.storage";
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Mon Feb 27 15:45:45 2017
@@ -127,6 +127,11 @@ public final class Vocabulary extends In
         public static final short Classpath = 14;
 
         /**
+         * Code
+         */
+        public static final short Code = 128;
+
+        /**
          * {0} code
          */
         public static final short Code_1 = 15;
@@ -147,6 +152,11 @@ public final class Vocabulary extends In
         public static final short Container = 18;
 
         /**
+         * Coordinate
+         */
+        public static final short Coordinate = 129;
+
+        /**
          * Correlation
          */
         public static final short Correlation = 19;
@@ -397,6 +407,11 @@ public final class Vocabulary extends In
         public static final short Mandatory = 66;
 
         /**
+         * Mapping
+         */
+        public static final short Mapping = 127;
+
+        /**
          * Maximum value
          */
         public static final short MaximumValue = 67;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Mon Feb 27 15:45:45 2017
@@ -28,10 +28,12 @@ CausedBy_1              = Caused by {0}
 CharacterEncoding       = Character encoding
 Characteristics         = Characteristics
 Classpath               = Classpath
+Code                    = Code
 Code_1                  = {0} code
 Commands                = Commands
 ConstantPressureSurface = Constant pressure surface
 Container               = Container
+Coordinate              = Coordinate
 Correlation             = Correlation
 CurrentDateTime         = Current date and time
 CurrentDirectory        = Current directory
@@ -82,6 +84,7 @@ Locale                  = Locale
 Localization            = Localization
 Logging                 = Logging
 Mandatory               = Mandatory
+Mapping                 = Mapping
 MaximumValue            = Maximum value
 MeanValue               = Mean value
 MinimumValue            = Minimum value

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1784589&r1=1784588&r2=1784589&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Mon Feb 27 15:45:45 2017
@@ -35,10 +35,12 @@ CausedBy_1              = Caus\u00e9e pa
 CharacterEncoding       = Encodage des caract\u00e8res
 Characteristics         = Caract\u00e9ristiques
 Classpath               = Chemin de classes
+Code                    = Code
 Code_1                  = Code {0}
 Commands                = Commandes
 ConstantPressureSurface = Surface \u00e0 pression constante
 Container               = Conteneur
+Coordinate              = Coordonn\u00e9e
 Correlation             = Corr\u00e9lation
 CurrentDateTime         = Date et heure courantes
 CurrentDirectory        = R\u00e9pertoire courant
@@ -89,6 +91,7 @@ Locale                  = Locale
 Localization            = R\u00e9gionalisation
 Logging                 = Journalisation
 Mandatory               = Requis
+Mapping                 = Cartographie
 MaximumValue            = Valeur maximale
 MeanValue               = Valeur moyenne
 MinimumValue            = Valeur minimale



Mime
View raw message