sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1569694 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ main/java/org/apache/sis/referencing/cs/ test/java/org/apache/sis/internal/referencing/ test/java/org/apache/sis/referencing/crs/ test...
Date Wed, 19 Feb 2014 11:37:55 GMT
Author: desruisseaux
Date: Wed Feb 19 11:37:55 2014
New Revision: 1569694

URL: http://svn.apache.org/r1569694
Log:
Added test for GeocentricCRS WKT 2 formatting.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?rev=1569694&r1=1569693&r2=1569694&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] Wed Feb 19 11:37:55 2014
@@ -214,6 +214,19 @@ public final class AxisDirections extend
     }
 
     /**
+     * Returns {@code true} if the given direction is {@code GEOCENTRIC_X}, {@code GEOCENTRIC_Y}
+     * or {@code GEOCENTRIC_Z}.
+     *
+     * @param  dir The direction to test, or {@code null}.
+     * @return {@code true} if the given direction is one of geocentric directions.
+     */
+    public static boolean isGeocentric(final AxisDirection dir) {
+        if (dir == null) return false;
+        final int ordinal = dir.ordinal();
+        return ordinal >= GEOCENTRIC_X.ordinal() && ordinal <= GEOCENTRIC_Z.ordinal();
+    }
+
+    /**
      * Returns {@code true} if the given direction is a spatial axis direction (including
vertical and geocentric axes).
      * The current implementation conservatively returns {@code true} for every non-null
directions except a hard-coded
      * set of directions which are known to be non-spatial. We conservatively accept unknown
axis directions because

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1569694&r1=1569693&r2=1569694&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Wed Feb 19 11:37:55 2014
@@ -31,7 +31,6 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.referencing.crs.GeodeticCRS;
-import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.RangeMeaning;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
@@ -723,13 +722,8 @@ public class DefaultCoordinateSystemAxis
      * the axis name should be omitted as it is given through the mandatory axis direction,
      * but the axis abbreviation, respectively ‘X’, 'Y' and ‘Z’, shall be given.
      */
-    private static boolean omitName(final Formatter formatter) {
-        if (formatter.getEnclosingElement(2) instanceof GeodeticCRS) {
-            if (formatter.getEnclosingElement(1) instanceof CartesianCS) {
-                return true;
-            }
-        }
-        return false;
+    private boolean omitName(final Formatter formatter) {
+        return AxisDirections.isGeocentric(direction) && formatter.getEnclosingElement(1)
instanceof GeodeticCRS;
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1569694&r1=1569693&r2=1569694&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] Wed Feb 19 11:37:55 2014
@@ -129,6 +129,20 @@ public final strictfp class AxisDirectio
     }
 
     /**
+     * Tests {@link AxisDirections#isGeocentric(AxisDirection)}.
+     */
+    @Test
+    public void testIsGeocentric() {
+        assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_X));
+        assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_Y));
+        assertTrue (AxisDirections.isGeocentric(GEOCENTRIC_Z));
+        assertFalse(AxisDirections.isGeocentric(NORTH));
+        assertFalse(AxisDirections.isGeocentric(UP));
+        assertFalse(AxisDirections.isGeocentric(DOWN));
+        assertFalse(AxisDirections.isGeocentric(FUTURE));
+    }
+
+    /**
      * Tests {@link AxisDirections#isSpatialOrUserDefined(AxisDirection, boolean)} and
      * {@link AxisDirections#isGrid(AxisDirection)}.
      */

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java?rev=1569694&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
[UTF-8] Wed Feb 19 11:37:55 2014
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.crs;
+
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests the {@link DefaultGeocentricCRS} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+    DefaultGeodeticCRSTest.class
+})
+public final strictfp class DefaultGeocentricCRSTest extends TestCase {
+    /**
+     * Tests WKT 1 formatting.
+     */
+    @Test
+    public void testWKT1() {
+        assertWktEquals(Convention.WKT1,
+                "GEOCCS[“Geocentric”,\n" +
+                "  DATUM[“World Geodetic System 1984”,\n" +
+                "    SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "  PRIMEM[“Greenwich”, 0.0],\n" +
+                "  UNIT[“metre”, 1],\n" +
+                "  AXIS[“X”, OTHER],\n" +
+                "  AXIS[“Y”, EAST],\n" +
+                "  AXIS[“Z”, NORTH]]",
+                HardCodedCRS.GEOCENTRIC);
+    }
+
+    /**
+     * Tests WKT 2 formatting.
+     *
+     * {@section Note on axis names}
+     * ISO 19162 said: “For geodetic CRSs having a geocentric Cartesian coordinate system,
+     * the axis name should be omitted as it is given through the mandatory axis direction,
+     * but the axis abbreviation, respectively ‘X’, 'Y' and ‘Z’, shall be given.”
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT2() {
+        assertWktEquals(Convention.WKT2,
+                "GeodeticCRS[“Geocentric”,\n" +
+                "  Datum[“World Geodetic System 1984”,\n" +
+                "    Ellipsoid[“WGS84”, 6378137.0, 298.257223563, LengthUnit[“metre”,
1]]],\n" +
+                "  PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n"
+
+                "  CS[“Cartesian”, 3],\n" +
+                "  Axis[“(X)”, geocentricX],\n" +
+                "  Axis[“(Y)”, geocentricY],\n" +
+                "  Axis[“(Z)”, geocentricZ],\n" +
+                "  LengthUnit[“metre”, 1]]",
+                HardCodedCRS.GEOCENTRIC);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1569694&r1=1569693&r2=1569694&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Wed Feb 19 11:37:55 2014
@@ -71,6 +71,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.cs.HardCodedCSTest.class,
     org.apache.sis.referencing.crs.AbstractCRSTest.class,
     org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
+    org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
     org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
     org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
     org.apache.sis.referencing.crs.SubTypesTest.class,



Mime
View raw message