sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1685871 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-referencing/src/test/java/org/apache/sis/io/wkt/ sis-referencing/src/test/java/org/apa...
Date Tue, 16 Jun 2015 17:23:09 GMT
Author: desruisseaux
Date: Tue Jun 16 17:23:09 2015
New Revision: 1685871

URL: http://svn.apache.org/r1685871
Log:
WKT 2: fixed the spelling of "Remark" (without trailing "s") and completed the support of
"ID" keyword.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -60,7 +60,7 @@ public final class WKTKeywords extends S
             Anchor    = "Anchor",
             Scope     = "Scope",
             Area      = "Area",
-            Remarks   = "Remarks";
+            Remark    = "Remark";
 
     /**
      * Related to unit of measurements.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -107,12 +107,14 @@ public enum Convention {
      * names when available.</p>
      *
      * <div class="section">Differences compared to WKT 2</div>
-     * WKT 1 and WKT 2 differ in their keywords and syntax, but also in more subtle ways
regarding parameter
-     * and code list values. For {@link GeocentricCRS}, WKT 1 uses a legacy set of Cartesian
axes which were
-     * defined in OGC 01-009. Those axes use the <var>Other</var>, <var>Easting</var>
and <var>Northing</var>
-     * {@linkplain org.opengis.referencing.cs.AxisDirection axis directions} instead than
the geocentric ones,
-     * as shown in the following table:
+     * WKT 1 and WKT 2 differ in their keywords and syntax, but also in more subtle ways
regarding axis names,
+     * parameter and code list values. For example in  {@link GeocentricCRS}, WKT 1 uses
a legacy set of Cartesian axes
+     * which were defined in OGC 01-009. Those axes use the <var>Other</var>,
<var>Easting</var> and <var>Northing</var>
+     * {@linkplain org.opengis.referencing.cs.AxisDirection axis directions} instead than
the geocentric ones.
+     * For more uniform handling of CRS objects in client code, SIS parser replaces some
WKT 1 conventions by
+     * the ISO ones when possible.
      *
+     * <table class="compact" summary="Differences between current and legacy specifications"><tr><td>
      * <table class="sis">
      *   <caption>Geocentric axis directions</caption>
      *   <tr><th>ISO 19111</th>    <th>OGC 01-009</th> <th>Description</th></tr>
@@ -120,6 +122,16 @@ public enum Convention {
      *   <tr><td>Geocentric Y</td> <td>Easting</td>    <td>Toward
90°E longitude</td></tr>
      *   <tr><td>Geocentric Z</td> <td>Northing</td>   <td>Toward
north pole</td></tr>
      * </table>
+     * </td><td>
+     * <table class="sis">
+     *   <caption>Coordinate system axis names</caption>
+     *   <tr><th>CRS type</th>   <th>WKT1 names</th>      
                        <th>ISO abbreviations</th></tr>
+     *   <tr><td>Geographic</td> <td>Lon, Lat</td>        
                        <td>λ, φ</td></tr>
+     *   <tr><td>Vertical</td>   <td><var>H</var></td>
                            <td><var>H</var> or <var>h</var></td></tr>
+     *   <tr><td>Projected</td>  <td><var>X</var>, <var>Y</var></td>
              <td><var>E</var>, <var>N</var></td></tr>
+     *   <tr><td>Geocentric</td> <td><var>X</var>, <var>Y</var>,
<var>Z</var></td> <td><var>X</var>, <var>Y</var>,
<var>Z</var></td></tr>
+     * </table>
+     * </td></tr></table>
      *
      * @see <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html">Legacy
WKT 1</a>
      */

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
Tue Jun 16 17:23:09 2015
@@ -560,6 +560,25 @@ final class Element {
     }
 
     /**
+     * Removes the next object of the given type from the list and returns it, if presents.
+     *
+     * @param  type The object type.
+     * @return The next object on the list, or {@code null} if none.
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T pullOptional(final Class<T> type) {
+        final Iterator<Object> iterator = list.iterator();
+        while (iterator.hasNext()) {
+            final Object object = iterator.next();
+            if (type.isInstance(object)) {
+                iterator.remove();
+                return (T) object;
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns the next element, or {@code null} if there is no more element.
      * The element is <strong>not</strong> removed from the list.
      *

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -745,7 +745,7 @@ public class Formatter implements Locali
             }
         }
         if (showRemarks) {
-            appendOnNewLine(WKTKeywords.Remarks, object.getRemarks(), ElementKind.REMARKS);
+            appendOnNewLine(WKTKeywords.Remark, object.getRemarks(), ElementKind.REMARKS);
         }
         isComplement = false;
     }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.HashMap;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.text.DateFormat;
 import java.text.NumberFormat;
@@ -375,13 +376,25 @@ final class GeodeticObjectParser extends
         assert (name instanceof String) || (name instanceof Identifier);
         properties.clear();
         properties.put(IdentifiedObject.NAME_KEY, name);
-        Element element = parent.pullOptionalElement(WKTKeywords.Id, WKTKeywords.Authority);
-        if (element != null) {
-            final String auth = element.pullString("name");
-            final String code = element.pullObject("code").toString();  // Accepts Integer
as well as String.
+        Element element;
+        while ((element = parent.pullOptionalElement(WKTKeywords.Id, WKTKeywords.Authority))
!= null) {
+            final String   codeSpace = element.pullString("name");
+            final String   code      = element.pullObject("code").toString();   // Accepts
Integer as well as String.
+            final Object   version   = element.pullOptional(Object.class);      // Accepts
Number as well as String.
+            final Element  citation  = element.pullOptionalElement(WKTKeywords.Citation);
+            final String   authority;
+            if (citation != null) {
+                authority = citation.pullString("authority");
+                citation.close(ignoredElements);
+            } else {
+                authority = codeSpace;
+            }
+            final Element uri = element.pullOptionalElement(WKTKeywords.URI);
+            if (uri != null) {
+                uri.pullString("URI");      // TODO: not yet stored, since often redundant
with other informations.
+                uri.close(ignoredElements);
+            }
             element.close(ignoredElements);
-            final Citation authority = Citations.fromName(auth);
-            properties.put(IdentifiedObject.IDENTIFIERS_KEY, new ImmutableIdentifier(authority,
auth, code));
             /*
              * Note: we could be tempted to assign the authority to the name as well, like
below:
              *
@@ -395,6 +408,21 @@ final class GeodeticObjectParser extends
              * (for example "WGS84" for the datum instead than "World Geodetic System 1984"),
              * so the name in WKT is often not compliant with the name actually defined by
the authority.
              */
