sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1541888 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/test/java/org/apache/sis/referencing/ sis-referencing/src/test/java/org/apache/sis/referencing/datum/ sis-utility/...
Date Thu, 14 Nov 2013 12:27:31 GMT
Author: desruisseaux
Date: Thu Nov 14 12:27:30 2013
New Revision: 1541888

URL: http://svn.apache.org/r1541888
Log:
Complete DefaultGeodeticDatumTest.testGetPositionVectorTransformation()

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.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/datum/BursaWolfParametersTest.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
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/PrimeMeridianMock.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java?rev=1541888&r1=1541887&r2=1541888&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
[UTF-8] Thu Nov 14 12:27:30 2013
@@ -96,14 +96,4 @@ public final class ExtentSelector<T> {
     public T best() {
         return best;
     }
-
-    /**
-     * Returns the area of the largest intersection between the extents given to {@link #evaluate(Extent,
Object)}
-     * and the area of interest.
-     *
-     * @return Area of the largest intersection (m²), or 0.
-     */
-    public double largestArea() {
-        return largestArea;
-    }
 }

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=1541888&r1=1541887&r2=1541888&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 Nov 14 12:27:30 2013
@@ -17,8 +17,12 @@
 package org.apache.sis.referencing;
 
 import java.util.Date;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.datum.TemporalDatum;
 import org.opengis.test.Validators;
+import org.apache.sis.test.mock.GeodeticDatumMock;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -34,6 +38,10 @@ import static org.apache.sis.test.TestUt
  * @version 0.4
  * @module
  */
+@DependsOn({
+  org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
+  org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class
+})
 public final strictfp class GeodeticObjectsTest extends TestCase {
     /**
      * Length of a day in milliseconds.
@@ -41,6 +49,39 @@ public final strictfp class GeodeticObje
     private static final double DAY_LENGTH = 24 * 60 * 60 * 1000;
 
     /**
+     * Compares the {@link GeodeticDatumMock} constants with the {@link GeodeticObjects}
ones.
+     * This is more a {@code GeodeticDatumMock} test than a {@code GeodeticObjects} one,
but can
+     * hardly be defined elsewhere since we need some reference objects for comparing the
values.
+     */
+    @Test
+    public void testGeodeticDatumMocks() {
+        final GeodeticDatum[] mocks = new GeodeticDatum[] {
+            GeodeticDatumMock.WGS84,
+            GeodeticDatumMock.WGS72,
+            GeodeticDatumMock.NAD83,
+            GeodeticDatumMock.NAD27,
+            GeodeticDatumMock.SPHERE
+        };
+        final GeodeticObjects[] enums = new GeodeticObjects[] {
+            GeodeticObjects.WGS84,
+            GeodeticObjects.WGS72,
+            GeodeticObjects.NAD83,
+            GeodeticObjects.NAD27,
+            GeodeticObjects.SPHERE
+        };
+        assertEquals(mocks.length, enums.length);
+        for (int i=0; i<mocks.length; i++) {
+            final Ellipsoid mock = mocks[i].getEllipsoid();
+            final Ellipsoid ref  = enums[i].ellipsoid();
+            assertEquals("semiMajorAxis",     ref.getSemiMajorAxis(),     mock.getSemiMajorAxis(),
0);
+            assertEquals("semiMinorAxis",     ref.getSemiMinorAxis(),     mock.getSemiMinorAxis(),
0);
+            assertEquals("inverseFlattening", ref.getInverseFlattening(), mock.getInverseFlattening(),
1E-11);
+            assertEquals("isIvfDefinitive",   ref.isIvfDefinitive(),      mock.isIvfDefinitive());
+            assertEquals("isSphere",          ref.isSphere(),             mock.isSphere());
+        }
+    }
+
+    /**
      * Verifies the epoch values of temporal enumeration compared to the Julian epoch.
      *
      * @see <a href="http://en.wikipedia.org/wiki/Julian_day">Wikipedia: Julian day</a>

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1541888&r1=1541887&r2=1541888&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
[UTF-8] Thu Nov 14 12:27:30 2013
@@ -30,6 +30,7 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.mock.GeodeticDatumMock.WGS84;
 
 
 /**
@@ -51,7 +52,7 @@ public final strictfp class BursaWolfPar
      * Area of validity is the World.
      */
     static BursaWolfParameters createWGS72_to_WGS84() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(null, Extents.WORLD);
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, Extents.WORLD);
         bursaWolf.tZ = 4.5;
         bursaWolf.rZ = 0.554;
         bursaWolf.dS = 0.219;
