You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/10/30 09:36:35 UTC
[sis] branch geoapi-4.0 updated: Geographic/Geocentric conversions
shall work with two-dimensional geographic CRS (not only
three-dimensional). https://issues.apache.org/jira/browse/SIS-376
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new d2a7a83 Geographic/Geocentric conversions shall work with two-dimensional geographic CRS (not only three-dimensional). https://issues.apache.org/jira/browse/SIS-376
d2a7a83 is described below
commit d2a7a83e3bddc988910dcf4074ce9c5cd52c8e1c
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Oct 30 10:35:30 2018 +0100
Geographic/Geocentric conversions shall work with two-dimensional geographic CRS (not only three-dimensional).
https://issues.apache.org/jira/browse/SIS-376
---
.../referencing/provider/GeodeticOperation.java | 2 +-
.../internal/referencing/provider/Molodensky.java | 4 +--
.../operation/CoordinateOperationFinder.java | 19 +++++++++++--
.../operation/CoordinateOperationFinderTest.java | 32 +++++++++++++++++++++-
4 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeodeticOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeodeticOperation.java
index 6882615..a6641d3 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeodeticOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeodeticOperation.java
@@ -26,7 +26,7 @@ import org.opengis.referencing.operation.Transformation;
/**
* Base class for providers that perform an operation on geographic or geocentric coordinates.
* In the geographic case, those operations can have two-dimensional and three-dimensional variants
- * by adding or omitting the ellipsoidal height. Sometime those variants are explicitely declared
+ * by adding or omitting the ellipsoidal height. Sometime those variants are explicitly declared
* in the EPSG database and are implemented in this package as separated operations. Sometime those
* variants are specific to Apache SIS and can be fetched only by a call to {@link #redimension(int, int)}.
*
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
index b76e759..daf5272 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
@@ -292,8 +292,8 @@ public final class Molodensky extends GeocentricAffineBetweenGeographic {
}
/**
- * Tries to set the given parameter values. This method should be invoked only when completing parameters
- * without explicit values. This approach complete the work done in {@code DefaultMathTransformFactory},
+ * Tries to set the given parameter value. This method should be invoked only when completing parameters
+ * without explicit values. This approach completes the work done in {@code DefaultMathTransformFactory},
* which already completed the {@code src_semi_major}, {@code src_semi_minor}, {@code tgt_semi_major} and
* {@code tgt_semi_minor} parameters.
*
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
index d7853bc..a2b8a81 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
@@ -34,6 +34,7 @@ import org.opengis.referencing.operation.*;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterDescriptorGroup;
import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.internal.referencing.CoordinateOperations;
import org.apache.sis.internal.referencing.ReferencingUtilities;
@@ -608,8 +609,22 @@ public class CoordinateOperationFinder extends CoordinateOperationRegistry {
context.setTarget(normalized);
}
} else if (identifier == GEOCENTRIC_CONVERSION) {
- parameters = (isGeographicToGeocentric ? GeographicToGeocentric.PARAMETERS
- : GeocentricToGeographic.PARAMETERS).createValue();
+ /*
+ * Geographic ↔︎ Geocentric conversion. The "dim" parameter is Apache SIS specific but is guaranteed
+ * to be present since we use SIS parameter descriptors directly. The default number of dimension is 3,
+ * but we specify the value unconditionally anyway as a safety.
+ */
+ final ParameterDescriptorGroup descriptor;
+ final GeodeticCRS geographic;
+ if (isGeographicToGeocentric) {
+ geographic = sourceCRS;
+ descriptor = GeographicToGeocentric.PARAMETERS;
+ } else {
+ geographic = targetCRS;
+ descriptor = GeocentricToGeographic.PARAMETERS;
+ }
+ parameters = descriptor.createValue();
+ parameters.parameter("dim").setValue(geographic.getCoordinateSystem().getDimension());
} else {
/*
* Coordinate system change (including change in the number of dimensions) without datum shift.
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
index 89986e9..b017868 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
@@ -70,7 +70,7 @@ import static org.apache.sis.test.Assert.*;
* Contrarily to {@link CoordinateOperationRegistryTest}, tests in this class are run without EPSG geodetic dataset.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -403,6 +403,36 @@ public final strictfp class CoordinateOperationFinderTest extends MathTransformT
}
/**
+ * Tests conversion from geographic to geocentric coordinate reference system and conversely.
+ * Both two-dimensional and three-dimensional cases are tested.
+ *
+ * @throws FactoryException if the operation can not be created.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-376">SIS-376</a>
+ */
+ @Test
+ public void testGeocentricConversions() throws FactoryException {
+ testGeocentricConversion(HardCodedCRS.WGS84_3D, HardCodedCRS.GEOCENTRIC);
+ testGeocentricConversion(HardCodedCRS.WGS84, HardCodedCRS.GEOCENTRIC);
+ testGeocentricConversion(HardCodedCRS.GEOCENTRIC, HardCodedCRS.WGS84_3D);
+ testGeocentricConversion(HardCodedCRS.GEOCENTRIC, HardCodedCRS.WGS84);
+ }
+
+ /**
+ * Tests a single case of Geographic ↔︎ Geocentric conversions.
+ */
+ private void testGeocentricConversion(final CoordinateReferenceSystem sourceCRS,
+ final CoordinateReferenceSystem targetCRS)
+ throws FactoryException
+ {
+ final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
+ assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS());
+ assertSame ("targetCRS", targetCRS, operation.getTargetCRS());
+ assertEquals ("name", "Geocentric conversion", operation.getName().getCode());
+ assertInstanceOf("operation", Conversion.class, operation);
+ }
+
+ /**
* Tests conversion from a geographic to a projected CRS without datum of axis changes.
*
* @throws ParseException if a CRS used in this test can not be parsed.