+            final ImmutableIdentifier id = new ImmutableIdentifier(Citations.fromName(authority),
+                    codeSpace, code, (version != null) ? version.toString() : null, null);
+            final Object previous = properties.put(IdentifiedObject.IDENTIFIERS_KEY, id);
+            if (previous != null) {
+                Identifier[] identifiers;
+                if (previous instanceof Identifier) {
+                    identifiers = new Identifier[] {(Identifier) previous, id};
+                } else {
+                    identifiers = (Identifier[]) previous;
+                    final int n = identifiers.length;
+                    identifiers = Arrays.copyOf(identifiers, n + 1);
+                    identifiers[n] = id;
+                }
+                properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifiers);
+            }
         }
         /*
          * Other metadata (SCOPE, AREA, etc.).  ISO 19162 said that at most one of each type
shall be present,
@@ -472,6 +500,14 @@ final class GeodeticObjectParser extends
                     warning(parent, element, e);
                 }
             }
+            /*
+             * Example: REMARK["Замечание на русском языке"]
+             */
+            element = parent.pullOptionalElement(WKTKeywords.Remark);
+            if (element != null) {
+                properties.put(IdentifiedObject.REMARKS_KEY, element.pullString("remarks"));
+                element.close(ignoredElements);
+            }
         }
         parent.close(ignoredElements);
         return properties;

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
Tue Jun 16 17:23:09 2015
@@ -37,19 +37,6 @@ import org.opengis.util.FactoryException
  *   <li>{@link org.apache.sis.geometry.Envelopes#fromWKT(CharSequence)}</li>
  * </ul>
  *
- * <div class="section">Axis names</div>
- * The WKT 1 specification defined axis names different than the ISO 19111 ones.
- * This SIS parser replaces the WKT 1 names by the ISO names and abbreviations when possible.
- *
- * <table class="sis">
- *   <caption>Coordinate system axis names</caption>
- *   <tr><th>CRS type</th>   <th>WKT1 names</th>          
                    <th>ISO abbreviations</th></tr>
- *   <tr><td>Geographic</td> <td>Lon, Lat</td>            
                    <td>λ, φ</td></tr>
- *   <tr><td>Vertical</td>   <td><var>H</var></td>
                            <td><var>H</var> or <var>h</var></td></tr>
- *   <tr><td>Projected</td>  <td><var>X</var>, <var>Y</var></td>
              <td><var>E</var>, <var>N</var></td></tr>
- *   <tr><td>Geocentric</td> <td><var>X</var>, <var>Y</var>,
<var>Z</var></td> <td><var>X</var>, <var>Y</var>,
<var>Z</var></td></tr>
- * </table>
- *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
  * @version 0.6

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -69,6 +69,9 @@ public final strictfp class GeodeticObje
     /**
      * Parses the given text.
      *
+     * @param  type The expected object type.
+     * @param  text The WKT string to parse.
+     * @return The parsed object.
      * @throws ParseException if an error occurred during the parsing.
      */
     private <T> T parse(final Class<T> type, final String text) throws ParseException
{

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -123,7 +123,7 @@ public final strictfp class AbstractRefe
                 "  BBox[51.43, 2.54, 55.77, 6.40],\n" +
                 "  VerticalExtent[-1000, -10, LengthUnit[“metre”, 1]],\n" +
                 "  Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
-                "  Remarks[“注です。”]]",
+                "  Remark[“注です。”]]",
                 object);
 
         assertWktEquals(Convention.WKT2_SIMPLIFIED,
@@ -133,7 +133,7 @@ public final strictfp class AbstractRefe
                 "  BBox[51.43, 2.54, 55.77, 6.40],\n" +
                 "  VerticalExtent[-1000, -10],\n" +
                 "  Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n"
+
-                "  Remarks[“注です。”]]",
+                "  Remark[“注です。”]]",
                 object);
 
         assertWktEquals(Convention.INTERNAL,
@@ -143,7 +143,7 @@ public final strictfp class AbstractRefe
                 "  BBox[51.43, 2.54, 55.77, 6.40],\n" +
                 "  VerticalExtent[-1000, -10],\n" +
                 "  Id[“EPSG”, 4326, “8.2”],\n" +
-                "  Remarks[“注です。”]]",
+                "  Remark[“注です。”]]",
                 object);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -274,13 +274,13 @@ public final strictfp class DefaultGeode
         assertWktEquals(Convention.INTERNAL,
                 "Datum[“World Geodetic System 1984”,\n" +
                 "  Ellipsoid[“WGS 84”, 6378137.0, 298.257223563, Id[“EPSG”, 7030],\n"
+
-                "    Remarks[“Defining parameters cited in EPSG database.”]],\n" +
+                "    Remark[“Defining parameters cited in EPSG database.”]],\n" +
                 "  Anchor[“Station coordinates changed by a few centimetres in 1994, 1997,
2002 and 2012.”],\n" +
                 "  Scope[“Satellite navigation.”],\n" +
                 "  Area[“World.”],\n" +
                 "  BBox[-90.00, -180.00, 90.00, 180.00],\n" +
                 "  Id[“EPSG”, 6326],\n" +
-                "  Remarks[“No distinction between the original and subsequent WGS 84 frames.”]]",
+                "  Remark[“No distinction between the original and subsequent WGS 84 frames.”]]",
                 datum);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1685871&r1=1685870&r2=1685871&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] Tue Jun 16 17:23:09 2015
@@ -153,7 +153,7 @@ public final strictfp class DefaultPrime
                 "PrimeMeridian[“Paris”, 2.5969213, AngleUnit[“grade”, 0.015707963267948967],
Id[“EPSG”, 8903, URI[“urn:ogc:def:meridian:EPSG::8903”]]]", pm);
         assertWktEquals(Convention.INTERNAL,
                 "PrimeMeridian[“Paris”, 2.5969213, Unit[“grade”, 0.015707963267948967],
Id[“EPSG”, 8903],\n" +
-                "  Remarks[“Equivalent to 2°20′14.025″.”]]", pm);
+                "  Remark[“Equivalent to 2°20′14.025″.”]]", pm);
         assertXmlEquals(
                 "<gml:PrimeMeridian xmlns:gml=\"" + Namespaces.GML + "\">\n" +
                 "  <gml:identifier codeSpace=\"IOGP\">urn:ogc:def:meridian:EPSG::8903</gml:identifier>\n"
+



Mime
View raw message