@@ -64,7 +65,7 @@ public final strictfp class BursaWolfPar
      * Area of validity is the North Sea: 5.05°W to 11.13°E in longitude and 51.04°N to
62.0°N in latitude.
      */
     static BursaWolfParameters createED87_to_WGS84() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(null, new DefaultExtent("Europe
- North Sea",
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, new DefaultExtent("Europe
- North Sea",
                 new DefaultGeographicBoundingBox(-5.05, 11.13, 51.04, 62.0), null, null));
         bursaWolf.tX =  -82.981;
         bursaWolf.tY =  -99.719;

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=1541888&r1=1541887&r2=1541888&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] Thu Nov 14 12:27:30 2013
@@ -19,8 +19,8 @@ package org.apache.sis.referencing.datum
 import java.util.Random;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
-import org.apache.sis.referencing.GeodeticObjects;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.test.mock.GeodeticDatumMock;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.DependsOn;
@@ -69,7 +69,7 @@ public final strictfp class DefaultEllip
      */
     @Test
     public void testOrthodromicDistance() {
-        final DefaultEllipsoid e = (DefaultEllipsoid) GeodeticObjects.NAD27.ellipsoid();
// Clark 1866
+        final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.NAD27.getEllipsoid());
// Clark 1866
         assertEquals("Nautical mile at equator",    1842.78, e.orthodromicDistance(0,   
-HM,   0,    +HM), 0.01);
         assertEquals("Nautical mile at North pole", 1861.67, e.orthodromicDistance(0,  90-HM*2,
0,  90   ), 0.02);
         assertEquals("Nautical mile at South pole", 1861.67, e.orthodromicDistance(0, -90+HM*2,
0, -90   ), 0.02);
@@ -92,15 +92,15 @@ public final strictfp class DefaultEllip
     @Test
     @DependsOnMethod("testOrthodromicDistance")
     public void testOrthodromicDistanceOnSphere() {
-        final DefaultEllipsoid s = (DefaultEllipsoid) GeodeticObjects.SPHERE.ellipsoid();
-        assertInstanceOf("SPHERE", Sphere.class, s);
         /*
-         * Creates an instance of DefaultEllipsoid with the same properties than s.
-         * The 's' and 'e' instances will use different formulas for orthodromic distances,
which we will compare.
+         * Creates instance of DefaultEllipsoid and Sphere with the same properties.
+         * Those instances will use different formulas for orthodromic distances, which we
will compare.
          */
-        final double radius = s.getSemiMajorAxis();
-        final DefaultEllipsoid e = new DefaultEllipsoid(IdentifiedObjects.getProperties(s),
-                radius, radius, Double.POSITIVE_INFINITY, false, s.getAxisUnit());
+        final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.SPHERE.getEllipsoid());
+        final double radius = e.getSemiMajorAxis();
+        final Sphere s = new Sphere(IdentifiedObjects.getProperties(e), radius, false, e.getAxisUnit());
+        assertTrue(e.isSphere());
+        assertTrue(s.isSphere());
         /*
          * Test parallel segments of increasing length at random positions on the equator.
          */
