sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1541767 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ sis-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-ref...
Date Thu, 14 Nov 2013 00:08:38 GMT
Author: desruisseaux
Date: Thu Nov 14 00:08:38 2013
New Revision: 1541767

URL: http://svn.apache.org/r1541767
Log:
First draft of DefaultGeodeticDatumTest (not yet completed).

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.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/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/DoubleConsumer.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java?rev=1541767&r1=1541766&r2=1541767&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
[UTF-8] Thu Nov 14 00:08:38 2013
@@ -149,7 +149,7 @@ public final class Extents extends Stati
      * However this may change in any future SIS version.</p>
      *
      * @param  box The geographic bounding box for which to compute the area, or {@code null}.
-     * @return An estimation of the geographic area in the given bounding box,
+     * @return An estimation of the area in the given bounding box (m²),
      *         or {@linkplain Double#NaN NaN} if the given box was null.
      *
      * @since 0.4

Added: 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=1541767&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
[UTF-8] Thu Nov 14 00:08:38 2013
@@ -0,0 +1,109 @@
+/*
+ * 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.internal.referencing;
+
+import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.Extents;
+
+
+/**
+ * Selects an object in a sequence of objects using their extent as a criterion.
+ * Current implementation uses only the geographic extent.
+ * This may be extended to other kind of extent in any future SIS version.
+ *
+ * @param <T> The type of object to be selected.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class ExtentSelector<T> {
+    /**
+     * The area of interest, or {@code null} if none.
+     */
+    private final GeographicBoundingBox areaOfInterest;
+
+    /**
+     * The best object found so far.
+     */
+    private T best;
+
+    /**
+     * The area covered by the {@linkplain #best} object (m²). The initial value is zero,
+     * which imply that only intersection areas greater than zero will be accepted.
+     * This is the desired behavior in order to filter out empty intersections.
+     */
+    private double largestArea;
+
+    /**
+     * Creates a selector for the given area of interest.
+     *
+     * @param areaOfInterest The area of interest, or {@code null} if none.
+     */
+    public ExtentSelector(final Extent areaOfInterest) {
+        this.areaOfInterest = Extents.getGeographicBoundingBox(areaOfInterest);
+    }
+
+    /**
+     * Evaluates the given extent against the criteria represented by the {@code ExtentSelector}.
+     * If the intersection between the given extent and the area of interest is greater than
any
+     * previous intersection, then the given extent and object are remembered as the best
match
+     * found so far.
+     *
+     * @param  extent The extent to evaluate, or {@code null} if none.
+     * @param  object An optional user object associated to the given extent.
+     * @return {@code true} if the given extent is a better match than any previous extents
given to this method.
+     */
+    public boolean evaluate(final Extent extent, final T object) {
+        final double area = Extents.area(Extents.intersection(Extents.getGeographicBoundingBox(extent),
areaOfInterest));
+        if (best != null && !(area > largestArea)) { // Use '!' for catching NaN.
+            /*
+             * At this point, the given extent is not greater than the previous one.
+             * However if the previous object had no extent information at all (i.e.
+             * 'largestArea' is NaN) while the new object has a valid extent, then
+             * the new object will have precedence.
+             */
+            if (Double.isNaN(area) || !Double.isNaN(largestArea)) {
+                return false;
+            }
+        }
+        largestArea = area;
+        best = object;
+        return true;
+    }
+
+    /**
+     * Returns the object associated to the largest area found so far.
+     *
+     * @return The object associated to the largest area found so far, or {@code null}.
+     */
+    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;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtentSelector.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1541767&r1=1541766&r2=1541767&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] Thu Nov 14 00:08:38 2013
@@ -17,9 +17,7 @@
 package org.apache.sis.referencing.datum;
 
 import java.util.Map;
