sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1568339 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/ sis-referencing/src/main/java/org/apach...
Date Fri, 14 Feb 2014 15:50:34 GMT
Author: desruisseaux
Date: Fri Feb 14 15:50:34 2014
New Revision: 1568339

URL: http://svn.apache.org/r1568339
Log:
WKT bug fix: the citation element inside ID[...] needs to be wrapped inside a CITATION[...]
element.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Colors.java [UTF-8]
Fri Feb 14 15:50:34 2014
@@ -69,6 +69,7 @@ public class Colors implements Cloneable
         map.put(ElementKind.ERROR,      X364.BACKGROUND_RED);
         map.put(ElementKind.SCOPE,      X364.BACKGROUND_GRAY);
         map.put(ElementKind.EXTENT,     X364.BACKGROUND_GRAY);
+        map.put(ElementKind.CITATION,   X364.BACKGROUND_GRAY);
         map.put(ElementKind.REMARKS,    X364.BACKGROUND_GRAY);
         CONSOLE.isImmutable = true;
     }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -18,6 +18,7 @@ package org.apache.sis.io.wkt;
 
 import javax.measure.unit.Unit;
 import org.opengis.util.CodeList;
+import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.datum.Datum;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.operation.OperationMethod;
@@ -36,6 +37,11 @@ import org.apache.sis.util.Numbers;
  */
 public enum ElementKind {
     /**
+     * Object name, typically written immediately after the WKT keyword and its opening bracket.
+     */
+    NAME,
+
+    /**
      * Floating point numbers (excluding integer types).
      */
     NUMBER,
@@ -93,6 +99,12 @@ public enum ElementKind {
     EXTENT,
 
     /**
+     * Citation (typically for the {@linkplain org.apache.sis.metadata.iso.ImmutableIdentifier#getAuthority()
+     * authority}), often represented by {@code CITATION[…]} elements.
+     */
+    CITATION,
+
+    /**
      * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getRemarks() Remarks},
      * often represented by {@code REMARKS[…]} elements.
      */
@@ -113,6 +125,7 @@ public enum ElementKind {
      *   <tr><td>{@link OperationMethod}</td>       <td>{@link #METHOD}</td></tr>
      *   <tr><td>{@link GeneralParameterValue}</td> <td>{@link #PARAMETER}</td></tr>
      *   <tr><td>{@link CoordinateSystemAxis}</td>  <td>{@link #AXIS}</td></tr>
+     *   <tr><td>{@link Citation}</td>              <td>{@link #CITATION}</td></tr>
      *   <tr><td>{@link CodeList}</td>              <td>{@link #CODE_LIST}</td></tr>
      *   <tr><td>{@link Unit}</td>                  <td>{@link #UNIT}</td></tr>
      *   <tr><td>{@link Number}</td>                <td>{@link #INTEGER}
or {@link #NUMBER}</td></tr>
@@ -130,6 +143,7 @@ public enum ElementKind {
             if (OperationMethod      .class.isAssignableFrom(type)) return METHOD;
             if (GeneralParameterValue.class.isAssignableFrom(type)) return PARAMETER;
             if (CoordinateSystemAxis .class.isAssignableFrom(type)) return AXIS;
+            if (Citation             .class.isAssignableFrom(type)) return CITATION;
             if (CodeList             .class.isAssignableFrom(type)) return CODE_LIST;
             if (Unit                 .class.isAssignableFrom(type)) return UNIT;
             if (Number.class.isAssignableFrom(type)) {

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -34,6 +34,7 @@ import org.apache.sis.internal.util.Defi
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.io.wkt.ElementKind;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
@@ -568,7 +569,9 @@ public class ImmutableIdentifier extends
                     appendCode(formatter, code);
                     if (version != null) {
                         appendCode(formatter, version);
-                        formatter.append(citation, null);
+                    }
+                    if (citation != null && !citation.equals(cs)) {
+                        formatter.append(new Cite(citation));
                     }
                     /*
                      * Do not format the optional URI element for internal convention,
@@ -610,6 +613,26 @@ public class ImmutableIdentifier extends
     }
 
     /**
+     * The {@code CITATION[…]} element inside an {@code ID[…]}.
+     */
+    private static final class Cite extends FormattableObject {
+        /** The component of the citation to format. */
+        private final String identifier;
+
+        /** Creates a new citation with the given component. */
+        Cite(final String identifier) {
+            this.identifier = identifier;
+        }
+
+        /** Formats the citation. */
+        @Override
+        protected String formatTo(final Formatter formatter) {
+            formatter.append(identifier, ElementKind.CITATION);
+            return "Citation";
+        }
+    }
+
+    /**
      * The {@code URI[…]} element inside an {@code ID[…]}.
      */
     private static final class URI extends FormattableObject {

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -176,7 +176,7 @@ public final strictfp class ImmutableIde
     @Test
     public void testWKT() {
         final ImmutableIdentifier id = new ImmutableIdentifier(HardCodedCitations.OGP, "EPSG",
"4326", "8.2", null);
-        assertWktEquals(Convention.WKT2, "Id[“EPSG”, 4326, “8.2”, “OGP”]", id);
+        assertWktEquals(Convention.WKT2, "Id[“EPSG”, 4326, “8.2”, Citation[“OGP”]]",
id);
         assertWktEquals(Convention.WKT1, "AUTHORITY[“EPSG”, “4326”]", id);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -59,7 +59,7 @@ public final class WKTUtilities extends 
                 name = Vocabulary.getResources(formatter.getLocale()).getString(Vocabulary.Keys.Unnamed);
             }
         }
-        formatter.append(name, type);
+        formatter.append(name, (type != null) ? type : ElementKind.NAME);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -120,7 +120,7 @@ public final strictfp class AbstractRefe
                 "  Area[“Netherlands offshore.”],\n" +
                 "  BBox[51.43, 2.54, 55.77, 6.40],\n" +
                 "  VerticalExtent[-1000, -10, LengthUnit[“metre”, 1]],\n" +
-                "  Id[“EPSG”, 4326, “8.2”, “OGP”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
+                "  Id[“EPSG”, 4326, “8.2”, Citation[“OGP”], URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
                 "  Remarks[“注です。”]]",
                 object);
 
@@ -130,7 +130,7 @@ public final strictfp class AbstractRefe
                 "  Area[“Netherlands offshore.”],\n" +
                 "  BBox[51.43, 2.54, 55.77, 6.40],\n" +
                 "  VerticalExtent[-1000, -10],\n" +
-                "  Id[“EPSG”, 4326, “8.2”, “OGP”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
+                "  Id[“EPSG”, 4326, “8.2”, Citation[“OGP”], URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
                 "  Remarks[“注です。”]]",
                 object);
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -267,17 +267,17 @@ public final strictfp class DefaultGeode
         assertWktEquals(Convention.WKT2,
                 "Datum[“World Geodetic System 1984”,\n" +
                 "  Spheroid[“WGS 84”, 6378137.0, 298.257223563],\n" +
-                "  Id[“EPSG”, 6326, URI[“urn:ogc:def:datum:EPSG::6326”]]]",
+                "  Id[“EPSG”, 6326, Citation[“OGP”], URI[“urn:ogc:def:datum:EPSG::6326”]]]",
                 datum);
 
         assertWktEquals(Convention.INTERNAL,
                 "Datum[“World Geodetic System 1984”,\n" +
-                "  Spheroid[“WGS 84”, 6378137.0, 298.257223563, Id[“EPSG”, 7030],\n"
+
+                "  Spheroid[“WGS 84”, 6378137.0, 298.257223563, Id[“EPSG”, 7030,
Citation[“OGP”]],\n" +
                 "    Remarks[“Defining parameters cited in EPSG database.”]],\n" +
                 "  Scope[“Satellite navigation.”],\n" +
                 "  Area[“World.”],\n" +
                 "  BBox[-90.00, -180.00, 90.00, 180.00],\n" +
-                "  Id[“EPSG”, 6326],\n" +
+                "  Id[“EPSG”, 6326, Citation[“OGP”]],\n" +
                 "  Remarks[“No distinction between the original and subsequent WGS 84 frames.”]]",
                 datum);
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1568339&r1=1568338&r2=1568339&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] Fri Feb 14 15:50:34 2014
@@ -148,9 +148,9 @@ public final strictfp class DefaultPrime
         assertEquals("Equivalent to 2°20′14.025″.", pm.getRemarks().toString());
         assertNull("name.codeSpace", pm.getName().getCodeSpace());
         assertWktEquals(
-                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903, URI[“urn:ogc:def:meridian:EPSG::8903”]]]",
pm);
+                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903, Citation[“OGP”],
URI[“urn:ogc:def:meridian:EPSG::8903”]]]", pm);
         assertWktEquals(Convention.INTERNAL,
-                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903],\n" +
+                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903, Citation[“OGP”]],\n"
+
                 "  Remarks[“Equivalent to 2°20′14.025″.”]]", pm);
         assertXmlEquals(
                 "<gml:PrimeMeridian xmlns:gml=\"" + Namespaces.GML + "\">\n" +



Mime
View raw message