sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1726433 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ sis-metadata/src/te...
Date Sat, 23 Jan 2016 18:26:30 GMT
Author: desruisseaux
Date: Sat Jan 23 18:26:30 2016
New Revision: 1726433

URL: http://svn.apache.org/viewvc?rev=1726433&view=rev
Log:
Consolidation of our way to handle authority, codespace and code.
The success metric for this commit is when the WKT formatter can write "urn:ogc:def:crs:OGC:1.3:CRS84" correctly.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/NameMeaningTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -25,8 +25,12 @@ import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
 import org.opengis.referencing.operation.*;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Citation;
 import org.apache.sis.util.Static;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.util.DefinitionURI;
+import org.apache.sis.metadata.iso.citation.Citations;
 
 
 /**
@@ -81,11 +85,18 @@ public final class NameMeaning extends S
 
     /**
      * Naming authorities allowed to appear in {@code "urn:ogc:def:"}.
+     * This map serves two purposes:
      *
-     * <p><b>Note on the case:</b> The <cite>"Name type specification — definitions"</cite> document (OGC 09-048) writes
-     * authorities in upper cases, while <a href="http://www.opengis.net/def/auth/">http://www.opengis.net/def/auth/</a>
-     * use lower cases. Apache SIS uses upper cases for now. The lower/upper case policy should be kept consistent with
-     * the policy used by {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory} for its keys.</p>
+     * <ul>
+     *   <li>Tell if a given authority is one of the authorities allowed by the OGC namespace.</li>
+     *   <li>Opportunistically fix the letter case.</li>
+     * </ul>
+     *
+     * <b>Note on the case:</b>
+     * <cite>"Name type specification — definitions"</cite> (OGC 09-048) writes authorities in upper cases,
+     * while <a href="http://www.opengis.net/def/auth/">http://www.opengis.net/def/auth/</a> uses lower cases.
+     * Apache SIS uses upper cases for now. The lower/upper case policy should be kept consistent with the policy
+     * used by {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory} for its keys.
      *
      * @see org.apache.sis.referencing.factory.MultiAuthoritiesFactory
      * @see <a href="http://www.opengis.net/def/auth/">http://www.opengis.net/def/auth/</a>
@@ -101,11 +112,6 @@ public final class NameMeaning extends S
         add("UCUM");            // Unified Code for Units of Measure
         add("UNSD");            // United Nations Statistics Division
         add("USNO");            // United States Naval Observatory
-
-        // Codespaces defined by WMS specification for CRS.
-        AUTHORITIES.put(Constants.CRS, Constants.OGC);
-        AUTHORITIES.put("AUTO",        Constants.OGC);
-        AUTHORITIES.put("AUTO2",       Constants.OGC);
     }
 
     /**
@@ -123,20 +129,54 @@ public final class NameMeaning extends S
     }
 
     /**
-     * Returns the authority to format for the given code space, or {@code null} if there is no known authority
-     * in URN syntax for the given code space. The return value is used for fixing the Apache SIS policy regarding
-     * lower or upper cases (both conventions are used in different OGC resources).
-     *
-     * @param  codeSpace The code space (can be {@code null}).
-     * @return The authority to format in the URN, or {@code null} if none.
+     * Formats the given identifier using the {@code "ogc:urn:def:"} syntax with possible heuristic changes to
+     * the given values. This method delegates to {@link DefinitionURI#format(String, String, String, String)}
+     * after "fixing" the given values using some heuristic knowledge about the meaning of URN.
+     *
+     * @param  type      The object type.
+     * @param  authority The authority as one of the values documented in {@link DefinitionURI} javadoc.
+     * @param  version   The code version, or {@code null}. This is the only optional information.
+     * @param  code      The code.
+     * @return An identifier using the URN syntax, or {@code null} if a mandatory information is missing.
      *
      * @since 0.7
+     *
+     * @see DefinitionURI#format(String, String, String, String)
      */
