sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1568847 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-referencing/src/test/java/org/apache/sis/referencing/crs/ sis-referencing/src/test/...
Date Sun, 16 Feb 2014 22:16:50 GMT
Author: desruisseaux
Date: Sun Feb 16 22:16:49 2014
New Revision: 1568847

URL: http://svn.apache.org/r1568847
Log:
WKT 2 formatting for DefaultPrimeMeridian.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.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/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1568847&r1=1568846&r2=1568847&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Sun Feb 16 22:16:49 2014
@@ -58,10 +58,10 @@ public enum Convention {
      * This convention follows the ISO recommendations except the following ones:
      *
      * <ul>
-     *   <li>{@code AXIS} element omits the {@code ORDER} sub-element.</li>
+     *   <li>{@code Axis} element omits the {@code Order} sub-element.</li>
      * </ul>
      *
-     * Since the {@code ORDER} element is optional, the WKT is still valid.
+     * Since the {@code Order} element is optional, the WKT is still valid.
      *
      * <p>Unless otherwise specified by {@link WKTFormat#setNameAuthority(Citation)},
projections
      * and parameters formatted with this convention will use the {@linkplain Citations#EPSG
EPSG}
@@ -77,14 +77,16 @@ public enum Convention {
      * to the {@link #WKT2} convention except for the following aspects:
      *
      * <ul>
-     *   <li>{@code VERTICALEXTENT} element omits the {@code UNIT} sub-element
+     *   <li>{@code VerticalExtent} element omits the {@code LengthUnit} sub-element
      *       if the unit is {@link javax.measure.unit.SI#METRE}.</li>
-     *   <li>{@code ELLIPSOID} element omits the {@code UNIT} sub-element
+     *   <li>{@code Ellipsoid} element omits the {@code LengthUnit} sub-element
      *       if the unit is {@link javax.measure.unit.SI#METRE}.</li>
-     *   <li>{@code ANGLEUNIT}, {@code LENGTHUNIT}, {@code SCALEUNIT}, {@code PARAMETRICUNIT}
-     *       and {@code TIMEUNIT} are formatted as plain {@code UNIT} elements.</li>
-     *   <li>{@code ID} is formatted only for the root element
-     *       (omit parameters and operation methods {@code ID}).</li>
+     *   <li>{@code PrimeMeridian} element omits the {@code AngleUnit} sub-element
+     *       if the unit is as defined by the enclosing {@code GeodeticCRS} element.</li>
+     *   <li>{@code AngleUnit}, {@code LengthUnit}, {@code ScaleUnit}, {@code ParametricUnit}
+     *       and {@code TimeUnit} are formatted as plain {@code Unit} elements.</li>
+     *   <li>{@code Id} is formatted only for the root element
+     *       (omit parameters and operation methods {@code Id}).</li>
      * </ul>
      *
      * Those modifications are allowed by the ISO 19162 standard, so the WKT is still valid.
@@ -143,10 +145,10 @@ public enum Convention {
      * <ul>
      *   <li>Map projections are shown as SIS stores them internally, i.e. with the
separation between
      *       linear and non-linear steps, rather than as a single operation.</li>
-     *   <li>{@code ID} elements are formatted for child elements in addition to the
root one.</li>
-     *   <li>{@code ID} element omits the {@code URI} sub-element if the later is derived
by Apache SIS
-     *       from the {@code ID} properties.</li>
-     *   <li>{@code REMARKS} element is formatted for all
+     *   <li>{@code Id} elements are formatted for child elements in addition to the
root one.</li>
+     *   <li>{@code Id} element omits the {@code URI} sub-element if the later is derived
by Apache SIS
+     *       from the {@code Id} properties.</li>
+     *   <li>{@code Remarks} element is formatted for all
      *       {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject identified objects},
      *       not only CRS or coordinate operations.</li>
      * </ul>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1568847&r1=1568846&r2=1568847&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
[UTF-8] Sun Feb 16 22:16:49 2014
@@ -31,6 +31,7 @@ import org.apache.sis.referencing.Abstra
 import org.apache.sis.internal.jaxb.gco.Measure;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.ComparisonMode;
 
 import static org.apache.sis.util.ArgumentChecks.ensureFinite;
@@ -339,11 +340,19 @@ public class DefaultPrimeMeridian extend
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
+        final Convention convention = formatter.getConvention();
+        final boolean isWKT1 = convention.versionOfWKT() == 1;
         Unit<Angle> targetUnit = formatter.getContextualUnit(Angle.class);
         if (targetUnit == null) {
             targetUnit = NonSI.DEGREE_ANGLE;
         }
-        formatter.append(getGreenwichLongitude(targetUnit));
-        return "PrimeM";
+        formatter.append(isWKT1 ? getGreenwichLongitude(targetUnit) : greenwichLongitude);
+        if (isWKT1) {
+            return "PrimeM";
+        }
+        if (!convention.isSimplified() || !targetUnit.equals(angularUnit)) {
+            formatter.append(angularUnit);
+        }
+        return "PrimeMeridian";
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java?rev=1568847&r1=1568846&r2=1568847&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
[UTF-8] Sun Feb 16 22:16:49 2014
@@ -87,7 +87,7 @@ public final strictfp class HardCodedCRS
                 "GeodeticCRS[“WGS 84”,\n" +
                 "  Datum[“World Geodetic System 1984”,\n" +
                 "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]],\n" +
-                "  PrimeM[“Greenwich”, 0.0],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n"
+
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Longitude (λ)”, east],\n" +
                 "    Axis[“Latitude (φ)”, north],\n" +
@@ -100,7 +100,7 @@ public final strictfp class HardCodedCRS
                 "GeodeticCRS[“WGS 84”,\n" +
                 "  Datum[“World Geodetic System 1984”,\n" +
                 "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
-                "  PrimeM[“Greenwich”, 0.0],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0],\n" +
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Longitude (λ)”, east],\n" +
                 "    Axis[“Latitude (φ)”, north],\n" +
@@ -114,7 +114,7 @@ public final strictfp class HardCodedCRS
                 "  Datum[“World Geodetic System 1984”,\n" +
                 "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563],\n" +
                 "    Id[“EPSG”, 6326]],\n" +
-                "  PrimeM[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Geodetic longitude (λ)”, east],\n" +
                 "    Axis[“Geodetic latitude (φ)”, north],\n" +

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=1568847&r1=1568846&r2=1568847&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] Sun Feb 16 22:16:49 2014
@@ -58,7 +58,7 @@ public final strictfp class DefaultPrime
     public void testToWKT() {
         final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
         assertIsGreenwich(pm);
-        assertWktEquals("PrimeM[“Greenwich”, 0.0]", pm);
+        assertWktEquals("PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]]",
pm);
     }
 
     /**
@@ -147,10 +147,12 @@ public final strictfp class DefaultPrime
         assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(NonSI.DEGREE_ANGLE),
1E-12);
         assertEquals("Equivalent to 2°20′14.025″.", pm.getRemarks().toString());
         assertNull("name.codeSpace", pm.getName().getCodeSpace());
-        assertWktEquals(
-                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903, Citation[“OGP”],
URI[“urn:ogc:def:meridian:EPSG::8903”]]]", pm);
+        assertWktEquals(Convention.WKT1,
+                "PRIMEM[“Paris”, 2.33722917, AUTHORITY[“EPSG”, “8903”]]", pm);
+        assertWktEquals(Convention.WKT2,
+                "PrimeMeridian[“Paris”, 2.5969213, AngleUnit[“grade”, 0.015707963267948967],
Id[“EPSG”, 8903, Citation[“OGP”], URI[“urn:ogc:def:meridian:EPSG::8903”]]]", pm);
         assertWktEquals(Convention.INTERNAL,
-                "PrimeM[“Paris”, 2.33722917, Id[“EPSG”, 8903, Citation[“OGP”]],\n"
+
+                "PrimeMeridian[“Paris”, 2.5969213, Unit[“grade”, 0.015707963267948967],
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