sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1558919 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/referencing/ test/java/org/apache/sis/referencing/ test/java/org/apache/sis/referencing/cs/
Date Thu, 16 Jan 2014 21:07:03 GMT
Author: desruisseaux
Date: Thu Jan 16 21:07:02 2014
New Revision: 1558919

URL: http://svn.apache.org/r1558919
Log:
Added tests.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -60,6 +60,9 @@ public final class CRS extends Static {
      *
      * <blockquote><table class="sis">
      *   <tr><th>Code</th>      <th>Enum</th>             
                    <th>CRS Type</th>   <th>Description</th></tr>
+     *   <tr><td>CRS:27</td>    <td>{@link GeodeticObjects#NAD27
 NAD27}</td>  <td>Geographic</td> <td>Like EPSG:4267 except for (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
+     *   <tr><td>CRS:83</td>    <td>{@link GeodeticObjects#NAD83
 NAD83}</td>  <td>Geographic</td> <td>Like EPSG:4269 except for (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
+     *   <tr><td>CRS:84</td>    <td>{@link GeodeticObjects#WGS84
 WGS84}</td>  <td>Geographic</td> <td>Like EPSG:4326 except for (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
      *   <tr><td>EPSG:4047</td> <td>{@link GeodeticObjects#SPHERE
SPHERE}</td> <td>Geographic</td> <td>GRS 1980 Authalic Sphere</td></tr>
      *   <tr><td>EPSG:4230</td> <td>{@link GeodeticObjects#ED50 
 ED50}</td>   <td>Geographic</td> <td>European Datum 1950</td></tr>
      *   <tr><td>EPSG:4258</td> <td>{@link GeodeticObjects#ETRS89
ETRS89}</td> <td>Geographic</td> <td>European Terrestrial Reference
Frame 1989</td></tr>
@@ -67,9 +70,8 @@ public final class CRS extends Static {
      *   <tr><td>EPSG:4269</td> <td>{@link GeodeticObjects#NAD83
 NAD83}</td>  <td>Geographic</td> <td>North American Datum 1983</td></tr>
      *   <tr><td>EPSG:4322</td> <td>{@link GeodeticObjects#WGS72
 WGS72}</td>  <td>Geographic</td> <td>World Geodetic System 1972</td></tr>
      *   <tr><td>EPSG:4326</td> <td>{@link GeodeticObjects#WGS84
 WGS84}</td>  <td>Geographic</td> <td>World Geodetic System 1984</td></tr>
-     *   <tr><td>CRS:27</td>    <td>{@link GeodeticObjects#NAD27
 NAD27}</td>  <td>Geographic</td> <td>NAD 27 with (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
-     *   <tr><td>CRS:83</td>    <td>{@link GeodeticObjects#NAD83
 NAD83}</td>  <td>Geographic</td> <td>NAD 83 with (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
-     *   <tr><td>CRS:84</td>    <td>{@link GeodeticObjects#WGS84
 WGS84}</td>  <td>Geographic</td> <td>WGS 84 with (<var>longitude</var>,
<var>latitude</var>) axis order</td></tr>
+     *   <tr><td>EPSG:5714</td> <td>{@link GeodeticObjects.Vertical#MSL_HEIGHT
MSL_HEIGHT}</td> <td>Vertical</td> <td>Mean Sea Level height</td></tr>
+     *   <tr><td>EPSG:5715</td> <td>{@link GeodeticObjects.Vertical#MSL_DEPTH
 MSL_DEPTH}</td>  <td>Vertical</td> <td>Mean Sea Level depth</td></tr>
      * </table></blockquote>
      *
      * This method accepts also the URN and URL syntax.
@@ -120,9 +122,16 @@ public final class CRS extends Static {
                 }
             } else if (authority.equalsIgnoreCase("EPSG")) {
                 final int n = Integer.parseInt(value);
-                for (final GeodeticObjects candidate : GeodeticObjects.values()) {
-                    if (candidate.geographic == n) {
-                        return candidate.geographic();
+                if (n != 0) { // 0 stands for "no EPSG code" in GeodeticObjects.Vertical
+                    for (final GeodeticObjects candidate : GeodeticObjects.values()) {
+                        if (candidate.geographic == n) {
+                            return candidate.geographic();
+                        }
+                    }
+                    for (final GeodeticObjects.Vertical candidate : GeodeticObjects.Vertical.values())
{
+                        if (candidate.crs == n) {
+                            return candidate.crs();
+                        }
                     }
                 }
             } else {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/StandardDefinitions.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -246,7 +246,7 @@ final class StandardDefinitions {
      * @param  code The EPSG code.
      * @return The coordinate system axis for the given code.
      */
-    private static CoordinateSystemAxis createAxis(final short code) {
+    static CoordinateSystemAxis createAxis(final short code) {
         final String name, abrv;
         final Unit<?> unit;
         double min = Double.NEGATIVE_INFINITY;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -47,7 +47,7 @@ import static java.lang.StrictMath.*;
  */
 public strictfp class Assert extends org.apache.sis.test.Assert {
     /**
-     * Tolerance threshold for strict floating point comparisons.
+     * The tolerance threshold for strict comparisons of floating point values.
      */
     private static final double STRICT = 0;
 

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -61,6 +61,8 @@ public final strictfp class CRSTest exte
         verifyForCode(GeodeticObjects.NAD27 .geographic(), "EPSG:4267");
         verifyForCode(GeodeticObjects.ETRS89.geographic(), "EPSG:4258");
         verifyForCode(GeodeticObjects.ED50  .geographic(), "EPSG:4230");
+        assertSame("EPSG:5714", GeodeticObjects.Vertical.MSL_HEIGHT.crs(), CRS.forCode("EPSG:5714"));
+        assertSame("EPSG:5715", GeodeticObjects.Vertical.MSL_DEPTH .crs(), CRS.forCode("EPSG:5715"));
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -50,9 +50,9 @@ import static org.apache.sis.test.Assert
  */
 public final strictfp class GeodeticObjectVerifier {
     /**
-     * The tolerance factor for strict comparisons of floating point values.
+     * The tolerance threshold for strict comparisons of floating point values.
      */
-    private static final double STRICT = 0.0;
+    private static final double STRICT = 0;
 
     /**
      * Creates a new test case.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -17,6 +17,8 @@
 package org.apache.sis.referencing;
 
 import java.util.Date;
+import org.opengis.referencing.crs.TemporalCRS;
+import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.datum.TemporalDatum;
@@ -78,20 +80,30 @@ public final strictfp class GeodeticObje
      */
     @Test
     public void testVertical() {
-        assertEquals(VerticalDatumType. BAROMETRIC,    type(GeodeticObjects.Vertical.BAROMETRIC));
-        assertEquals(VerticalDatumType. GEOIDAL,       type(GeodeticObjects.Vertical.MSL_HEIGHT));
-        assertEquals(VerticalDatumType. GEOIDAL,       type(GeodeticObjects.Vertical.MSL_DEPTH));
-        assertEquals(VerticalDatumTypes.ELLIPSOIDAL,   type(GeodeticObjects.Vertical.ELLIPSOIDAL));
-        assertEquals(VerticalDatumType. OTHER_SURFACE, type(GeodeticObjects.Vertical.OTHER_SURFACE));
-    }
-
-    /**
-     * Validates the datum of the given enumeration, then returns its datum type.
-     */
-    private static VerticalDatumType type(final GeodeticObjects.Vertical e) {
-        final VerticalDatum datum = e.datum();
-        Validators.validate(datum);
-        return datum.getVerticalDatumType();
+        for (final GeodeticObjects.Vertical e : GeodeticObjects.Vertical.values()) {
+            final VerticalDatumType expectedType;
+            switch (e) {
+                case MSL_DEPTH:     // Fall through
+                case MSL_HEIGHT:    expectedType = VerticalDatumType. GEOIDAL;       break;
+                case BAROMETRIC:    expectedType = VerticalDatumType. BAROMETRIC;    break;
+                case ELLIPSOIDAL:   expectedType = VerticalDatumTypes.ELLIPSOIDAL;   break;
+                case OTHER_SURFACE: expectedType = VerticalDatumType. OTHER_SURFACE; break;
+                default: throw new AssertionError(e);
+            }
+            final String        name  = e.name();
+            final VerticalDatum datum = e.datum();
+            final VerticalCRS   crs   = e.crs();
+            if (!crs.getCoordinateSystem().getAxis(0).getName().getCode().equals("Height"))
{
+                /*
+                 * BAROMETRIC, ELLIPSOIDAL and OTHER_SURFACE uses an axis named "Height",
which is not
+                 * a valid axis name according ISO 19111. We skip the validation test for
those enums.
+                 */
+                Validators.validate(crs);
+            }
+            assertSame  (name, datum,          e.datum()); // Datum before CRS creation.
+            assertSame  (name, crs.getDatum(), e.datum()); // Datum after CRS creation.
+            assertEquals(name, expectedType, datum.getVerticalDatumType());
+        }
     }
 
     /**
@@ -101,23 +113,29 @@ public final strictfp class GeodeticObje
      */
     @Test
     public void testTemporal() {
-        final double epoch = GeodeticObjects.Temporal.JULIAN.datum().getOrigin().getTime()
/ DAY_LENGTH;
-        assertTrue(epoch < 0);
-        assertEquals(2400000.5, julian("1858-11-17 00:00:00", GeodeticObjects.Temporal.MODIFIED_JULIAN)
 - epoch, 0);
-        assertEquals(2440000.5, julian("1968-05-24 00:00:00", GeodeticObjects.Temporal.TRUNCATED_JULIAN)
- epoch, 0);
-        assertEquals(2415020.0, julian("1899-12-31 12:00:00", GeodeticObjects.Temporal.DUBLIN_JULIAN)
   - epoch, 0);
-        assertEquals(2440587.5, julian("1970-01-01 00:00:00", GeodeticObjects.Temporal.UNIX)
            - epoch, 0);
-    }
-
-    /**
-     * Validates the datum of the given definition, compares its epoch with the given ISO
date
-     * and returns its Julian day.
-     */
-    private static double julian(final String epoch, final GeodeticObjects.Temporal def)
{
-        final TemporalDatum datum = def.datum();
-        Validators.validate(datum);
-        final Date origin = datum.getOrigin();
-        assertEquals(def.name(), epoch, format(origin));
-        return origin.getTime() / DAY_LENGTH;
+        final double julianEpoch = GeodeticObjects.Temporal.JULIAN.datum().getOrigin().getTime()
/ DAY_LENGTH;
+        assertTrue(julianEpoch < 0);
+        for (final GeodeticObjects.Temporal e : GeodeticObjects.Temporal.values()) {
+            final String epoch;
+            final double days;
+            switch (e) {
+                case JAVA:             // Fall through
+                case UNIX:             epoch = "1970-01-01 00:00:00"; days = 2440587.5; break;
+                case TRUNCATED_JULIAN: epoch = "1968-05-24 00:00:00"; days = 2440000.5; break;
+                case DUBLIN_JULIAN:    epoch = "1899-12-31 12:00:00"; days = 2415020.0; break;
+                case MODIFIED_JULIAN:  epoch = "1858-11-17 00:00:00"; days = 2400000.5; break;
+                case JULIAN:           epoch = "4713-01-01 12:00:00"; days = 0;         break;
+                default: throw new AssertionError(e);
+            }
+            final String        name   = e.name();
+            final TemporalDatum datum  = e.datum();
+            final TemporalCRS   crs    = e.crs();
+            final Date          origin = datum.getOrigin();
+            Validators.validate(crs);
+            assertSame  (name, datum,          e.datum()); // Datum before CRS creation.
+            assertSame  (name, crs.getDatum(), e.datum()); // Datum after CRS creation.
+            assertEquals(name, epoch, format(origin));
+            assertEquals(name, days, origin.getTime() / DAY_LENGTH - julianEpoch, 0);
+        }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -16,12 +16,14 @@
  */
 package org.apache.sis.referencing;
 
+import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.apache.sis.test.mock.GeodeticDatumMock;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.opengis.test.Validators;
+import org.apache.sis.referencing.cs.CommonAxes;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -36,10 +38,16 @@ import static org.junit.Assert.*;
  * @module
  */
 @DependsOn({
-  org.apache.sis.referencing.datum.DefaultEllipsoidTest.class
+  org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+  org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class
 })
 public final strictfp class StandardDefinitionsTest extends TestCase {
     /**
+     * The tolerance threshold for strict comparisons of floating point values.
+     */
+    private static final double STRICT = 0;
+
+    /**
      * Compares the values created by {@link StandardDefinitions#createEllipsoid(short)}
against
      * the {@link GeodeticObjects} constants. Actually this is more a {@code GeodeticDatumMock}
      * test than a {@code StandardDefinitions} one - in case of test failure, both classes
could
@@ -66,11 +74,41 @@ public final strictfp class StandardDefi
             final Ellipsoid mock = mocks[i].getEllipsoid();
             final Ellipsoid def  = StandardDefinitions.createEllipsoid(enums[i].ellipsoid);
             Validators.validate(def);
-            assertEquals("semiMajorAxis",     mock.getSemiMajorAxis(),     def.getSemiMajorAxis(),
0);
-            assertEquals("semiMinorAxis",     mock.getSemiMinorAxis(),     def.getSemiMinorAxis(),
0);
-            assertEquals("inverseFlattening", mock.getInverseFlattening(), def.getInverseFlattening(),
mock.isIvfDefinitive() ? 0 : 1E-11);
+            assertEquals("semiMajorAxis",     mock.getSemiMajorAxis(),     def.getSemiMajorAxis(),
STRICT);
+            assertEquals("semiMinorAxis",     mock.getSemiMinorAxis(),     def.getSemiMinorAxis(),
STRICT);
+            assertEquals("inverseFlattening", mock.getInverseFlattening(), def.getInverseFlattening(),
mock.isIvfDefinitive() ? STRICT : 1E-11);
             assertEquals("isIvfDefinitive",   mock.isIvfDefinitive(),      def.isIvfDefinitive());
             assertEquals("isSphere",          mock.isSphere(),             def.isSphere());
         }
     }
+
+    /**
+     * Compares the values created by {@link StandardDefinitions#createAxis(short)} against
the {@link CommonAxes}
+     * constants. Actually this is more a {@code CommonAxes} test than a {@code StandardDefinitions}
one - in case
+     * of test failure, both classes could be at fault.
+     */
+    @Test
+    public void testCreateAxis() {
+        final short[] codes = {
+            106, 107, 110, 114, 113
+        };
+        final CoordinateSystemAxis[] axes = {
+            CommonAxes.GEODETIC_LATITUDE,
+            CommonAxes.GEODETIC_LONGITUDE,
+            CommonAxes.ELLIPSOIDAL_HEIGHT,
+            CommonAxes.GRAVITY_RELATED_HEIGHT,
+            CommonAxes.DEPTH
+        };
+        for (int i=0; i<codes.length; i++) {
+            final CoordinateSystemAxis axis = StandardDefinitions.createAxis(codes[i]);
+            final CoordinateSystemAxis expected = axes[i];
+            assertEquals("name",         expected.getName().getCode(), axis.getName().getCode());
+            assertEquals("abbreviation", expected.getAbbreviation(),   axis.getAbbreviation());
+            assertEquals("unit",         expected.getUnit(),           axis.getUnit());
+            assertEquals("direction",    expected.getDirection(),      axis.getDirection());
+            assertEquals("minimumValue", expected.getMinimumValue(),   axis.getMinimumValue(),
STRICT);
+            assertEquals("maximumValue", expected.getMaximumValue(),   axis.getMaximumValue(),
STRICT);
+            assertEquals("rangeMeaning", expected.getRangeMeaning(),   axis.getRangeMeaning());
+        }
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java?rev=1558919&r1=1558918&r2=1558919&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
[UTF-8] Thu Jan 16 21:07:02 2014
@@ -166,7 +166,7 @@ public final strictfp class CommonAxes {
      * @see #GEOCENTRIC_RADIUS
      * @see #GRAVITY_RELATED_HEIGHT
      */
-    public static final DefaultCoordinateSystemAxis DEPTH = create("Depth", "d",
+    public static final DefaultCoordinateSystemAxis DEPTH = create("Depth", "D",
             AxisDirection.DOWN, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
null);
 
     /**



Mime
View raw message