sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1568843 - 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:02:51 GMT
Author: desruisseaux
Date: Sun Feb 16 22:02:51 2014
New Revision: 1568843

URL: http://svn.apache.org/r1568843
Log:
WKT 2 formatting for DefaultEllipsoid.

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/DefaultEllipsoid.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/DefaultEllipsoidTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.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=1568843&r1=1568842&r2=1568843&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:02:51 2014
@@ -79,6 +79,8 @@ public enum Convention {
      * <ul>
      *   <li>{@code VERTICALEXTENT} element omits the {@code UNIT} sub-element
      *       if the unit is {@link javax.measure.unit.SI#METRE}.</li>
+     *   <li>{@code ELLIPSOID} element omits the {@code UNIT} 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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1568843&r1=1568842&r2=1568843&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] Sun Feb 16 22:02:51 2014
@@ -37,6 +37,7 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
 
@@ -760,8 +761,20 @@ public class DefaultEllipsoid extends Ab
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        formatter.append(unit.getConverterTo(SI.METRE).convert(semiMajorAxis));
+        final Convention convention = formatter.getConvention();
+        final boolean isWKT1 = convention.versionOfWKT() == 1;
+        double length = semiMajorAxis;
+        if (isWKT1) {
+            length = unit.getConverterTo(SI.METRE).convert(length);
+        }
+        formatter.append(length);
         formatter.append(isInfinite(inverseFlattening) ? 0 : inverseFlattening);
-        return "Spheroid";
+        if (isWKT1) {
+            return "Spheroid";
+        }
+        if (!convention.isSimplified() || !SI.METRE.equals(unit)) {
+            formatter.append(unit);
+        }
+        return "Ellipsoid";
     }
 }

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=1568843&r1=1568842&r2=1568843&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:02:51 2014
@@ -86,7 +86,7 @@ public final strictfp class HardCodedCRS
         assertWktEquals(Convention.WKT2,
                 "GeodeticCRS[“WGS 84”,\n" +
                 "  Datum[“World Geodetic System 1984”,\n" +
-                "    Spheroid[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]],\n" +
                 "  PrimeM[“Greenwich”, 0.0],\n" +
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Longitude (λ)”, east],\n" +
@@ -99,7 +99,7 @@ public final strictfp class HardCodedCRS
         assertWktEquals(Convention.WKT2_SIMPLIFIED,
                 "GeodeticCRS[“WGS 84”,\n" +
                 "  Datum[“World Geodetic System 1984”,\n" +
-                "    Spheroid[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" +
                 "  PrimeM[“Greenwich”, 0.0],\n" +
                 "  CS[“ellipsoidal”, 2],\n" +
                 "    Axis[“Longitude (λ)”, east],\n" +
@@ -112,7 +112,7 @@ public final strictfp class HardCodedCRS
         assertWktEquals(Convention.INTERNAL,
                 "GeodeticCRS[“WGS 84”,\n" +
                 "  Datum[“World Geodetic System 1984”,\n" +
-                "    Spheroid[“WGS84”, 6378137.0, 298.257223563],\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563],\n" +
                 "    Id[“EPSG”, 6326]],\n" +
                 "  PrimeM[“Greenwich”, 0.0, Id[“EPSG”, 8901]],\n" +
                 "  CS[“ellipsoidal”, 2],\n" +

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java?rev=1568843&r1=1568842&r2=1568843&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] Sun Feb 16 22:02:51 2014
@@ -166,7 +166,7 @@ public final strictfp class DefaultEllip
     @Test
     public void testToWKT() {
         final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid());
-        assertWktEquals("Spheroid[“WGS84”, 6378137.0, 298.257223563]", e);
+        assertWktEquals("Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]", e);
     }
 
     /**

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=1568843&r1=1568842&r2=1568843&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] Sun Feb 16 22:02:51 2014
@@ -178,14 +178,14 @@ public final strictfp class DefaultGeode
     }
 
     /**
-     * Tests {@link DefaultEllipsoid#toWKT()}.
+     * Tests {@link DefaultGeodeticDatum#toWKT()}.
      */
     @Test
     public void testToWKT() {
         final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(WGS84);
         assertWktEquals(
                 "Datum[“WGS84”,\n" +
-                "  Spheroid[“WGS84”, 6378137.0, 298.257223563]]",
+                "  Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]]",
                 datum);
     }
 
@@ -256,7 +256,8 @@ public final strictfp class DefaultGeode
      * @throws JAXBException If an error occurred during unmarshalling.
      */
     @Test
-    public void testWKT() throws JAXBException {
+    @DependsOnMethod("testToWKT")
+    public void testUnmarshalledWKT() throws JAXBException {
         final DefaultGeodeticDatum datum = testUnmarshalling();
         assertWktEquals(Convention.WKT1,
                 "DATUM[“World Geodetic System 1984”,\n" +
@@ -266,13 +267,13 @@ public final strictfp class DefaultGeode
 
         assertWktEquals(Convention.WKT2,
                 "Datum[“World Geodetic System 1984”,\n" +
-                "  Spheroid[“WGS 84”, 6378137.0, 298.257223563],\n" +
+                "  Ellipsoid[“WGS 84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]],\n" +
                 "  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,
Citation[“OGP”]],\n" +
+                "  Ellipsoid[“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" +



Mime
View raw message