@@ -141,7 +141,12 @@ public final strictfp class DefaultEllip
      */
     @Test
     public void testAuthalicRadius() {
-        assertEquals("SPHERE", 6371007, ((DefaultEllipsoid) GeodeticObjects.SPHERE.ellipsoid()).getAuthalicRadius(),
0.0);
-        assertEquals("NAD83",  6371007, ((DefaultEllipsoid) GeodeticObjects.NAD83 .ellipsoid()).getAuthalicRadius(),
0.2);
+        final DefaultEllipsoid sphere = DefaultEllipsoid.castOrCopy(GeodeticDatumMock.SPHERE.getEllipsoid());
+        final DefaultEllipsoid GRS80  = DefaultEllipsoid.castOrCopy(GeodeticDatumMock.NAD83
.getEllipsoid());
+        assertInstanceOf("SPHERE", Sphere.class, sphere);
+        assertTrue  ("SPHERE", sphere.isSphere());
+        assertFalse ("GRS80",  GRS80 .isSphere());
+        assertEquals("SPHERE", 6371007, sphere.getAuthalicRadius(), 0.0);
+        assertEquals("GRS80",  6371007, GRS80 .getAuthalicRadius(), 0.2);
     }
 }

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=1541888&r1=1541887&r2=1541888&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] Thu Nov 14 12:27:30 2013
@@ -19,13 +19,16 @@ package org.apache.sis.referencing.datum
 import java.util.Map;
 import java.util.HashMap;
 import org.opengis.metadata.extent.Extent;
+import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.datum.GeodeticDatum;
-import org.apache.sis.referencing.GeodeticObjects;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
 import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.mock.GeodeticDatumMock.*;
 
 
 /**
@@ -52,18 +55,42 @@ public final strictfp class DefaultGeode
          * in datum consistency - we only want any Bursa-Wolf parameters having different
area
          * of validity.
          */
-        assertNull(properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, new BursaWolfParameters[]
{
-            BursaWolfParametersTest.createED87_to_WGS84(),  // Local area (North Sea)
-            BursaWolfParametersTest.createWGS72_to_WGS84()  // Global area (World)
-        }));
+        final BursaWolfParameters local  = BursaWolfParametersTest.createED87_to_WGS84();
  // Local area (North Sea)
+        final BursaWolfParameters global = BursaWolfParametersTest.createWGS72_to_WGS84();
 // Global area (World)
+        assertNull(properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, new BursaWolfParameters[]
{local, global}));
         /*
-         * Build the datum.
+         * Build the datum using WGS 72 ellipsoid (so at least one of the BursaWolfParameters
is real).
          */
