sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1811506 - 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-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/mai...
Date Sun, 08 Oct 2017 21:28:36 GMT
Author: desruisseaux
Date: Sun Oct  8 21:28:36 2017
New Revision: 1811506

URL: http://svn.apache.org/viewvc?rev=1811506&view=rev
Log:
Partial support of three-dimensional ProjectedCRS.
This is actually an extension of existing support for three-dimensional GeographicCRS.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
  (with props)
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/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.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/internal/referencing/provider/ProvidersTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.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=1811506&r1=1811505&r2=1811506&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] Sun Oct  8 21:28:36 2017
@@ -32,7 +32,9 @@ import org.opengis.referencing.crs.Coord
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.DerivedCRS;
 import org.opengis.referencing.crs.GeodeticCRS;
+import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.ProjectedCRS;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CSFactory;
 import org.opengis.referencing.cs.CartesianCS;
@@ -459,14 +461,14 @@ public class ReferencingServices extends
                 final VerticalDatum datum = ((VerticalCRS) vertical).getDatum();
                 if (datum != null && datum.getVerticalDatumType() == VerticalDatumTypes.ELLIPSOIDAL)
{
                     int axisPosition = 0;
-                    EllipsoidalCS cs = null;
+                    CoordinateSystem cs = null;
                     CoordinateReferenceSystem crs = null;
-                    if (i == 0 || (cs = getCsIfGeographic2D(crs = components[i - 1])) ==
null) {
+                    if (i == 0 || (cs = getCsIfHorizontal2D(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) {
+                        if (i+1 >= components.length || (cs = getCsIfHorizontal2D(crs
= components[i + 1])) == null) {
                             continue;
                         }
                         axisPosition = 1;
@@ -482,9 +484,20 @@ public class ReferencingServices extends
                     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((components.length == 2) ? properties
: getProperties(crs),
-                            ((GeodeticCRS) crs).getDatum(), cs);
+                    final Map<String,?> csProps = getProperties(cs, false);
+                    final Map<String,?> crsProps = (components.length == 2) ? properties
: getProperties(crs, false);
+                    if (crs instanceof GeodeticCRS) {
+                        cs = csFactory.createEllipsoidalCS(csProps, axes[0], axes[1], axes[2]);
+                        crs = crsFactory.createGeographicCRS(crsProps, ((GeodeticCRS) crs).getDatum(),
(EllipsoidalCS) cs);
+                    } else {
+                        final ProjectedCRS proj = (ProjectedCRS) crs;
+                        GeographicCRS base = proj.getBaseCRS();
+                        if (base.getCoordinateSystem().getDimension() == 2) {
+                            base = (GeographicCRS) createCompoundCRS(crsFactory, csFactory,
getProperties(base, false), base, vertical);
+                        }
+                        cs = csFactory.createCartesianCS(csProps, axes[0], axes[1], axes[2]);
+                        crs = crsFactory.createProjectedCRS(crsProps, base, proj.getConversionFromBase(),
(CartesianCS) 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
@@ -504,13 +517,22 @@ public class ReferencingServices extends
     }
 
     /**
-     * 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) {
+     * Returns the coordinate system if the given CRS is a two-dimensional geographic or
projected CRS,
+     * or {@code null} otherwise. The returned coordinate system is either ellipsoidal or
Cartesian;
+     * no other type is returned.
+     */
+    private static CoordinateSystem getCsIfHorizontal2D(final CoordinateReferenceSystem crs)
{
+        final boolean isProjected = (crs instanceof ProjectedCRS);
+        if (isProjected || crs instanceof GeodeticCRS) {
             final CoordinateSystem cs = crs.getCoordinateSystem();
-            if (cs instanceof EllipsoidalCS && cs.getDimension() == 2) {
-                return (EllipsoidalCS) cs;
+            if (cs.getDimension() == 2 && (isProjected || cs instanceof EllipsoidalCS))
{
+                /*
+                 * ProjectedCRS are guaranteed to be associated to CartesianCS, so we do
not test that.
+                 * GeodeticCRS may be associated to either CartesianCS or EllipsoidalCS,
but this method
+                 * shall accept only EllipsoidalCS. Actually we should accept only GeographicCRS,
but we
+                 * relax this condition by accepting GeodeticCRS with EllipsoidalCS.
+                 */
+                return cs;
             }
         }
         return null;
@@ -616,11 +638,12 @@ public class ReferencingServices extends
      * Returns the properties of the given object.
      *
      * @param  object  the object from which to get the properties.
+     * @param  keepId  {@code true} for preserving the identifiers, {@code false} for discarding
them.
      * @return the properties of the given object.
      *
      * @since 0.6
      */
-    public Map<String,?> getProperties(final IdentifiedObject object) {
+    public Map<String,?> getProperties(final IdentifiedObject object, final boolean
keepId) {
         return Collections.singletonMap(IdentifiedObject.NAME_KEY, object.getName());
     }
 

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=1811506&r1=1811505&r2=1811506&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] Sun Oct  8 21:28:36 2017
@@ -1928,7 +1928,7 @@ class GeodeticObjectParser extends MathT
                 if (VerticalDatumType.OTHER_SURFACE.equals(datum.getVerticalDatumType()))
{
                     final VerticalDatumType type = VerticalDatumTypes.guess(datum.getName().getCode(),
datum.getAlias(), cs.getAxis(0));
                     if (!VerticalDatumType.OTHER_SURFACE.equals(type)) {
-                        datum = datumFactory.createVerticalDatum(referencing.getProperties(datum),
type);
+                        datum = datumFactory.createVerticalDatum(referencing.getProperties(datum,
true), type);
                     }
                 }
                 verticalCRS = crsFactory.createVerticalCRS(properties, datum, (VerticalCS)
cs);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1811506&r1=1811505&r2=1811506&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] Sun Oct  8 21:28:36 2017
@@ -91,6 +91,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.util.resources.Errors;
@@ -692,13 +693,15 @@ public final class ServicesForMetadata e
      * Returns the properties of the given object.
      *
      * @param  object  the object from which to get the properties.
+     * @param  keepId  {@code true} for preserving the identifiers, {@code false} for discarding
them.
      * @return the properties of the given object.
      *
      * @since 0.6
      */
     @Override
-    public Map<String,?> getProperties(final IdentifiedObject object) {
-        return IdentifiedObjects.getProperties(object);
+    public Map<String,?> getProperties(final IdentifiedObject object, final boolean
keepId) {
+        return IdentifiedObjects.getProperties(object, keepId ? CharSequences.EMPTY_ARRAY
+                : new String[] {IdentifiedObject.IDENTIFIERS_KEY});
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1811506&r1=1811505&r2=1811506&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] Sun Oct  8 21:28:36 2017
@@ -31,6 +31,7 @@ import org.opengis.util.GenericName;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterNotFoundException;
+import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.Projection;
@@ -127,6 +128,15 @@ public abstract class MapProjection exte
     }
 
     /**
+     * The three-dimensional counterpart of this two-dimensional map projection.
+     * This is created when first needed.
+     *
+     * @see #redimension(int, int)
+     * @see GeodeticOperation#redimensioned
+     */
+    private OperationMethod redimensioned;
+
+    /**
      * Constructs a math transform provider from a set of parameters. The provider
      * {@linkplain #getIdentifiers() identifiers} will be the same than the parameter ones.
      *
@@ -147,6 +157,26 @@ public abstract class MapProjection exte
     }
 
     /**
+     * Returns this operation method with the specified number of dimensions.
+     * The number of dimensions can be only 2 or 3, and must be the same for source and target
CRS.
+     *
+     * @return the redimensioned projection method, or {@code this} if no change is needed.
+     *
+     * @since 0.8
+     */
+    @Override
+    public final OperationMethod redimension(final int sourceDimensions, final int targetDimensions)
{
+        if (sourceDimensions != 3 || targetDimensions != 3) {
+            return super.redimension(sourceDimensions, targetDimensions);
+        } else synchronized (this) {
+            if (redimensioned == null) {
+                redimensioned = new MapProjection3D(this);
+            }
+            return redimensioned;
+        }
+    }
+
+    /**
      * Validates the given parameter value. This method duplicates the verification already
      * done by {@link org.apache.sis.parameter.DefaultParameterValue#setValue(Object, Unit)}.
      * But we check again because we have no guarantee that the parameters given by the user

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java?rev=1811506&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection3D.java
[UTF-8] Sun Oct  8 21:28:36 2017
@@ -0,0 +1,96 @@
+/*
+ * 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.provider;
+
+import javax.xml.bind.annotation.XmlTransient;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.OperationMethod;
+import org.opengis.referencing.operation.Projection;
+import org.opengis.util.FactoryException;
+
+
+/**
+ * The three-dimensional counter-part of a map projection. This is the same than two-dimensional
map projections
+ * with only the ellipsoidal height which pass through.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+@XmlTransient
+final class MapProjection3D extends AbstractProvider {
+    /**
+     * Serial number for inter-operability with different versions.
+     */
+    private static final long serialVersionUID = -6089942320273982171L;
+
+    /**
+     * The two-dimensional counterpart of this three-dimensional map projection.
+     */
+    private final MapProjection redimensioned;
+
+    /**
+     * Constructs a three-dimensional map projection for the given two-dimensional projection.
+     */
+    MapProjection3D(final MapProjection proj) {
+        super(3, 3, proj.getParameters());
+        redimensioned = proj;
+    }
+
+    /**
+     * Returns this operation method with the specified number of dimensions.
+     * The number of dimensions can be only 2 or 3, and must be the same for source and target
CRS.
+     */
+    @Override
+    public OperationMethod redimension(final int sourceDimensions, final int targetDimensions)
{
+        if (sourceDimensions == 2 && targetDimensions == 2) {
+            return redimensioned;
+        }
+        return super.redimension(sourceDimensions, targetDimensions);
+    }
+
+    /**
+     * Returns the operation type for this map projection.
+     */
+    @Override
+    public Class<? extends Projection> getOperationType() {
+        return redimensioned.getOperationType();
+    }
+
+    /**
+     * Notifies {@code DefaultMathTransformFactory} that map projections require
+     * values for the {@code "semi_major"} and {@code "semi_minor"} parameters.
+     *
+     * @return 1, meaning that the operation requires a source ellipsoid.
+     */
+    @Override
+    public int getEllipsoidsMask() {
+        return redimensioned.getEllipsoidsMask();
+    }
+
+    /**
+     * Creates a three-dimensional map projections for the given parameters.
+     * The ellipsoidal height is assumed to be in the third dimension.
+     */
+    @Override
+    public MathTransform createMathTransform(MathTransformFactory factory, ParameterValueGroup
parameters) throws FactoryException {
+        return factory.createPassThroughTransform(0, redimensioned.createMathTransform(factory,
parameters), 1);
+    }
+}

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

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

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=1811506&r1=1811505&r2=1811506&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] Sun Oct  8 21:28:36 2017
@@ -23,8 +23,11 @@ import org.opengis.metadata.extent.Geogr
 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.crs.GeographicCRS;
+import org.opengis.referencing.crs.ProjectedCRS;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.util.FactoryException;
 import org.apache.sis.internal.metadata.ReferencingServices;
@@ -34,8 +37,10 @@ import org.apache.sis.metadata.iso.exten
 import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.referencing.cs.HardCodedCS;
 import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.referencing.operation.HardCodedConversions;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -59,6 +64,16 @@ import static org.apache.sis.test.TestUt
 })
 public final strictfp class ServicesForMetadataTest extends TestCase {
     /**
+     * Tests {@link org.apache.sis.metadata.iso.extent.Extents#centroid(GeographicBoundingBox)}.
+     *
+     * @since 0.8
+     */
+    @Test
+    public void testGeographicBoundingBoxCentroid() {
+        org.apache.sis.metadata.iso.extent.ExtentsTest.testCentroid();
+    }
+
+    /**
      * Creates a test envelope with the given CRS and initialized with
      * [-10 … 70]° of longitude, [-20 … 30]° of latitude, [-40 … 60] metres of elevation
      * and [51000 … 52000] modified Julian days.
@@ -97,7 +112,6 @@ public final strictfp class ServicesForM
         assertEqualsIgnoreMetadata(expectedCRS.crs(), extent.getVerticalCRS());
     }
 
-
     /**
      * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox)}
      * from a three-dimensional envelope.
@@ -165,7 +179,8 @@ public final strictfp class ServicesForM
     }
 
     /**
-     * Tests {@link ServicesForMetadata#createCompoundCRS ReferencingUtilities.createCompoundCRS(…)}.
+     * Tests {@link ServicesForMetadata#createCompoundCRS ReferencingUtilities.createCompoundCRS(…)}
+     * with a geographic CRS.
      *
      * @throws FactoryException if a CRS can not be created.
      *
@@ -174,40 +189,38 @@ public final strictfp class ServicesForM
      * @since 0.7
      */
     @Test
-    public void testCreateCompoundCRS() throws FactoryException {
-        final ReferencingServices services = ServicesForMetadata.getInstance();
+    public void testCreateCompoundGeographicCRS() 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)");
+        final GeographicCRS horizontal   = HardCodedCRS.WGS84;
+        final GeographicCRS horizontal3D = HardCodedCRS.WGS84_3D;
+        final VerticalCRS   vertical     = HardCodedCRS.ELLIPSOIDAL_HEIGHT;
+        final TemporalCRS   temporal     = HardCodedCRS.TIME;
+        final VerticalCRS   geoidal      = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
         /*
          * 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());
+        CoordinateReferenceSystem compound = services.createCompoundCRS(factory, factory,
properties, horizontal, geoidal, temporal);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal, geoidal, temporal},
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());
+        compound = services.createCompoundCRS(factory, factory, properties, horizontal, vertical);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal3D}, 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());
+        compound = services.createCompoundCRS(factory, factory, properties, horizontal, vertical,
temporal);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal3D, temporal}, 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_φλ);
+        compound = services.createCompoundCRS(factory, factory, properties, temporal, vertical,
HardCodedCRS.WGS84_φλ);
         final Object[] components = CRS.getSingleComponents(compound).toArray();
         assertEquals(2, components.length);
-        assertEqualsIgnoreMetadata(HardCodedCRS.TIME, components[0]);
+        assertEqualsIgnoreMetadata(temporal, 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(),
@@ -215,12 +228,52 @@ public final strictfp class ServicesForM
     }
 
     /**
-     * Tests {@link org.apache.sis.metadata.iso.extent.Extents#centroid(GeographicBoundingBox)}.
+     * Tests {@link ServicesForMetadata#createCompoundCRS ReferencingUtilities.createCompoundCRS(…)}
+     * with a projected CRS.
+     *
+     * @throws FactoryException if a CRS can not be created.
      *
      * @since 0.8
      */
     @Test
-    public void testGeographicBoundingBoxCentroid() {
-        org.apache.sis.metadata.iso.extent.ExtentsTest.testCentroid();
+    @DependsOnMethod("testCreateCompoundGeographicCRS")
+    public void testCreateCompoundProjectedCRS() throws FactoryException {
+        final ReferencingServices  services = ServicesForMetadata.getInstance();
+        final GeodeticObjectFactory factory = new GeodeticObjectFactory();
+        final Map<String,String> properties = Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY,
"World Mercator (4D)");
+        final ProjectedCRS horizontal   = factory.createProjectedCRS(properties, HardCodedCRS.WGS84,
   HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED);
+        final ProjectedCRS horizontal3D = factory.createProjectedCRS(properties, HardCodedCRS.WGS84_3D,
HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED_3D);
+        final VerticalCRS  vertical     = HardCodedCRS.ELLIPSOIDAL_HEIGHT;
+        final TemporalCRS  temporal     = HardCodedCRS.TIME;
+        final VerticalCRS  geoidal      = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
+        /*
+         * createCompoundCRS(…) should not combine ProjectedCRS with non-ellipsoidal height.
+         */
+        CoordinateReferenceSystem compound = services.createCompoundCRS(factory, factory,
properties, horizontal, geoidal, temporal);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal, geoidal, temporal},
CRS.getSingleComponents(compound).toArray());
+        /*
+         * createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height.
+         */
+        if (true) return;       // TODO - debug after this point.
+        compound = services.createCompoundCRS(factory, factory, properties, horizontal, vertical);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal3D}, CRS.getSingleComponents(compound).toArray());
+        /*
+         * createCompoundCRS(…) should combine GeographicCRS with ellipsoidal height and
keep time.
+         */
+        compound = services.createCompoundCRS(factory, factory, properties, horizontal, vertical,
temporal);
+        assertArrayEqualsIgnoreMetadata(new SingleCRS[] {horizontal3D, temporal}, 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,
+                temporal, vertical, HardCodedCRS.WGS84_φλ);
+        final Object[] components = CRS.getSingleComponents(compound).toArray();
+        assertEquals(2, components.length);
+        assertEqualsIgnoreMetadata(temporal, 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/internal/referencing/provider/ProvidersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java?rev=1811506&r1=1811505&r2=1811506&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] Sun Oct  8 21:28:36 2017
@@ -109,7 +109,7 @@ public final strictfp class ProvidersTes
 
     /**
      * Returns the subset of {@link #methods()} which are expected to support
-     * {@link AbstractProvider#redimension(int, int)}.
+     * {@link AbstractProvider#redimension(int, int)}, not including map projections.
      */
     private static Class<?>[] redimensionables() {
         return new Class<?>[] {
@@ -224,6 +224,13 @@ public final strictfp class ProvidersTes
                         }
                     }
                 }