-    public static String authority(String codeSpace) {
-        if (codeSpace != null) {
-            codeSpace = AUTHORITIES.get(codeSpace.toUpperCase(Locale.US));
+    public static String toURN(final Class<?> type, final String authority, String version, String code) {
+        if (type != null && authority != null && code != null) {
+            final String key = authority.toUpperCase(Locale.US);
+            String codeSpace = AUTHORITIES.get(key);
+            if (codeSpace == null) {
+                /*
+                 * If the given authority is not one of the authorities that we expected for the OGC namespace,
+                 * verify if we can related it to one of the specifications enumerated in the Citations class.
+                 * For example if the user gave us "OGP" as the authority, we will replace that by "IOGP" (the
+                 * new name for that organization).
+                 */
+                final Citation c = Citations.fromName(key);
+                codeSpace = org.apache.sis.internal.util.Citations.getCodeSpace(c);
+                if (AUTHORITIES.get(codeSpace) == null) {
+                    return null;            // Not an authority that we recognize for the OGC namespace.
+                }
+                version = getVersion(c);    // Unconditionally overwrite the user-specified version.
+                /*
+                 * If the above lines resulted in a chance of codespace, we may need to concatenate the authority
+                 * with the code for preserving information. The main use case is WMS codes like "CRS:84":
+                 *
+                 *   1) Citations.fromName("CRS") gave us Citations.WMS (version 1.3) as the authority.
+                 *   2) getCodeSpace(Citations.WMS) gave us "OGC", which is indeed the codespace used in URN.
+                 *   3) OGC Naming Authority – Procedures (OGC-09-046r2) said that "CRS:84" should be formatted
+                 *      as "urn:ogc:def:crs:OGC:1.3:CRS84". We already got the "OGC" and "1.3" parts with above
+                 *      steps, the last part is to replace "84" by "CRS84".
+                 */
+                if (!authority.equals(codeSpace) && !code.startsWith(authority)) {
+                    code = authority + code;    // Intentionally no ':' separator.
+                }
+            }
+            return DefinitionURI.format(toObjectType(type), codeSpace, version, code);
         }
-        return codeSpace;
+        return null;
     }
 
     /**
@@ -153,5 +193,26 @@ public final class NameMeaning extends S
             }
         }
         return null;
+    }
+
+    /**
+     * Returns the version of the namespace managed by the given authority.
+     * Current Apache SIS implementation searches this information in the {@link Citation#getEdition()} property.
+     * This approach is based on the assumption that the authority is some specification document or reference to
+     * a database, not an organization. However this policy may be revisited in any future SIS version.
+     *
+     * @param authority The authority from which to get a version, or {@code null}.
+     * @return The version, or {@code null} if none.
+     *
+     * @since 0.7
+     */
+    public static String getVersion(final Citation authority) {
+        if (authority != null) {
+            final InternationalString i18n = authority.getEdition();
+            if (i18n != null) {
+                return i18n.toString(Locale.US);
+            }
+        }
+        return null;
     }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.metadata;
 
+import java.util.Arrays;
 import java.util.Collection;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
@@ -81,7 +82,7 @@ public final class ServicesForUtility ex
         String           code                  = null;
         String           codeSpace             = null;
         String           version               = null;
-        Identifier       alternateIdentifier   = null;
+        Identifier[]     alternateIdentifiers  = null;
         CharSequence     citedResponsibleParty = null;
         PresentationForm presentationForm      = null;
         Citation[]       copyFrom              = null;      // Copy citedResponsibleParty from those citations.
@@ -106,16 +107,18 @@ public final class ServicesForUtility ex
                 presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                 break;
             }
-            case "ISO 19128": {
-                title               = "Geographic Information — Web map server interface";   // ISO title
-                alternateTitle      = "Web Map Server Implementation Specification";         // OGC title
-                alternateIdentifier = new ImmutableIdentifier(Citations.OGC, "OGC", "06-042", null, null);
-                edition             = "ISO 19128:2005";
-                code                = "19128";
-                codeSpace           = "ISO";
-                version             = "2005";
-                copyFrom            = new Citation[] {Citations.ISO_19115.get(0), Citations.OGC};
-                presentationForm    = PresentationForm.DOCUMENT_DIGITAL;
+            case "WMS": {
+                title                = "Web Map Server";                                      // OGC title
+                alternateTitle       = "Geographic Information — Web map server interface";   // ISO title
+                alternateIdentifiers = new Identifier[] {
+                    new ImmutableIdentifier(null, "OGC", "06-042",  null, null),
+                    new ImmutableIdentifier(null, "ISO", "19128", "2005", null)
+                };
+                edition          = "1.3";
+                code             = "WMS";
+                codeSpace        = "OGC";
+                copyFrom         = new Citation[] {Citations.OGC, Citations.ISO_19115.get(0)};
+                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                 break;
             }
             case Constants.OGC: {
@@ -197,8 +200,9 @@ public final class ServicesForUtility ex
                 }
             }
         }
