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 75d1967fa4 Fix the last JUnit test failure when using EPSG version 12.
This fix is not satisfying, as it cannot be applied between two datum ensemble.
A generalization of this fix would need a refactoring of the way that
Bursa-Wolf parameters are searched.
75d1967fa4 is described below
commit 75d1967fa48133546e9e2306c12dd4f68e2f291d
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Fri Sep 5 00:42:14 2025 +0200
Fix the last JUnit test failure when using EPSG version 12.
This fix is not satisfying, as it cannot be applied between two datum
ensemble.
A generalization of this fix would need a refactoring of the way that
Bursa-Wolf parameters are searched.
---
.../apache/sis/console/MetadataCommandTest.java | 4 ++--
.../referencing/datum/DefaultGeodeticDatum.java | 2 ++
.../operation/CoordinateOperationFinder.java | 22 +++++++++++++++-------
.../CoordinateSystemTransformBuilder.java | 3 ++-
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
index 6debe66ea7..0f6e18b34b 100644
---
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
+++
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
@@ -52,7 +52,8 @@ public final class MetadataCommandTest extends
TestCaseWithLogs {
var test = new MetadataCommand(0, new String[] {CommandRunner.TEST,
url.toString()});
test.run();
verifyNetCDF("Metadata", test.outputBuffer.toString());
- loggings.skipNextLogIfContains("EPSG:4019"); // Warning
about deprecated EPSG code.
+ loggings.skipNextLogIfContains("EPSG:6019"); // Warning about
deprecated EPSG code for datum.
+ loggings.skipNextLogIfContains("EPSG:4019"); // Warning about
deprecated EPSG code for CRS.
loggings.assertNoUnexpectedLog();
}
@@ -80,7 +81,6 @@ public final class MetadataCommandTest extends
TestCaseWithLogs {
verifyNetCDF("<?xml", test.outputBuffer.toString());
loggings.skipNextLogIfContains("EPSG:6019"); // Warning about
deprecated EPSG code for datum.
loggings.skipNextLogIfContains("EPSG:4019"); // Warning about
deprecated EPSG code for CRS.
- loggings.skipNextLogIfContains("EPSG:6019"); // In case logs are
not in above order.
loggings.assertNoUnexpectedLog();
}
}
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
index d388cce354..35f0d7501a 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
@@ -45,6 +45,7 @@ import org.apache.sis.referencing.internal.AnnotatedMatrix;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.privy.CollectionsExt;
+import org.apache.sis.util.OptionalCandidate;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.io.wkt.Formatter;
import static org.apache.sis.util.Utilities.deepEquals;
@@ -423,6 +424,7 @@ public class DefaultGeodeticDatum extends AbstractDatum
implements GeodeticDatum
*
* @see BursaWolfParameters#getPositionVectorTransformation(Temporal)
*/
+ @OptionalCandidate
public Matrix getPositionVectorTransformation(final GeodeticDatum
targetDatum, final Extent areaOfInterest) {
ensureNonNull("targetDatum", targetDatum);
final var selector = new
ExtentSelector<BursaWolfParameters>(areaOfInterest);
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
index 44aa117e10..77bf446a4b 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
@@ -57,6 +57,7 @@ import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
import org.apache.sis.referencing.datum.DatumOrEnsemble;
import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import
org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
import org.apache.sis.referencing.operation.provider.DatumShiftMethod;
import org.apache.sis.referencing.operation.provider.GeocentricAffine;
import org.apache.sis.util.Utilities;
@@ -524,12 +525,8 @@ public class CoordinateOperationFinder extends
CoordinateOperationRegistry {
* May contain the addition of ellipsoidal height or spherical
radius, which need an ellipsoid.
*/
final var builder =
factorySIS.getMathTransformFactory().builder(Constants.COORDINATE_SYSTEM_CONVERSION);
- Ellipsoid ellipsoid = targetDatum.getEllipsoid();
- if (ellipsoid == null) {
- ellipsoid = sourceDatum.getEllipsoid();
- }
- builder.setSourceAxes(sourceCS, ellipsoid);
- builder.setTargetAxes(targetCS, ellipsoid);
+ builder.setSourceAxes(sourceCS, sourceDatum.getEllipsoid());
+ builder.setTargetAxes(targetCS, targetDatum.getEllipsoid());
transform = builder.create();
method = builder.getMethod();
parameters = builder.parameters();
@@ -558,8 +555,19 @@ public class CoordinateOperationFinder extends
CoordinateOperationRegistry {
final var impl = (DefaultGeodeticDatum) sourceDatum;
datumShift = impl.getPositionVectorTransformation(targetDatum,
areaOfInterest);
if (datumShift != null) typeOfChange = DATUM_SHIFT;
+ } else if (targetDatum instanceof DefaultGeodeticDatum) {
+ final var impl = (DefaultGeodeticDatum) targetDatum;
+ Matrix matrix =
impl.getPositionVectorTransformation(sourceDatum, areaOfInterest);
+ if (matrix != null) try {
+ matrix = Matrices.inverse(matrix);
+ typeOfChange = DATUM_SHIFT;
+ } catch (NoninvertibleMatrixException e) {
+ recoverableException("createOperationStep", e);
+ matrix = null;
+ }
+ datumShift = matrix;
} else {
- datumShift = null;
+ datumShift = null;
}
var builder = new
MathTransformContext(factorySIS.getMathTransformFactory(), sourceDatum,
targetDatum);
builder.setSourceAxes(sourceCS, sourceDatum.getEllipsoid());
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
index 82a6d02100..b102444f2f 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/CoordinateSystemTransformBuilder.java
@@ -43,6 +43,7 @@ import
org.apache.sis.referencing.operation.provider.Geographic3Dto2D;
import org.apache.sis.referencing.operation.provider.GeocentricToGeographic;
import org.apache.sis.referencing.operation.provider.GeographicToGeocentric;
import org.apache.sis.referencing.privy.WKTUtilities;
+import org.apache.sis.util.Utilities;
import org.apache.sis.util.resources.Errors;
@@ -149,7 +150,7 @@ final class CoordinateSystemTransformBuilder extends
MathTransformBuilder {
*/
private void setEllipsoid(final Ellipsoid value) {
if (value != null) {
- if (ellipsoid != null && ellipsoid != value) {
+ if (ellipsoid != null &&
!Utilities.equalsIgnoreMetadata(ellipsoid, value)) {
throw new
IllegalStateException(Errors.format(Errors.Keys.AlreadyInitialized_1,
"ellipsoid"));
}
ellipsoid = value;