sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1732336 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/internal/metadata/ sis-referencing/src/main/java...
Date Thu, 25 Feb 2016 18:16:26 GMT
Author: desruisseaux
Date: Thu Feb 25 18:16:26 2016
New Revision: 1732336

URL: http://svn.apache.org/viewvc?rev=1732336&view=rev
Log:
When parsing a WKT 1 string, convert (Geographic2D + Vertical) into (Geographic3D) CRS.
Issue: SIS-317.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -25,15 +25,20 @@ import org.opengis.geometry.Envelope;
 import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.crs.CRSFactory;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.DerivedCRS;
+import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CSFactory;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.CoordinateOperationFactory;
@@ -50,6 +55,7 @@ import org.apache.sis.internal.system.De
 import org.apache.sis.internal.system.OptionalDependency;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.io.wkt.FormattableObject;
+import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.util.Deprecable;
 
@@ -408,6 +414,81 @@ public class ReferencingServices extends
     }
 
     /**
+     * Creates a compound CRS, but we special processing for (two-dimensional Geographic
+ ellipsoidal heights) tupples.
+     * If any such tupple is found, a three-dimensional geographic CRS is created instead
than the compound CRS.
+     *
+     * @param  crsFactory The factory to use for creating compound or three-dimensional geographic
CRS.
+     * @param  csFactory  The factory to use for creating three-dimensional ellipsoidal CS,
if needed.
+     * @param  properties Name and other properties to give to the new object.
+     * @param  components ordered array of {@code CoordinateReferenceSystem} objects.
+     * @return The coordinate reference system for the given properties.
+     * @throws FactoryException if the object creation failed.
+     *
+     * @since 0.7
+     */
+    public final CoordinateReferenceSystem createCompoundCRS(final CRSFactory crsFactory,
final CSFactory csFactory,
+            final Map<String,?> properties, CoordinateReferenceSystem... components)
throws FactoryException
+    {
+        for (int i=0; i<components.length; i++) {
+            final CoordinateReferenceSystem vertical = components[i];
+            if (vertical instanceof VerticalCRS) {
+                final VerticalDatum datum = ((VerticalCRS) vertical).getDatum();
+                if (datum != null && datum.getVerticalDatumType() == VerticalDatumTypes.ELLIPSOIDAL)
{
+                    int axisPosition = 0;
+                    EllipsoidalCS cs = null;
+                    CoordinateReferenceSystem crs = null;
+                    if (i == 0 || (cs = getCsIfGeographic2D(crs = components[i - 1])) ==
null) {
+                        /*
+                         * GeographicCRS are normally before VerticalCRS. But Apache SIS
is tolerant to the
+                         * opposite order (note however that such ordering is illegal according
ISO 19162).
+                         */
+                        if (i+1 >= components.length || (cs = getCsIfGeographic2D(crs
= components[i + 1])) == null) {
+                            continue;
+                        }
+                        axisPosition = 1;
+                    }
+                    /*
+                     * At this point we have the horizontal and vertical components. The
horizontal component
+                     * begins at 'axisPosition', which is almost always zero. Create the
three-dimensional CRS.
+                     */
+                    final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[3];
+                    axes[axisPosition++   ] = cs.getAxis(0);
+                    axes[axisPosition++   ] = cs.getAxis(1);
+                    axes[axisPosition %= 3] = vertical.getCoordinateSystem().getAxis(0);
+                    cs = csFactory.createEllipsoidalCS(getProperties(cs), axes[0], axes[1],
axes[2]);
+                    crs = crsFactory.createGeographicCRS(getProperties(crs), ((GeodeticCRS)
crs).getDatum(), cs);
+                    /*
+                     * Remove the VerticalCRS and store the three-dimensional GeographicCRS
in place of the previous
+                     * two-dimensional GeographicCRS. Then let the loop continues in case
there is other CRS to merge
+                     * (should never happen, but we are paranoiac).
+                     */
+                    components = ArraysExt.remove(components, i, 1);
+                    if (axisPosition != 0) i--;             // GeographicCRS before VerticalCRS
(usual case).
+                    components[i] = crs;
+                }
+            }
+        }
+        switch (components.length) {
+            case 0:  return null;
+            case 1:  return components[0];
+            default: return crsFactory.createCompoundCRS(properties, components);
+        }
+    }
+
+    /**
+     * Returns the coordinate system if the given CRS is a two-dimensional geographic CRS,
or {@code null} otherwise.
+     */
+    private static EllipsoidalCS getCsIfGeographic2D(final CoordinateReferenceSystem crs)
{
+        if (crs instanceof GeodeticCRS) {
+            final CoordinateSystem cs = crs.getCoordinateSystem();
+            if (cs instanceof EllipsoidalCS && cs.getDimension() == 2) {
+                return (EllipsoidalCS) cs;
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns an axis direction from a pole along a meridian.
      * The given meridian is usually, but not necessarily, relative to the Greenwich meridian.
      *

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/VerticalDatumTypes.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -39,7 +39,7 @@ import org.apache.sis.util.Characters;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class VerticalDatumTypes implements CodeList.Filter {
@@ -108,12 +108,19 @@ public final class VerticalDatumTypes im
 
     /**
      * Returns the legacy code for the datum type, or 0 if unknown.
+     * This method is used for WKT 1 formatting.
      *
-     * @param  ordinal The {@linkplain CodeList#ordinal() ordinal} value of the {@link VerticalDatumType}.
+     * @param  type The vertical datum type, or {@code null} if unknown.
      * @return The legacy code for the given datum type, or 0 if unknown.
      */
-    public static int toLegacy(final int ordinal) {
-        return (ordinal >= 0 && ordinal < LEGACY_CODES.length) ? LEGACY_CODES[ordinal]
: 0;
+    public static int toLegacy(final VerticalDatumType type) {
+        if (type != null) {
+            final int ordinal = type.ordinal();
+            if (ordinal >= 0 && ordinal < LEGACY_CODES.length) {
+                return LEGACY_CODES[ordinal];
+            }
+        }
+        return 0;
     }
 
     /**
@@ -219,6 +226,8 @@ public final class VerticalDatumTypes im
      * We do not test the characters following the prefix because the word may be incomplete
      * (e.g. {@code "geoid"} versus {@code "geoidal"}).
      *
+     * <p>This method is public as an implementation side-effect and should be ignored.</p>
+     *
      * @param code The code to test.
      * @return {@code true} if the code matches the criterion.
       */
@@ -230,6 +239,7 @@ public final class VerticalDatumTypes im
 
     /**
      * Returns {@code null} for disabling the creation of new code list elements.
+     * This method is public as an implementation side-effect and should be ignored.
      *
      * @return {@code null}.
      */

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -821,14 +821,14 @@ final class GeodeticObjectParser extends
                     direction = AxisDirection.UP;
                     if (datum instanceof VerticalDatum) {
                         final VerticalDatumType vt = ((VerticalDatum) datum).getVerticalDatumType();
-                        if (VerticalDatumType.GEOIDAL.equals(vt)) {
+                        if (vt == VerticalDatumType.GEOIDAL) {
                             nz = AxisNames.GRAVITY_RELATED_HEIGHT;
                             z  = "H";
-                        } else if (VerticalDatumType.DEPTH.equals(vt)) {
+                        } else if (vt == VerticalDatumType.DEPTH) {
                             direction = AxisDirection.DOWN;
                             nz = AxisNames.DEPTH;
                             z  = "D";
-                        } else if (VerticalDatumTypes.ELLIPSOIDAL.equals(vt)) {
+                        } else if (vt == VerticalDatumTypes.ELLIPSOIDAL) {
                             // Not allowed by ISO 19111 as a standalone axis, but SIS is
                             // tolerant to this case since it is sometime hard to avoid.
                             nz = AxisNames.ELLIPSOIDAL_HEIGHT;
@@ -2020,12 +2020,15 @@ final class GeodeticObjectParser extends
      *     COMPD_CS["<name>", <head cs>, <tail cs> {,<authority>}]
      * }
      *
+     * In the particular case where there is a geographic CRS and an ellipsoidal height,
+     * this method rather build a three-dimensional geographic CRS.
+     *
      * @param  mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
      * @param  parent The parent element.
      * @return The {@code "CompoundCRS"} element as a {@link CompoundCRS} object.
      * @throws ParseException if the {@code "CompoundCRS"} element can not be parsed.
      */
-    private CompoundCRS parseCompoundCRS(final int mode, final Element parent) throws ParseException
{
+    private CoordinateReferenceSystem parseCompoundCRS(final int mode, final Element parent)
throws ParseException {
         final Element element = parent.pullElement(mode, WKTKeywords.CompoundCRS, WKTKeywords.Compd_CS);
         if (element == null) {
             return null;
@@ -2037,7 +2040,7 @@ final class GeodeticObjectParser extends
             components.add(crs);
         }
         try {
-            return crsFactory.createCompoundCRS(parseMetadataAndClose(element, name, null),
+            return referencing.createCompoundCRS(crsFactory, csFactory, parseMetadataAndClose(element,
name, null),
                     components.toArray(new CoordinateReferenceSystem[components.size()]));
         } catch (FactoryException exception) {
             throw element.parseFailed(exception);

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/VerticalDatumTypesTest.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -30,7 +30,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final strictfp class VerticalDatumTypesTest extends TestCase {
@@ -49,9 +49,9 @@ public final strictfp class VerticalDatu
      */
     @Test
     public void testToLegacy() {
-        assertEquals(2002, VerticalDatumTypes.toLegacy(VerticalDatumTypes.ELLIPSOIDAL.ordinal()));
-        assertEquals(2005, VerticalDatumTypes.toLegacy(VerticalDatumType .GEOIDAL    .ordinal()));
-        assertEquals(2006, VerticalDatumTypes.toLegacy(VerticalDatumType .DEPTH      .ordinal()));
+        assertEquals(2002, VerticalDatumTypes.toLegacy(VerticalDatumTypes.ELLIPSOIDAL));
+        assertEquals(2005, VerticalDatumTypes.toLegacy(VerticalDatumType .GEOIDAL));
+        assertEquals(2006, VerticalDatumTypes.toLegacy(VerticalDatumType .DEPTH));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -301,7 +301,7 @@ public class DefaultVerticalDatum extend
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
         if (formatter.getConvention().majorVersion() == 1) {
-            formatter.append(VerticalDatumTypes.toLegacy(type().ordinal()));
+            formatter.append(VerticalDatumTypes.toLegacy(type()));
             return WKTKeywords.Vert_Datum;
         }
         return formatter.shortOrLong(WKTKeywords.VDatum, WKTKeywords.VerticalDatum);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -16,17 +16,26 @@
  */
 package org.apache.sis.internal.referencing;
 
+import java.util.Map;
+import java.util.Collections;
 import org.opengis.geometry.Envelope;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
 import org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent;
 import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.referencing.factory.GeodeticObjectFactory;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -41,7 +50,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -154,4 +163,54 @@ public final strictfp class ServicesForM
         verifySpatialExtent((GeographicBoundingBox) getSingleton(extent.getSpatialExtent()));
         verifyVerticalExtent(CommonCRS.Vertical.MEAN_SEA_LEVEL, extent.getVerticalExtent());
     }
+
+    /**
+     * Tests {@link ServicesForMetadata#createCompoundCRS ReferencingUtilities.createCompoundCRS(…)}.
+     *
+     * @throws FactoryException if a CRS can not be created.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-303">SIS-303</a>
+     *
+     * @since 0.7
+     */
+    @Test
+    public void testCreateCompoundCRS() throws FactoryException {
+        final ReferencingServices services = ServicesForMetadata.getInstance();
+        final GeodeticObjectFactory factory = new GeodeticObjectFactory();
+        final Map<String,String> properties = Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY,
"WGS 84 (4D)");
+        /*
+         * createCompoundCRS(…) should not combine GeographicCRS with non-ellipsoidal height.
+         */
+        CoordinateReferenceSystem compound = services.createCompoundCRS(factory, factory,
properties,
+                HardCodedCRS.WGS84, HardCodedCRS.GRAVITY_RELATED_HEIGHT, HardCodedCRS.TIME);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {HardCodedCRS.WGS84, HardCodedCRS.GRAVITY_RELATED_HEIGHT,
HardCodedCRS.TIME},
+                CRS.getSingleComponents(compound).toArray());
+        /*
+         * createCompoundCRS(…) should combine GeographicCRS with ellipsoidal height.
+         */
+        compound = services.createCompoundCRS(factory, factory, properties,
+                HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {HardCodedCRS.WGS84_3D},
+                CRS.getSingleComponents(compound).toArray());
+        /*
+         * createCompoundCRS(…) should combine GeographicCRS with ellipsoidal height and
keep time.
+         */
+        compound = services.createCompoundCRS(factory, factory, properties,
+                HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCRS.TIME);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {HardCodedCRS.WGS84_3D, HardCodedCRS.TIME},
+                CRS.getSingleComponents(compound).toArray());
+        /*
+         * Non-standard feature: accept (VerticalCRS + GeodeticCRS) order.
+         * The test below use the reverse order for all axes compared to the previous test.
+         */
+        compound = services.createCompoundCRS(factory, factory, properties,
+                HardCodedCRS.TIME, HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCRS.WGS84_φλ);
+        final Object[] components = CRS.getSingleComponents(compound).toArray();
+        assertEquals(2, components.length);
+        assertEqualsIgnoreMetadata(HardCodedCRS.TIME, components[0]);
+        assertInstanceOf("Shall be a three-dimensional geographic CRS.", GeographicCRS.class,
components[1]);
+        assertAxisDirectionsEqual("Shall be a three-dimensional geographic CRS.",
+                ((CoordinateReferenceSystem) components[1]).getCoordinateSystem(),
+                AxisDirection.UP, AxisDirection.NORTH, AxisDirection.EAST);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -998,6 +998,40 @@ public final strictfp class GeodeticObje
     }
 
     /**
+     * Tests the parsing of a compound CRS from a WKT 1 string with ellipsoidal height and
its conversion
+     * to a three-dimensional geographic CRS.
+     *
+     * @throws ParseException if the parsing failed.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-317">SIS-317</a>
+     *
+     * @since 0.7
+     */
+    @Test
+    @DependsOnMethod("testCompoundCRS")
+    public void testCompoundWKT1() throws ParseException {
+        final GeographicCRS crs = parse(GeographicCRS.class,
+                "COMPD_CS[“WGS 84 (3D)”,\n" +
+                "  GEOGCS[“WGS 84”,\n" +
+                "    DATUM[“World Geodetic System 1984”,\n" +
+                "      SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+                "      PRIMEM[“Greenwich”, 0.0],\n" +
+                "    UNIT[“degree”, 0.017453292519943295],\n" +
+                "    AXIS[“Longitude”, EAST],\n" +
+                "    AXIS[“Latitude”, NORTH]],\n" +
+                "  VERT_CS[“Ellipsoidal height”,\n" +
+                "    VERT_DATUM[“Ellipsoid”, 2002],\n" +
+                "    UNIT[“metre”, 1],\n" +
+                "    AXIS[“Ellipsoidal height”, UP]]]");
+
+        final CoordinateSystem cs = crs.getCoordinateSystem();
+        assertEquals("dimension", 3, cs.getDimension());
+        assertLongitudeAxisEquals(cs.getAxis(0));
+        assertLatitudeAxisEquals (cs.getAxis(1));
+        assertUnboundedAxisEquals("Ellipsoidal height", "h", AxisDirection.UP, SI.METRE,
cs.getAxis(2));
+    }
+
+    /**
      * Tests the production of a warning messages when the WKT contains unknown elements.
      *
      * @throws ParseException if the parsing failed.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
[UTF-8] Thu Feb 25 18:16:26 2016
@@ -172,9 +172,9 @@ public final strictfp class DefaultGeogr
      * <p>This CRS used in this test is equivalent to {@code EPSG:4979} except for
axis order,
      * since EPSG puts latitude before longitude.</p>
      *
-     * @since 0.7
-     *
      * @see #testWKT1_For3D()
+     *
+     * @since 0.7
      */
     @Test
     @DependsOnMethod("testWKT2")
@@ -300,9 +300,10 @@ public final strictfp class DefaultGeogr
      * geographic CRS followed by an ellipsoidal height. Such construction is illegal according
ISO 19111, so this
      * split shall be done on-the-fly only for formatting purpose.
      *
-     * @since 0.7
-     *
      * @see #testWKT2_For3D()
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-317">SIS-317</a>
+     *
+     * @since 0.7
      */
     @Test
     @DependsOnMethod("testWKT1")

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1732336&r1=1732335&r2=1732336&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
Thu Feb 25 18:16:26 2016
@@ -33,6 +33,8 @@ import org.xml.sax.SAXException;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.Classes;
 
 // Branch-dependent imports
 import java.util.Objects;
@@ -100,6 +102,33 @@ public strictfp class Assert extends org
     }
 
     /**
+     * Asserts that the two given arrays contains objects that are equal ignoring metadata.
+     * See {@link ComparisonMode#IGNORE_METADATA} for more information.
+     *
+     * @param expected  The expected objects (array can be {@code null}).
+     * @param actual    The actual objects (array can be {@code null}).
+     *
+     * @since 0.7
+     */
+    public static void assertArrayEqualsIgnoreMetadata(final Object[] expected, final Object[]
actual) {
+        if (expected != actual) {
+            if (expected == null) {
+                assertNull("Expected null array.", actual);
+            } else {
+                assertNotNull("Expected non-null array.", actual);
+                final int length = StrictMath.min(expected.length, actual.length);
+                for (int i=0; i<length; i++) try {
+                    assertEqualsIgnoreMetadata(expected[i], actual[i]);
+                } catch (AssertionError e) {
+                    throw new AssertionError(Exceptions.formatChainedMessages(null, "Comparison
failure at index "
+                            + i + " (a " + Classes.getShortClassName(actual[i]) + ").", e),
e);
+                }
+                assertEquals("Unexpected array length.", expected.length, actual.length);
+            }
+        }
+    }
+
+    /**
      * Asserts that two strings are equal, ignoring the differences in EOL characters.
      * The comparisons is performed one a line-by-line basis. For each line, trailing
      * spaces (but not leading spaces) are ignored.



Mime
View raw message