-        if (alternateIdentifier != null) {
-            c.getIdentifiers().add(alternateIdentifier);    // getIdentifiers() should not return null at this point.
+        if (alternateIdentifiers != null) {
+            // getIdentifiers() should not return null at this point.
+            c.getIdentifiers().addAll(Arrays.asList(alternateIdentifiers));
         }
         c.freeze();
         return c;

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -29,7 +29,6 @@ import org.opengis.util.InternationalStr
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.internal.util.DefinitionURI;
 import org.apache.sis.internal.metadata.NameMeaning;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.FormattableObject;
@@ -549,12 +548,14 @@ public class ImmutableIdentifier extends
                      * Other conventions format only for the ID[…] of root element.
                      */
                     if (isRoot && enclosing != null && convention != Convention.INTERNAL) {
-                        final String auth = NameMeaning.authority(cs);
-                        if (auth != null) {
-                            final String type = NameMeaning.toObjectType(enclosing.getClass());
-                            if (type != null) {
-                                formatter.append(new URI(type, auth, version, code));
-                            }
+                        final String urn = NameMeaning.toURN(enclosing.getClass(), cs, version, code);
+                        if (urn != null) {
+                            formatter.append(new FormattableObject() {
+                                @Override protected String formatTo(final Formatter formatter) {
+                                    formatter.append(urn, null);
+                                    return WKTKeywords.URI;
+                                }
+                            });
                         }
                     }
                 }
@@ -603,29 +604,6 @@ public class ImmutableIdentifier extends
         }
     }
 
-    /**
-     * The {@code URI[…]} element inside an {@code ID[…]}.
-     */
-    private static final class URI extends FormattableObject {
-        /** The components of the URI to format. */
-        private final String type, codeSpace, version, code;
-
-        /** Creates a new URI with the given components. */
-        URI(final String type, final String codeSpace, final String version, final String code) {
-            this.type      = type;
-            this.codeSpace = codeSpace;
-            this.version   = version;
-            this.code      = code;
-        }
-
-        /** Formats the URI. */
-        @Override
-        protected String formatTo(final Formatter formatter) {
-            formatter.append(DefinitionURI.format(type, codeSpace, version, code), null);
-            return WKTKeywords.URI;
-        }
-    }
-
 
 
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -17,7 +17,6 @@
 package org.apache.sis.metadata.iso.citation;
 
 import java.util.List;
-import java.util.Collections;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;        // For javadoc
 import org.apache.sis.util.Static;
@@ -112,25 +111,6 @@ public final class Citations extends Sta
     });
 
     /**
-     * The <cite>Geographic Information — Web map server interface</cite> standards defined by ISO 19128.
-     * This specification is also available as the OGC
-     * <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS) specification version 1.3.
-     *
-     * <div class="section">Content and future evolution</div>
-     * This list currently contains only one standard, but is nevertheless defined as a list in case a
-     * future version splits the standard in many parts.
-     * The content of this list may vary in future Apache SIS versions depending on the evolution of standards
-     * and in the way that SIS support them.
-     *
-     * <div class="section">Main usage</div>
-     * Among other things, this specification defines the Coordinate Reference System objects
-     * in the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} namespaces.
-     *
-     * @since 0.7
-     */
-    public static final List<Citation> ISO_19128 = Collections.singletonList(new CitationConstant("ISO 19128"));
-
-    /**
      * The <a href="http://www.iogp.org">International Association of Oil &amp; Gas producers</a> (IOGP) organization.
      * This organization is responsible for maintainance of {@link #EPSG} database.
      *
@@ -205,6 +185,43 @@ public final class Citations extends Sta
     public static final IdentifierSpace<Integer> EPSG = new CitationConstant.Authority<>(Constants.EPSG);
 
     /**
+     * The authority for identifiers of objects defined by the
+     * <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS) specification.
+     * The WMS 1.3 specifications is also known as ISO 19128
+     * <cite>Geographic Information — Web map server interface</cite> standard.
+     *
+     * <p>The citation {@linkplain DefaultCitation#getCitedResponsibleParties() responsible parties}
+     * are the OGC and ISO organizations.
+     * The {@linkplain IdentifierSpace#getName() namespace} declared by this constant is {@code "OGC"},
+     * but the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} namespaces are also commonly found in practice.</p>
+     *
+     * <div class="section">Main usage</div>
+     * This value can be returned by:
+     * <ul>
+     *   <li>{@link org.apache.sis.referencing.factory.CommonAuthorityFactory#getAuthority()}</li>
+     * </ul>
+     *
+     * @since 0.7
+     */
+    public static final IdentifierSpace<Integer> WMS = new WMS();
+
+    /**
+     * Special case for the {@link Citations#WMS} constant
+     * since it uses the same codespace than {@link Citations#OGC}.
+     */
+    private static final class WMS extends CitationConstant.Authority<Integer> {
+        private static final long serialVersionUID = -8490156477724003085L;
+
+        WMS() {
+            super("WMS");
+        }
+
+        @Override public String getName() {
+            return Constants.OGC;
+        }
+    }
+
+    /**
      * The authority for identifiers found in specifications from the
      * <a href="http://www.opengeospatial.org">Open Geospatial Consortium</a>.
      * The {@linkplain IdentifierSpace#getName() name} of this identifier space is fixed to {@code "OGC"}.
@@ -422,6 +439,7 @@ public final class Citations extends Sta
      */
     private static final CitationConstant[] CITATIONS = {
         (CitationConstant) EPSG,
+        (CitationConstant) WMS,
         (CitationConstant) OGC,
         (CitationConstant) ESRI,
         (CitationConstant) NETCDF,
@@ -434,7 +452,6 @@ public final class Citations extends Sta
         (CitationConstant) SIS,
         (CitationConstant) ISO_19115.get(0),
         (CitationConstant) ISO_19115.get(1),
-        (CitationConstant) ISO_19128.get(0),
         (CitationConstant) IOGP
     };
 