-        final GeodeticDatum targetDatum = null; // TODO: need a WGS84 mock.
         final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(properties,
-                GeodeticObjects.WGS84.ellipsoid(),
-                GeodeticObjects.WGS84.primeMeridian()
-        );
-        // TODO: test getPositionVectorTransformation
+                WGS72.getEllipsoid(), WGS72.getPrimeMeridian());
+        /*
+         * Search for BursaWolfParameters around the North Sea area.
+         */
+        final DefaultGeographicBoundingBox areaOfInterest = new DefaultGeographicBoundingBox(-2,
8, 55, 60);
+        final DefaultExtent extent = new DefaultExtent("Around the North Sea", areaOfInterest,
null, null);
+        Matrix matrix = datum.getPositionVectorTransformation(NAD83, extent);
+        assertNull("No BursaWolfParameters for NAD83", matrix);
+        matrix = datum.getPositionVectorTransformation(WGS84, extent);
+        assertNotNull("BursaWolfParameters for WGS84", matrix);
+        checkTransformationSignature(local, matrix);
+        /*
+         * Expand the area of interest to something greater than North Sea, and test again.
+         */
+        areaOfInterest.setWestBoundLongitude(-8);
+        matrix = datum.getPositionVectorTransformation(WGS84, extent);
+        assertNotNull("BursaWolfParameters for WGS84", matrix);
+        checkTransformationSignature(global, matrix);
+    }
+
+    /**
+     * Verifies if the given matrix is for the expected Position Vector transformation.
+     * The easiest way to verify that is to check the translation terms (last matrix column),
+     * which should have been copied verbatim from the {@code BursaWolfParameters} to the
matrix.
+     * Other terms in the matrix are modified compared to the {@code BursaWolfParameters}
ones.
+     */
+    private static void checkTransformationSignature(final BursaWolfParameters expected,
final Matrix actual) {
+        assertEquals("tX", expected.tX, actual.getElement(0, 3), 0);
+        assertEquals("tY", expected.tY, actual.getElement(1, 3), 0);
+        assertEquals("tZ", expected.tZ, actual.getElement(2, 3), 0);
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java?rev=1541888&r1=1541887&r2=1541888&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/GeodeticDatumMock.java
[UTF-8] Thu Nov 14 12:27:30 2013
@@ -35,6 +35,7 @@ import org.opengis.referencing.datum.Pri
  * @version 0.4
  * @module
  */
+@SuppressWarnings("serial")
 public final strictfp class GeodeticDatumMock extends IdentifiedObjectMock implements GeodeticDatum,
Ellipsoid {
     /**
      * The "World Geodetic System 1984" datum.
@@ -94,6 +95,14 @@ public final strictfp class GeodeticDatu
         this.isIvfDefinitive   = isIvfDefinitive;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    Object[] properties() {
+        return new Object[] {getCode(), alias, semiMajorAxis, semiMinorAxis, inverseFlattening,
isIvfDefinitive};
+    }
+
     @Override public PrimeMeridian        getPrimeMeridian()      {return PrimeMeridianMock.GREENWICH;}
     @Override public Ellipsoid            getEllipsoid()          {return this;}
     @Override public Unit<Length>         getAxisUnit()           {return SI.METRE;}

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java?rev=1541888&r1=1541887&r2=1541888&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] Thu Nov 14 12:27:30 2013
@@ -16,9 +16,11 @@
  */
 package org.apache.sis.test.mock;
 
+import java.util.Arrays;
 import java.util.Set;
 import java.util.Collection;
 import java.util.Collections;
+import java.io.Serializable;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -40,8 +42,9 @@ import org.apache.sis.internal.jaxb.gco.
  * @version 0.4
  * @module
  */
+@SuppressWarnings("serial")
 @XmlRootElement(name = "IO_IdentifiedObject")
-public strictfp class IdentifiedObjectMock implements IdentifiedObject, ReferenceIdentifier
{
+public strictfp class IdentifiedObjectMock implements IdentifiedObject, ReferenceIdentifier,
Serializable {
     /**
      * The object name to be returned by {@link #getCode()}.
      */
@@ -55,6 +58,14 @@ public strictfp class IdentifiedObjectMo
     public GenericName alias;
 
     /**
+     * Returns all properties defined in this object,
+     * for the convenience of {@link #equals(Object)} and {@link #hashCode()}.
+     */
+    Object[] properties() {
+        return new Object[] {code, alias};
+    }
+
+    /**
      * Creates an initially empty identified object.
      * This constructor is required by JAXB.
      */
@@ -171,4 +182,36 @@ public strictfp class IdentifiedObjectMo
     public final String toWKT() throws UnsupportedOperationException {
         throw new UnsupportedOperationException();
     }
+
+    /**
+     * Returns a string representation for debugging purpose.
+     */
+    @Override
+    public final String toString() {
+        return getClass().getSimpleName() + '[' + code + ']';
+    }
+
+    /**
+     * Returns a hash code value for this object.
+     *
+     * @return A hash code value.
+     */
+    @Override
+    public final int hashCode() {
+        return Arrays.hashCode(properties());
+    }
+
+    /**
+     * Compares this object with the given object for equality.
+     *
+     * @param  object The other object, or {@code null}.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public final boolean equals(final Object object) {
+        if (object != null && object.getClass() == getClass()) {
+            return Arrays.equals(properties(), ((IdentifiedObjectMock) object).properties());
+        }
+        return false;
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/PrimeMeridianMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/PrimeMeridianMock.java?rev=1541888&r1=1541887&r2=1541888&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/PrimeMeridianMock.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/PrimeMeridianMock.java
[UTF-8] Thu Nov 14 12:27:30 2013
@@ -30,6 +30,7 @@ import org.opengis.referencing.datum.Pri
  * @version 0.4
  * @module
  */
+@SuppressWarnings("serial")
 public final strictfp class PrimeMeridianMock extends IdentifiedObjectMock implements PrimeMeridian
{
     /**
      * A mock for the Greenwich prime meridian.



Mime
View raw message