-import java.util.Set;
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Date;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
@@ -27,15 +25,14 @@ import javax.xml.bind.annotation.XmlRoot
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.extent.Extent;
-import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.PrimeMeridian;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
+import org.apache.sis.internal.referencing.ExtentSelector;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ComparisonMode;
@@ -304,7 +301,7 @@ public class DefaultGeodeticDatum extend
      */
     public BursaWolfParameters[] getBursaWolfParameters() {
         if (bursaWolf == null) {
-            return null;
+            return EMPTY_ARRAY;
         }
         final BursaWolfParameters[] copy = bursaWolf.clone();
         for (int i=0; i<copy.length; i++) {
@@ -314,22 +311,28 @@ public class DefaultGeodeticDatum extend
     }
 
     /**
-     * Returns a direct reference to the {@link #bursaWolf} of the given datum if it exists,
-     * or {@code null} otherwise. This method does not clone the array - do not modify!
-     */
-    private static BursaWolfParameters[] bursaWolf(final GeodeticDatum datum) {
-        return (datum instanceof DefaultGeodeticDatum) ? ((DefaultGeodeticDatum) datum).bursaWolf
: null;
-    }
-
-    /**
      * Returns the position vector transformation (geocentric domain) to the specified datum.
-     * If no transformation path is found, then this method returns {@code null}.
-     * If non-null, then the transformation is represented by an affine transform
-     * which can be applied on <strong>geocentric</strong> coordinates.
-     *
-     * {@note This is identified in the EPSG database as operation method 1033 -
-     *        <cite>Position Vector transformation (geocentric domain)</cite>,
or 1053 -
-     *        <cite>Time-dependent Position Vector transformation</cite>.}
+     * This method performs the search in the following order:
+     *
+     * <ul>
+     *   <li>If this {@code GeodeticDatum} contains {@code BursaWolfParameters} having
the given
+     *       {@linkplain BursaWolfParameters#getTargetDatum() target datum} (ignoring metadata),
+     *       then the matrix will be built from those parameters.</li>
+     *   <li>Otherwise if the other datum contains {@code BursaWolfParameters} having
this datum
+     *       as their target (ignoring metadata), then the matrix will be built from those
parameters
+     *       and {@linkplain MatrixSIS#inverse() inverted}.</li>
+     *   <li>Otherwise this method returns {@code null}.</li>
+     * </ul>
+     *
+     * If more than one {@code BursaWolfParameters} instance is found in any of the above
steps, then the one having
+     * the largest intersection between their {@linkplain BursaWolfParameters#getDomainOfValidity()
domain of validity}
+     * and the given extent will be selected. If more than one instance have the same intersection,
then the first
+     * occurrence is selected.
+     *
+     * <p>If non-null, then the transformation is represented by an affine transform
which can be applied on
+     * <strong>geocentric</strong> coordinates. This is identified in the EPSG
database as operation method
+     * 1033 - <cite>Position Vector transformation (geocentric domain)</cite>,
or
+     * 1053 - <cite>Time-dependent Position Vector transformation</cite>.</p>
      *
      * @param  targetDatum The target datum.
      * @param  extent The geographic and temporal extent where the transformation is valid,
or {@code null}.
@@ -339,94 +342,50 @@ public class DefaultGeodeticDatum extend
      */
     public Matrix getPositionVectorTransformation(final GeodeticDatum targetDatum, final
Extent extent) {
         ensureNonNull("targetDatum", targetDatum);
-        return getPositionVectorTransformation(this, targetDatum, Extents.getGeographicBoundingBox(extent),
null, null);
-    }
-
-    /**
-     * Returns a matrix that can be used to define a transformation to the specified datum.
-     * If no transformation path is found, then this method returns {@code null}.
-     *
-     * @param  source The source datum, or {@code null}.
-     * @param  target The target datum, or {@code null}.
-     * @param  extent The geographic extent where the transformation is desired, or {@code
null} if unspecified.
-     * @param  time   Date for which the transformation is desired, or {@code null} is unspecified.
-     * @param  exclusion The set of datum to exclude from the search, or {@code null}.
-     *         This is used in order to avoid never-ending recursivity.
-     * @return An affine transform from {@code source} to {@code target}, or {@code null}
if none.
-     */
-    private static Matrix getPositionVectorTransformation(final GeodeticDatum source, final
GeodeticDatum target,
-            final GeographicBoundingBox extent, final Date time, Set<GeodeticDatum>
exclusion)
-    {
-        final BursaWolfParameters[] sourceParam = bursaWolf(source);
-        if (sourceParam != null) {
-            for (final BursaWolfParameters candidate : sourceParam) {
-                if (deepEquals(target, candidate.getTargetDatum(), ComparisonMode.IGNORE_METADATA))
{
-                    return candidate.getPositionVectorTransformation(time);
-                }
-            }
-        }
+        final ExtentSelector<BursaWolfParameters> selector = new ExtentSelector<>(extent);
+        Date time = null; // TODO
         /*
-         * No transformation found to the specified target datum.
-         * Search if a transform exists in the opposite direction.
+         * Search in the BursaWolfParameters associated to this instance.
          */
-        final BursaWolfParameters[] targetParam = bursaWolf(target);
-        if (targetParam != null) {
-            for (final BursaWolfParameters candidate : targetParam) {
-                if (deepEquals(source, candidate.getTargetDatum(), ComparisonMode.IGNORE_METADATA))
try {
-                    return MatrixSIS.castOrCopy(candidate.getPositionVectorTransformation(time)).inverse();
-                } catch (NoninvertibleMatrixException e) {
-                    /*
-                     * Should never happen because BursaWolfParameters.getPositionVectorTransformation(Date)
-                     * is defined in such a way that matrix should always be invertible.
If it happen anyway,
-                     * search for an other BursaWolfParameters instance. If none are found,
returning 'null'
-                     * is allowed by this method's contract.
-                     */
-                    Logging.unexpectedException(DefaultGeodeticDatum.class, "getPositionVectorTransformation",
e);
-                }
-            }
+        BursaWolfParameters candidate = select(targetDatum, selector);
+        if (candidate != null) {
+            return candidate.getPositionVectorTransformation(time);
         }
         /*
-         * No direct tranformation found. Search for a path through some intermediate datum.
-         * First, search if there is some BursaWolfParameters for the same target in both
-         * 'source' and 'target' datum. If such an intermediate is found, ask for a path
as below:
-         *
-         *    source   →   [common datum]   →   target
+         * Search in the BursaWolfParameters associated to the other instance, if any.
          */
-        if (sourceParam != null && targetParam != null) {
-            for (int i=0; i<sourceParam.length; i++) {
-                final GeodeticDatum sourceStep = sourceParam[i].getTargetDatum();
-                for (int j=0; j<targetParam.length; j++) {
-                    final GeodeticDatum targetStep = targetParam[j].getTargetDatum();
-                    if (deepEquals(sourceStep, targetStep, ComparisonMode.IGNORE_METADATA))
{
-                        if (exclusion == null) {
-                            exclusion = new HashSet<>();
-                        }
-                        if (exclusion.add(source)) {
-                            if (exclusion.add(target)) {
-                                final Matrix step1 = getPositionVectorTransformation(source,
sourceStep, extent, time, exclusion);
-                                if (step1 != null) {
-                                    final Matrix step2 = getPositionVectorTransformation(targetStep,
target, extent, time, exclusion);
-                                    if (step2 != null) {
-                                        /*
-                                         * MatrixSIS.multiply(Matrix) is equivalent to AffineTransform.concatenate(…):
-                                         * First transform by the supplied transform and
then transform the result
-                                         * by the original transform.
-                                         */
-                                        return MatrixSIS.castOrCopy(step2).multiply(step1);
-                                    }
-                                }
-                                exclusion.remove(target);
-                            }
-                            exclusion.remove(source);
-                        }
-                    }
-                }
+        if (targetDatum instanceof DefaultGeodeticDatum) {
+            candidate = ((DefaultGeodeticDatum) targetDatum).select(this, selector);
+            if (candidate != null) try {
+                return MatrixSIS.castOrCopy(candidate.getPositionVectorTransformation(time)).inverse();
+            } catch (NoninvertibleMatrixException e) {
+                /*
+                 * Should never happen because BursaWolfParameters.getPositionVectorTransformation(Date)
+                 * is defined in such a way that matrix should always be invertible. If it
happen anyway,
+                 * returning 'null' is allowed by this method's contract.
+                 */
+                Logging.unexpectedException(DefaultGeodeticDatum.class, "getPositionVectorTransformation",
e);
             }
         }
         return null;
     }
 
     /**
+     * Returns the best parameters matching the given criteria, or {@code null} if none.
+     */
+    private BursaWolfParameters select(final GeodeticDatum targetDatum, final ExtentSelector<BursaWolfParameters>
selector) {
+        if (bursaWolf == null) {
+            return null;
+        }
+        for (final BursaWolfParameters candidate : bursaWolf) {
+            if (deepEquals(targetDatum, candidate.getTargetDatum(), ComparisonMode.IGNORE_METADATA))
{
+                selector.evaluate(candidate.getDomainOfValidity(), candidate);
+            }
+        }
+        return selector.best();
+    }
+
+    /**
      * Compare this datum with the specified object for equality.
      *
      * @param  object The object to compare to {@code this}.

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=1541767&r1=1541766&r2=1541767&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 00:08:38 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.referencing;
 
+import java.util.Date;
+import org.opengis.referencing.datum.TemporalDatum;
+import org.opengis.test.Validators;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -33,36 +36,34 @@ import static org.apache.sis.test.TestUt
  */
 public final strictfp class GeodeticObjectsTest extends TestCase {
     /**
+     * Length of a day in milliseconds.
+     */
+    private static final double DAY_LENGTH = 24 * 60 * 60 * 1000;
+
+    /**
      * 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>
      */
     @Test
     public void testTemporal() {
-        final double epoch = epoch(GeodeticObjects.Temporal.JULIAN);
+        final double epoch = GeodeticObjects.Temporal.JULIAN.datum().getOrigin().getTime()
/ DAY_LENGTH;
         assertTrue(epoch < 0);
-
-        assertEquals(2400000.5, epoch(GeodeticObjects.Temporal.MODIFIED_JULIAN) - epoch,
0);
-        assertEquals("1858-11-17 00:00:00", epochString(GeodeticObjects.Temporal.MODIFIED_JULIAN));
-
-        assertEquals(2440000.5, epoch(GeodeticObjects.Temporal.TRUNCATED_JULIAN) - epoch,
0);
-        assertEquals("1968-05-24 00:00:00", epochString(GeodeticObjects.Temporal.TRUNCATED_JULIAN));
-
-        assertEquals(2415020.0, epoch(GeodeticObjects.Temporal.DUBLIN_JULIAN) - epoch, 0);
-        assertEquals("1899-12-31 12:00:00", epochString(GeodeticObjects.Temporal.DUBLIN_JULIAN));
-    }
-
-    /**
-     * Returns the epoch of the given datum, in day units relative to Java epoch.
-     */
-    private static double epoch(final GeodeticObjects.Temporal def) {
-        return def.datum().getOrigin().getTime() / (24*60*60*1000.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);
     }
 
     /**
-     * Returns the epoch of the given datum formatted as a string.
+     * Validates the datum of the given definition, compares its epoch with the given ISO
date
+     * and returns its Julian day.
      */
-    private static String epochString(final GeodeticObjects.Temporal def) {
-        return format(def.datum().getOrigin());
+    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;
     }
 }

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=1541767&r1=1541766&r2=1541767&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 00:08:38 2013
@@ -18,6 +18,9 @@ package org.apache.sis.referencing.datum
 
 import java.util.Date;
 import org.opengis.referencing.operation.Matrix;
+import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.Matrix4;
@@ -44,10 +47,25 @@ public final strictfp class BursaWolfPar
     private static final double TO_RADIANS = Math.PI / (180 * 60 * 60);
 
     /**
-     * Returns the parameters for the <cite>ED87 to WGS 84</cite> transformation
(EPSG:1146).
+     * Returns the parameters for the <cite>WGS 72 to WGS 84 (2)</cite> transformation
(EPSG:1238).
+     * Area of validity is the World.
      */
-    private static BursaWolfParameters createForNorthSea() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(null, null);
+    static BursaWolfParameters createWGS72_to_WGS84() {
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(null, Extents.WORLD);
+        bursaWolf.tZ = 4.5;
+        bursaWolf.rZ = 0.554;
+        bursaWolf.dS = 0.219;
+        bursaWolf.verify();
+        return bursaWolf;
+    }
+
+    /**
+     * Returns the parameters for the <cite>ED87 to WGS 84 (1)</cite> transformation
(EPSG:1146).
+     * 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",
+                new DefaultGeographicBoundingBox(-5.05, 11.13, 51.04, 62.0), null, null));
         bursaWolf.tX =  -82.981;
         bursaWolf.tY =  -99.719;
         bursaWolf.tZ = -110.709;
@@ -86,10 +104,7 @@ public final strictfp class BursaWolfPar
      */
     @Test
     public void testGetPositionVectorTransformation() throws NoninvertibleMatrixException
{
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(null, null);
-        bursaWolf.tZ = 4.5;
-        bursaWolf.rZ = 0.554;
-        bursaWolf.dS = 0.219;
+        final BursaWolfParameters bursaWolf = createWGS72_to_WGS84();
         final MatrixSIS toWGS84 = getPositionVectorTransformation(bursaWolf);
         final MatrixSIS toWGS72 = toWGS84.inverse();
         final MatrixSIS source  = Matrices.create(4, 1, new double[] {3657660.66, 255768.55,
5201382.11, 1});
@@ -108,7 +123,7 @@ public final strictfp class BursaWolfPar
     @Test
     @DependsOnMethod("testGetPositionVectorTransformation")
     public void testProductOfInverse() throws NoninvertibleMatrixException {
-        final BursaWolfParameters bursaWolf = createForNorthSea();
+        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
         final MatrixSIS toWGS84 = getPositionVectorTransformation(bursaWolf);
         final MatrixSIS toED87  = getPositionVectorTransformation(bursaWolf).inverse();
         final MatrixSIS product = toWGS84.multiply(toED87);
@@ -122,9 +137,10 @@ public final strictfp class BursaWolfPar
     @Test
     @DependsOnMethod("testGetPositionVectorTransformation")
     public void testSetPositionVectorTransformation() {
-        final BursaWolfParameters bursaWolf = createForNorthSea();
+        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
         final Matrix matrix = bursaWolf.getPositionVectorTransformation(null);
-        final BursaWolfParameters actual = new BursaWolfParameters(null, null);
+        final BursaWolfParameters actual = new BursaWolfParameters(
+                bursaWolf.getTargetDatum(), bursaWolf.getDomainOfValidity());
         actual.setPositionVectorTransformation(matrix, 1E-10);
         assertEquals(bursaWolf, actual);
     }
@@ -134,7 +150,7 @@ public final strictfp class BursaWolfPar
      */
     @Test
     public void testToString() {
-        final BursaWolfParameters bursaWolf = createForNorthSea();
+        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
         assertEquals("TOWGS84[-82.981, -99.719, -110.709, -0.5076, 0.1503, 0.3898, -0.3143]",
bursaWolf.toString());
     }
 
@@ -143,7 +159,7 @@ public final strictfp class BursaWolfPar
      */
     @Test
     public void testSerialization() {
-        final BursaWolfParameters bursaWolf = createForNorthSea();
+        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
         assertSerializedEquals(bursaWolf);
     }
 }

Added: 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=1541767&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Thu Nov 14 00:08:38 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.datum;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.referencing.datum.GeodeticDatum;
+import org.apache.sis.referencing.GeodeticObjects;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
+import org.junit.Test;
+
+import static org.opengis.test.Assert.*;
+
+
+/**
+ * Tests the {@link DefaultGeodeticDatum} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@DependsOn({DefaultEllipsoidTest.class, BursaWolfParametersTest.class})
+public final strictfp class DefaultGeodeticDatumTest extends TestCase {
+    /**
+     * Tests {@link DefaultGeodeticDatum#getPositionVectorTransformation(GeodeticDatum, Extent)}.
+     */
+    @Test
+    public void testGetPositionVectorTransformation() {
+        final Map<String,Object> properties = new HashMap<>();
+        assertNull(properties.put(DefaultGeodeticDatum.NAME_KEY, "Invalid dummy datum"));
+        /*
+         * Associate two BursaWolfParameters, one valid only in a local area and the other
one
+         * valid globaly.  Note that we are building an invalid set of parameters, because
the
+         * source datum are not the same in both case. But for this test we are not interrested
+         * 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)
+        }));
+        /*
+         * Build the datum.
+         */
+        final GeodeticDatum targetDatum = null; // TODO: need a WGS84 mock.
+        final DefaultGeodeticDatum datum = new DefaultGeodeticDatum(properties,
+                GeodeticObjects.WGS84.ellipsoid(),
+                GeodeticObjects.WGS84.primeMeridian()
+        );
+        // TODO: test getPositionVectorTransformation
+    }
+}

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

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.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=1541767&r1=1541766&r2=1541767&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] Thu Nov 14 00:08:38 2013
@@ -53,6 +53,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
     org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
+    org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
     org.apache.sis.referencing.GeodeticObjectsTest.class,
 
     org.apache.sis.geometry.AbstractDirectPositionTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/DoubleConsumer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/DoubleConsumer.java?rev=1541767&r1=1541766&r2=1541767&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/DoubleConsumer.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/DoubleConsumer.java
[UTF-8] Thu Nov 14 00:08:38 2013
@@ -18,7 +18,7 @@ package org.apache.sis.internal.jdk8;
 
 
 /**
- * Placeholder for the {@link ava.util.function.DoubleConsumer} interface.
+ * Placeholder for the {@link java.util.function.DoubleConsumer} interface.
  */
 public interface DoubleConsumer {
     /**



Mime
View raw message