@@ -486,6 +503,9 @@ public final class Citations extends Sta
         if (equalsFiltered(identifier, "OGP")) {    // Old name of "IOGP" organization.
             return IOGP;
         }
+        if (equalsFiltered(identifier, Constants.CRS)) {
+            return WMS;
+        }
         /*
          * If we found no match, org.apache.sis.internal.metadata.ServicesForUtility expects
          * that we return anything that is not an instance of CitationConstant.
@@ -570,17 +590,26 @@ public final class Citations extends Sta
      * This method is useful for extracting a short designation of an authority (e.g. {@code "EPSG"})
      * for display purpose. This method performs the following choices:
      *
-     * <ul>
+     * <ul class="verbose">
      *   <li>If the given citation is {@code null}, then this method returns {@code null}.</li>
      *   <li>Otherwise if the collection of {@linkplain DefaultCitation#getIdentifiers() citation identifiers}
      *       contains at least one non-{@linkplain org.apache.sis.util.Deprecable#isDeprecated() deprecated}
      *       identifier, then:
      *     <ul>
-     *       <li>If the code and codespace of at least one non-deprecated identifier are
-     *           {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier unicode identifiers}, then
-     *           the <strong>first</strong> of those identifiers is returned in a {@code "[codespace:]code"} format.
-     *           Only the first character of the resulting string needs to be an
-     *           {@linkplain Character#isUnicodeIdentifierStart(int) identifier start character}.</li>
+     *       <li>If the <var>codespace</var> (if any) and the <var>code</var> of at least one non-deprecated identifier
+     *           are {@linkplain org.apache.sis.util.CharSequences#isUnicodeIdentifier valid Unicode identifiers}
+     *           (with relaxed rules regarding the code), then the <strong>first</strong> of those identifiers
+     *           is returned in a {@code "[codespace:]code"} format. If a <var>codespace</var> exists,
+     *           then the above restriction about the <var>code</var> is relaxed in two ways:
+     *         <ul>
+     *           <li>The code is allowed to start with a
+     *               Unicode identifier {@linkplain Character#isUnicodeIdentifierPart(int) part}
+     *               (not necessarily {@linkplain Character#isUnicodeIdentifierStart(int) start})
+     *               since the <var>codespace</var> already provides the start character.</li>
+     *           <li>The code is allowed to contain some other characters (currently {@code '.'} and {@code '-'})
+     *               commonly found in identifiers in the codespace managed by various authorities.</li>
+     *         </ul>
+     *       </li>
      *       <li>Otherwise the first non-empty and non-deprecated identifier is returned in a
      *           {@code "[codespace:]code"} format, despite not being a valid Unicode identifier.</li>
      *     </ul>
@@ -622,7 +651,7 @@ public final class Citations extends Sta
      * This method is useful for extracting a short designation of an authority (e.g. {@code "EPSG"})
      * for processing purpose. This method performs the following actions:
      *
-     * <ul>
+     * <ul class="verbose">
      *   <li>First, performs the same work than {@link #getIdentifier(Citation)} except that {@code '_'}
      *       is used instead of {@link org.apache.sis.util.iso.DefaultNameSpace#DEFAULT_SEPARATOR ':'}
      *       as the separator between the codespace and the code.</li>

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/NameMeaningTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/NameMeaningTest.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/NameMeaningTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/NameMeaningTest.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -20,6 +20,7 @@ import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
 import org.opengis.referencing.ReferenceSystem;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -31,7 +32,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5 (derived from 0.4)
- * @version 0.5
+ * @version 0.7
  * @module
  */
 public final strictfp class NameMeaningTest extends TestCase {
@@ -54,4 +55,16 @@ public final strictfp class NameMeaningT
         assertEquals("axis",            NameMeaning.toObjectType(CoordinateSystemAxis.class));
         assertEquals("referenceSystem", NameMeaning.toObjectType(ReferenceSystem     .class));
     }