+            } else if (method instanceof MapProjection) {
+                final OperationMethod proj3D = ((MapProjection) method).redimension(sourceDimensions
^ 1, targetDimensions ^ 1);
+                assertNotSame("redimension(3,3) should return a new method.", method, proj3D);
+                assertSame("redimension(2,2) should give back the original method.", method,
+                        ((DefaultOperationMethod) proj3D).redimension(sourceDimensions, targetDimensions));
+                assertSame("Value of redimension(3,3) should have been cached.", proj3D,
+                        ((MapProjection) method).redimension(sourceDimensions ^ 1, targetDimensions
^ 1));
             } else try {
                 ((DefaultOperationMethod) method).redimension(sourceDimensions ^ 1, targetDimensions
^ 1);
                 fail("Type " + method.getClass().getName() + " is not in our list of redimensionable
methods.");

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1811506&r1=1811505&r2=1811506&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] Sun Oct  8 21:28:36 2017
@@ -163,6 +163,19 @@ public final strictfp class HardCodedCS
             HardCodedAxes.NORTHING);
 
     /**
+     * A three-dimensional Cartesian CS with
+     * <var>{@linkplain HardCodedAxes#EASTING Easting}</var>,
+     * <var>{@linkplain HardCodedAxes#NORTHING Northing}</var>
+     * <var>{@linkplain HardCodedAxes#ELLIPSOIDAL_HEIGHT Height}</var>
+     * axes in metres.
+     */
+    public static final DefaultCartesianCS PROJECTED_3D = new DefaultCartesianCS(
+            singletonMap(NAME_KEY, "Projected"),
+            HardCodedAxes.EASTING,
+            HardCodedAxes.NORTHING,
+            HardCodedAxes.ELLIPSOIDAL_HEIGHT);
+
+    /**
      * A two-dimensional Cartesian CS with
      * <var>{@linkplain HardCodedAxes#X x}</var>,
      * <var>{@linkplain HardCodedAxes#Y y}</var>



Mime
View raw message