+
+    /**
+     * Tests {@link NameMeaning#toURN(Class, String, String, String)}.
+     *
+     * @since 0.7
+     */
+    @Test
+    @DependsOnMethod("testToObjectType")
+    public void testToURN() {
+        assertEquals("urn:ogc:def:crs:OGC:1.3:CRS84", NameMeaning.toURN(GeographicCRS.class, "CRS",  null,   "84"));
+        assertEquals("urn:ogc:def:datum:EPSG::6326",  NameMeaning.toURN(GeodeticDatum.class, "EPSG", null, "6326"));
+    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -65,7 +65,8 @@ public final strictfp class CitationsTes
         assertSame(ISSN,             fromName("ISSN"));
         assertSame(ISO_19115.get(0), fromName("ISO 19115-1"));
         assertSame(ISO_19115.get(1), fromName("ISO 19115-2"));
-        assertSame(ISO_19128.get(0), fromName("ISO 19128"));
+        assertSame(WMS,              fromName("WMS"));
+        assertSame(WMS,              fromName(Constants.CRS));
         /*
          * Verify again, but using reflection for making sure that the field names
          * are consistent and that we did not forgot any citation constant.
@@ -98,9 +99,11 @@ public final strictfp class CitationsTes
         assertEquals("S-57",        getIdentifier(S57));    // Not a valid Unicode identifier.
         assertEquals("ISO:19115-1", getIdentifier(ISO_19115.get(0)));  // The ':' separator is not usual in ISO references
         assertEquals("ISO:19115-2", getIdentifier(ISO_19115.get(1)));  // and could be changed in future SIS versions.
-        assertEquals("ISO:19128",   getIdentifier(ISO_19128.get(0)));
-        assertIdentifierEquals("OGC:06-042", "Identifiers in OGC namespace", "OGC", null, "06-042",
-                ((List<? extends Identifier>) ISO_19128.get(0).getIdentifiers()).get(1));
+        assertEquals("OGC:WMS",     getIdentifier(WMS));
+        assertIdentifierEquals("OGC:06-042", null, "OGC", null, "06-042",
+                ((List<? extends Identifier>) WMS.getIdentifiers()).get(1));
+        assertIdentifierEquals("ISO:19128", null, "ISO", "2005", "19128",
+                ((List<? extends Identifier>) WMS.getIdentifiers()).get(2));
     }
 
     /**
@@ -122,9 +125,9 @@ public final strictfp class CitationsTes
         assertEquals("ISSN",        getUnicodeIdentifier(ISSN));
         assertNull  ("Proj4",       getUnicodeIdentifier(PROJ4));      // Not yet publicly declared as an identifier.
         assertNull  ("S57",         getUnicodeIdentifier(S57));        // Not yet publicly declared as an identifier.
+        assertEquals("OGC_WMS",     getUnicodeIdentifier(WMS));
         assertNull  ("ISO_19115-1", getUnicodeIdentifier(ISO_19115.get(0)));  // Not a valid Unicode identifier.
         assertNull  ("ISO_19115-2", getUnicodeIdentifier(ISO_19115.get(1)));
-        assertEquals("ISO_19128",   getUnicodeIdentifier(ISO_19128.get(0)));
     }
 
     /**
@@ -135,6 +138,7 @@ public final strictfp class CitationsTes
     @DependsOnMethod("testGetUnicodeIdentifier")
     public void testGetCodeSpace() {
         assertEquals("SIS",         org.apache.sis.internal.util.Citations.getCodeSpace(SIS));
+        assertEquals("OGC",         org.apache.sis.internal.util.Citations.getCodeSpace(WMS));
         assertEquals("OGC",         org.apache.sis.internal.util.Citations.getCodeSpace(OGC));
         assertEquals("IOGP",        org.apache.sis.internal.util.Citations.getCodeSpace(IOGP));
         assertEquals("EPSG",        org.apache.sis.internal.util.Citations.getCodeSpace(EPSG));
@@ -148,7 +152,6 @@ public final strictfp class CitationsTes
         assertEquals("S57",         org.apache.sis.internal.util.Citations.getCodeSpace(S57));
         assertNull  ("ISO_19115-1", org.apache.sis.internal.util.Citations.getCodeSpace(ISO_19115.get(0)));
         assertNull  ("ISO_19115-2", org.apache.sis.internal.util.Citations.getCodeSpace(ISO_19115.get(1)));
-        assertEquals("ISO_19128",   org.apache.sis.internal.util.Citations.getCodeSpace(ISO_19128.get(0)));
     }
 
     /**
@@ -157,6 +160,7 @@ public final strictfp class CitationsTes
     @Test
     public void testGetTitles() {
         assertTitleEquals("SIS",     "Apache Spatial Information System",    SIS);
+        assertTitleEquals("WMS",     "Web Map Server",                       WMS);
         assertTitleEquals("OGC",     "Identifiers in OGC namespace",         OGC);
         assertTitleEquals("EPSG",    "EPSG Geodetic Parameter Dataset",      EPSG);
         assertTitleEquals("ISBN",    "International Standard Book Number",   ISBN);
@@ -167,7 +171,7 @@ public final strictfp class CitationsTes
         assertTitleEquals("S57",     "S-57",                                 S57);
         assertTitleEquals("ISO_19115", "Geographic Information — Metadata Part 1: Fundamentals", ISO_19115.get(0));
         assertTitleEquals("ISO_19115", "Geographic Information — Metadata Part 2: Extensions for imagery and gridded data", ISO_19115.get(1));
-        assertTitleEquals("ISO_19128", "Geographic Information — Web map server interface", ISO_19128.get(0));
+        assertEquals     ("ISO_19128", "Geographic Information — Web map server interface", getSingleton(WMS.getAlternateTitles()).toString());
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -193,9 +193,7 @@ public final class Code {
              */
             if (fallback != null) {
                 if (!isHTTP) {
-                    final String urn = DefinitionURI.format(NameMeaning.toObjectType(type),
-                                                            NameMeaning.authority(fallback.getCodeSpace()),
-                                                            fallback.getVersion(), fallback.getCode());
+                    final String urn = NameMeaning.toURN(type, fallback.getCodeSpace(), fallback.getVersion(), fallback.getCode());
                     if (urn != null) {
                         final Code code = new Code();
                         /*

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -113,12 +113,12 @@ final class StandardDefinitions {
 
     /**
      * Adds to the given properties an additional identifier in the {@code "CRS"} namespace.
-     * This method presume that the only identifier that existed before this method call was the EPSG one.
+     * This method presumes that the only identifier that existed before this method call was the EPSG one.
      */
     private static void addWMS(final Map<String,Object> properties, final String code) {
         properties.put(IDENTIFIERS_KEY, new NamedIdentifier[] {
             (NamedIdentifier) properties.get(IDENTIFIERS_KEY),
-            new NamedIdentifier(Citations.OGC, code)
+            new NamedIdentifier(Citations.WMS, code)
         });
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -260,7 +260,7 @@ public class DefaultGeographicCRS extend
                     final int i = Arrays.binarySearch(EPSG_CODES, Short.parseShort(identifier.getCode()));
                     if (i >= 0) {
                         final Map<String,Object> c = new HashMap<>(properties);
-                        c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.OGC, CRS, Short.toString(CRS_CODES[i])));
+                        c.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.WMS, CRS, Short.toString(CRS_CODES[i])));
                         properties = c;
                     }
                 } catch (NumberFormatException e) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/AuthorityFactoryIdentifier.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.facto
 import java.util.Locale;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
-import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.cs.CSAuthorityFactory;
@@ -33,6 +32,7 @@ import org.apache.sis.util.resources.Voc
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.metadata.NameMeaning;
 
 // Branch-dependent imports
 import java.util.Objects;
@@ -191,15 +191,9 @@ final class AuthorityFactoryIdentifier {
      * @return An identifier for the version of the given authority, or {@code this} if the version is the same.
      */
     AuthorityFactoryIdentifier versionOf(final Citation factory) {
-        String newVersion = null;
-        if (factory != null) {
-            final InternationalString i18n = factory.getEdition();
-            if (i18n != null) {
-                newVersion = i18n.toString(Locale.US);
-                if (newVersion != null) {
-                    newVersion = newVersion.toLowerCase(Locale.US);
-                }
-            }
+        String newVersion = NameMeaning.getVersion(factory);
+        if (newVersion != null) {
+            newVersion = newVersion.toLowerCase(Locale.US);
         }
         if (Objects.equals(version, newVersion)) {
             return this;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -264,20 +264,22 @@ public class CommonAuthorityFactory exte
     }
 
     /**
-     * Returns the specification that defines the codes recognized by this factory. The definitive source
-     * for this factory is ISO 19128: <cite>Geographic Information — Web map server interface</cite>,
-     * also available as the OGC <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS)
-     * specification. However this method returns OGC as the authority since it is the authority reported in URN
-     * (for example {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}).
+     * Returns the specification that defines the codes recognized by this factory. The definitive source for this
+     * factory is OGC <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS) specification,
+     * also available as the ISO 19128 <cite>Geographic Information — Web map server interface</cite> standard.
      *
-     * @return The <cite>"Identifiers in OGC namespace"</cite> authority.
+     * <p>While the authority is WMS, the {@linkplain org.apache.sis.xml.IdentifierSpace#getName() namespace}
+     * of that authority is set to {@code "OGC"}. Apache SIS does that for consistency with the namespace used
+     * in URNs (for example {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}).</p>
      *
-     * @see Citations#OGC
-     * @see Citations#ISO_19128
+     * @return The <cite>"Web Map Service"</cite> authority.
+     *
+     * @see #getCodeSpaces()
+     * @see Citations#WMS
      */
     @Override
     public Citation getAuthority() {
-        return Citations.OGC;
+        return Citations.WMS;
     }
 
     /**
@@ -379,9 +381,21 @@ public class CommonAuthorityFactory exte
     }
 
     /**
-     * Returns the namespaces of codes defined by OGC.
+     * Returns the namespaces defined by the OGC specifications implemented by this factory.
+     * At the difference of other factories, the namespaces of {@code CommonAuthorityFactory}
+     * are quite different than the {@linkplain #getAuthority() authority} title or identifier:
+     *
+     * <ul>
+     *   <li><b>Authority:</b> {@code "WMS"} (for <cite>"Web Map Services"</cite>)</li>
+     *   <li><b>Namespaces:</b> {@code "CRS"}, {@code "AUTO"}, {@code "AUTO2"}.
+     *       The {@code "OGC"} namespace is also accepted for compatibility reason,
+     *       but its scope is wider than the above-cited namespaces.</li>
+     * </ul>
      *
      * @return A set containing at least the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} strings.
+     *
+     * @see #getAuthority()
+     * @see Citations#WMS
      */
     @Override
     public Set<String> getCodeSpaces() {

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -194,7 +194,7 @@ public final strictfp class StandardDefi
         crs = StandardDefinitions.createVerticalCRS(CommonCRS.Vertical.NAVD88.crs, datum);
         assertEquals("name", "NAVD88 height", crs.getName().getCode());
         assertEquals("identifier", "5703", IdentifiedObjects.getIdentifier(crs, Citations.EPSG).getCode());
-        assertEquals("identifier",   "88", IdentifiedObjects.getIdentifier(crs, Citations.OGC ).getCode());
+        assertEquals("identifier",   "88", IdentifiedObjects.getIdentifier(crs, Citations.WMS ).getCode());
         assertEquals("direction", AxisDirection.UP, crs.getCoordinateSystem().getAxis(0).getDirection());
 
         datum = StandardDefinitions.createVerticalDatum(CommonCRS.Vertical.MEAN_SEA_LEVEL.datum);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -112,12 +112,10 @@ public final strictfp class CommonAuthor
     @Test
     public void testAuthority() {
         final Citation authority = factory.getAuthority();
-        assertFalse(Citations.identifierMatches(authority, "CRS"));
-        assertTrue (Citations.identifierMatches(authority, "OGC"));
+        assertTrue (Citations.identifierMatches(authority, "WMS"));
         assertFalse(Citations.identifierMatches(authority, "OGP"));
         assertFalse(Citations.identifierMatches(authority, "EPSG"));
-        assertFalse(Citations.identifierMatches(authority, "AUTO"));
-        assertFalse(Citations.identifierMatches(authority, "AUTO2"));
+        assertEquals(Constants.OGC, org.apache.sis.internal.util.Citations.getCodeSpace(authority));
     }
 
     /**
@@ -355,6 +353,15 @@ public final strictfp class CommonAuthor
                 "    ANGLEUNIT[“degree”, 0.017453292519943295],\n" +
                 "  AREA[“World”],\n" +
                 "  BBOX[-90.00, -180.00, 90.00, 180.00],\n" +
-                "  ID[“CRS”, 84, CITATION[“OGC”], URI[“urn:ogc:def:crs:OGC::84”]]]", crs);  // TODO: URI needs tuning.
+                "  ID[“CRS”, 84, CITATION[“OGC:WMS”], URI[“urn:ogc:def:crs:OGC:1.3:CRS84”]]]", crs);
+        /*
+         * Note: the WKT specification defines the ID element as:
+         *
+         *     ID[authority, code, (version), (authority citation), (URI)]
+         *
+         * where everything after the code is optional. The difference between "authority" and "authority citation"
+         * is unclear. The only example found in OGC 12-063r5 uses CITATION[…] as the source of an EPSG definition
+         * (so we could almost said "the authority of the authority").
+         */
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/CitationConstant.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -82,7 +82,7 @@ public class CitationConstant extends Si
          * </ul>
          */
         @Override
-        public final String getName() {
+        public String getName() {
             return title;
         }
 
@@ -92,7 +92,7 @@ public class CitationConstant extends Si
         @Debug
         @Override
         public final String toString() {
-            return "IdentifierSpace[“" + getName() + "”]";
+            return "IdentifierSpace[" + title + ']';
         }
     }
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -41,7 +41,7 @@ import java.util.Objects;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class Citations extends Static {
@@ -106,7 +106,7 @@ public final class Citations extends Sta
      *
      * @param  s1 The first characters sequence to compare, or {@code null}.
      * @param  s2 The second characters sequence to compare, or {@code null}.
-     * @return {@code true}if both arguments are {@code null} or if the two given texts are equal,
+     * @return {@code true} if both arguments are {@code null} or if the two given texts are equal,
      *         ignoring case and any characters other than digits and letters.
      *
      * @since 0.6
@@ -139,7 +139,7 @@ public final class Citations extends Sta
                         return true;
                     }
                     final String localized = candidate.toString();
-                    if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
+                    if (!Objects.equals(localized, unlocalized)             // Slight optimization for a common case.
                             && titleMatches(c1, localized))
                     {
                         return true;
@@ -178,7 +178,7 @@ public final class Citations extends Sta
                         return true;
                     }
                     final String localized = candidate.toString();
-                    if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case.
+                    if (!Objects.equals(localized, unlocalized)             // Slight optimization for a common case.
                             && equalsFiltered(localized, title))
                     {
                         return true;
@@ -209,7 +209,7 @@ public final class Citations extends Sta
     public static boolean identifierMatches(Citation c1, Citation c2) {
         if (c1 != null && c2 != null) {
             if (c1 == c2) {
-                return true; // Optimisation for a common case.
+                return true;                            // Optimisation for a common case.
             }
             /*
              * If there is no identifier in both citations, fallback on title comparisons.
@@ -369,9 +369,9 @@ public final class Citations extends Sta
                     final String candidate = CharSequences.trimWhitespaces(id.getCode());
                     if (candidate != null && !candidate.isEmpty()) {
                         /*
-                         * For a non-empty identifier. Verify if both the code ans its codespace are valid
-                         * Unicode identifiers. If a codespace exist, the code does not need to begin with
-                         * a "Unicode identifier start" (it may be a "Unicode identifier part").
+                         * For a non-empty identifier, verify if both the code and its codespace are valid
+                         * Unicode identifiers. If a codespace exists, then the code does not need to begin
+                         * with a "Unicode identifier start" (it may be a "Unicode identifier part").
                          */
                         String cs = CharSequences.trimWhitespaces(id.getCodeSpace());
                         if (cs == null || cs.isEmpty()) {
@@ -381,7 +381,11 @@ public final class Citations extends Sta
                             isUnicode = CharSequences.isUnicodeIdentifier(cs);
                             if (isUnicode) for (int i = 0; i < candidate.length();) {
                                 final int c = candidate.codePointAt(i);
-                                if (!Character.isUnicodeIdentifierPart(c)) {
+                                if (!Character.isUnicodeIdentifierPart(c) &&
+                                        (strict || (c != '.' && c != '-')))
+                                {
+                                    // Above special case for '.' and '-' characters is documented
+                                    // in the public Citations.getIdentifier(Citation) method.
                                     isUnicode = false;
                                     break;
                                 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -521,6 +521,8 @@ public final class DefinitionURI {
      * @param  version   The code version, or {@code null}. This is the only optional information.
      * @param  code      The code, or {@code null}.
      * @return An identifier using the URN syntax, or {@code null} if a mandatory information is missing.
+     *
+     * @see org.apache.sis.internal.metadata.NameMeaning#toURN(Class, String, String, String)
      */
     public static String format(final String type, final String authority, final String version, final String code) {
         final StringBuilder buffer = new StringBuilder(PREFIX);

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java?rev=1726433&r1=1726432&r2=1726433&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] Sat Jan 23 18:26:30 2016
@@ -18,6 +18,7 @@ package org.apache.sis.internal.util;
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.apache.sis.internal.simple.SimpleCitation;
@@ -35,11 +36,23 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final strictfp class CitationsTest extends TestCase {
     /**
+     * Creates a citation with the given title and the given identifiers.
+     */
+     @SuppressWarnings("serial")
+     private static SimpleCitation citation(final String title, final Identifier... identifiers) {
+        return new SimpleCitation(title) {
+            @Override public List<Identifier> getIdentifiers() {
+                return Arrays.asList(identifiers);
+            }
+        };
+    }
+
+    /**
      * Creates an identifier with a code space.
      */
      @SuppressWarnings("serial")
@@ -93,6 +106,13 @@ public final strictfp class CitationsTes
         citation = new SimpleCitation(" ValidIdentifier ");
         assertEquals("ValidIdentifier", Citations.getIdentifier(citation, false));
         assertEquals("ValidIdentifier", Citations.getIdentifier(citation, true));
+        /*
+         * Following test uses '-' in the first identifier, which is an invalid Unicode identifier part.
+         * Consequently the identifier that we get depends on whether we ask for strict Unicode or not.
+         */
+        citation = citation("Web Map Server", identifier("OGC", "06-042"), identifier("ISO", "19128"));
+        assertEquals("OGC:06-042", Citations.getIdentifier(citation, false));
+        assertEquals("ISO_19128",  Citations.getIdentifier(citation, true));
     }
 
     /**



Mime
View raw message