From commits-return-13905-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Tue Sep 15 12:51:55 2020
Return-Path:
X-Original-To: apmail-sis-commits-archive@www.apache.org
Delivered-To: apmail-sis-commits-archive@www.apache.org
Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153])
by minotaur.apache.org (Postfix) with ESMTP id 6AB611AE5C
for ; Tue, 15 Sep 2020 12:51:55 +0000 (UTC)
Received: from mail.apache.org (localhost [127.0.0.1])
by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 1D889122843
for ; Tue, 15 Sep 2020 12:51:55 +0000 (UTC)
Received: (qmail 43048 invoked by uid 500); 15 Sep 2020 12:51:55 -0000
Delivered-To: apmail-sis-commits-archive@sis.apache.org
Received: (qmail 42971 invoked by uid 500); 15 Sep 2020 12:51:54 -0000
Mailing-List: contact commits-help@sis.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: sis-dev@sis.apache.org
Delivered-To: mailing list commits@sis.apache.org
Received: (qmail 42954 invoked by uid 99); 15 Sep 2020 12:51:54 -0000
Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70)
by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Sep 2020 12:51:54 +0000
Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33)
id B49808087B; Tue, 15 Sep 2020 12:51:54 +0000 (UTC)
Date: Tue, 15 Sep 2020 12:51:55 +0000
To: "commits@sis.apache.org"
Subject: [sis] 02/03: Remove the use of `MathTransformFactory` in
WraparoundTransform (except in `tryConcatenate`). All classes using
WraparoundTransform had no particular factory to specify. Remove
corresponding `throws FactoryException` statements.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
From: desruisseaux@apache.org
In-Reply-To: <160017431395.6685.12997582227433907033@gitbox.apache.org>
References: <160017431395.6685.12997582227433907033@gitbox.apache.org>
X-Git-Host: gitbox.apache.org
X-Git-Repo: sis
X-Git-Refname: refs/heads/geoapi-4.0
X-Git-Reftype: branch
X-Git-Rev: 256767701e9a6adb3fa06c0e78455e064a4cee4c
X-Git-NotificationType: diff
X-Git-Multimail-Version: 1.5.dev
Auto-Submitted: auto-generated
Message-Id: <20200915125154.B49808087B@gitbox.apache.org>
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
commit 256767701e9a6adb3fa06c0e78455e064a4cee4c
Author: Martin Desruisseaux
AuthorDate: Mon Sep 14 16:39:40 2020 +0200
Remove the use of `MathTransformFactory` in WraparoundTransform (except in `tryConcatenate`).
All classes using WraparoundTransform had no particular factory to specify.
Remove corresponding `throws FactoryException` statements.
---
.../coverage/grid/CoordinateOperationFinder.java | 38 +++++--------
.../internal/referencing/WraparoundTransform.java | 62 ++++++++++------------
.../referencing/WraparoundTransformTest.java | 12 ++---
3 files changed, 43 insertions(+), 69 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/CoordinateOperationFinder.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/CoordinateOperationFinder.java
index e2b7b4a..fea754d 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/CoordinateOperationFinder.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/CoordinateOperationFinder.java
@@ -29,12 +29,12 @@ import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.TransformException;
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.internal.referencing.CoordinateOperations;
import org.apache.sis.internal.referencing.WraparoundTransform;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
import org.apache.sis.geometry.Envelopes;
import org.apache.sis.geometry.GeneralDirectPosition;
import org.apache.sis.image.ImageProcessor;
@@ -161,14 +161,6 @@ final class CoordinateOperationFinder implements Supplier {
private boolean isWraparoundApplied;
/**
- * The factory to use for {@link MathTransform} creations. For now this is fixed to SIS implementation.
- * But it may become a configurable reference in a future version if useful.
- *
- * @see org.apache.sis.coverage.grid.ImageRenderer#mtFactory
- */
- private final MathTransformFactory mtFactory;
-
- /**
* Creates a new finder.
*
* @param source the grid geometry which is the source of the coordinate operation to find.
@@ -177,7 +169,6 @@ final class CoordinateOperationFinder implements Supplier {
CoordinateOperationFinder(final GridGeometry source, final GridGeometry target) {
this.source = source;
this.target = target;
- mtFactory = CoordinateOperations.factoryMT().caching(false);
}
/**
@@ -213,7 +204,7 @@ final class CoordinateOperationFinder implements Supplier {
* The transform returned by this method applies wraparound checks systematically on every axes having
* wraparound range. This method does not verify whether those checks are needed (i.e. whether wraparound
* can possibly happen). This is okay because this transform is used only for transforming envelopes;
- * it is not used for transforming pixel coordinates.
+ * it is not used for transforming pixel coordinates.
*
* Implementation note
* After invocation of this method, the following fields are valid:
@@ -306,10 +297,10 @@ wraparound: if (mayRequireWraparound(cs)) {
if (median == null) break wraparound;
median = forwardOp.transform(median, null);
}
- forwardOp = WraparoundTransform.forDomainOfUse(mtFactory, forwardOp, cs, median);
+ forwardOp = WraparoundTransform.forDomainOfUse(forwardOp, cs, median);
}
}
- return mtFactory.createConcatenatedTransform(tr, forwardOp);
+ return MathTransforms.concatenate(tr, forwardOp);
}
/**
@@ -325,17 +316,16 @@ wraparound: if (mayRequireWraparound(cs)) {
* @param gridToCRS result of previous call to {@link #gridToCRS(PixelInCell)}, or {@code null}
* for reusing the {@link #isWraparoundNeeded} result of previous invocation.
* @return operation from target geospatial coordinates to source grid indices.
- * @throws FactoryException if some transform steps can not be concatenated.
* @throws TransformException if some coordinates can not be transformed.
*/
- final MathTransform inverse(final MathTransform gridToCRS) throws FactoryException, TransformException {
+ final MathTransform inverse(final MathTransform gridToCRS) throws TransformException {
final MathTransform tr = source.getGridToCRS(anchor).inverse();
if (operation == null) {
return tr;
}
if (inverseOp != null) {
// Here, `inverseOp` contains the wraparound step if needed.
- return mtFactory.createConcatenatedTransform(inverseOp, tr);
+ return MathTransforms.concatenate(inverseOp, tr);
}
/*
* Need to compute transform with wraparound checks, but contrarily to `gridToCRS(…)` we do not want
@@ -345,11 +335,11 @@ wraparound: if (mayRequireWraparound(cs)) {
* appears to be necessary or not.
*/
final MathTransform inverseNoWrap = operation.getMathTransform().inverse();
- final MathTransform crsToGridNoWrap = mtFactory.createConcatenatedTransform(inverseNoWrap, tr);
+ final MathTransform crsToGridNoWrap = MathTransforms.concatenate(inverseNoWrap, tr);
inverseOp = inverseNoWrap;
crsToGrid = crsToGridNoWrap;
isWraparoundApplied = false;
-check: if (gridToCRS != null) try {
+check: if (gridToCRS != null) {
/*
* We will do a more extensive check by converting all corners of source grid to the target CRS,
* then convert back to the source grid and see if coordinates match. Only if coordinates do not
@@ -360,7 +350,7 @@ check: if (gridToCRS != null) try {
final Supplier withWraparound = () -> {
try {
return applyWraparound(tr);
- } catch (FactoryException | TransformException e) {
+ } catch (TransformException e) {
throw new BackingStoreException(e);
}
};
@@ -376,9 +366,6 @@ check: if (gridToCRS != null) try {
}
return cc;
});
- } catch (BackingStoreException e) {
- throw e.unwrapOrRethrow(FactoryException.class);
- // TransformException is handled in `WraparoundTransform.isNeeded(…)` instead of here.
}
/*
* At this point we determined whether wraparound is needed. The `inverseOp` and `crsToGrid` fields
@@ -401,18 +388,17 @@ check: if (gridToCRS != null) try {
*
* @param tr value of {@code source.getGridToCRS(anchor).inverse()}.
* @return transform from geospatial target coordinates to source grid indices.
- * @throws FactoryException if some transform steps can not be concatenated.
* @throws TransformException if some coordinates can not be transformed.
*/
- private MathTransform applyWraparound(final MathTransform tr) throws FactoryException, TransformException {
+ private MathTransform applyWraparound(final MathTransform tr) throws TransformException {
if (!isWraparoundApplied) {
isWraparoundApplied = true;
final CoordinateSystem cs = operation.getSourceCRS().getCoordinateSystem();
if (mayRequireWraparound(cs)) {
final DirectPosition median = median(source);
if (median != null) {
- inverseOp = WraparoundTransform.forDomainOfUse(mtFactory, inverseOp, cs, median);
- crsToGrid = mtFactory.createConcatenatedTransform(inverseOp, tr);
+ inverseOp = WraparoundTransform.forDomainOfUse(inverseOp, cs, median);
+ crsToGrid = MathTransforms.concatenate(inverseOp, tr);
}
}
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
index 9917d92..95b6e6d 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WraparoundTransform.java
@@ -30,7 +30,6 @@ import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.referencing.operation.transform.AbstractMathTransform;
@@ -143,18 +142,14 @@ public final class WraparoundTransform extends AbstractMathTransform {
* on an inspection of source and target CRS axes. For a method making decision based on a domain of use,
* see {@link #forDomainOfUse forDomainOfUse(…)} instead.
*
- * @param factory the factory to use for creating math transforms.
* @param op the coordinate operation for which to get the math transform.
* @return the math transform for the given coordinate operation.
- * @throws FactoryException if an error occurred while creating the math transform.
*/
- public static MathTransform forTargetCRS(final MathTransformFactory factory, final CoordinateOperation op)
- throws FactoryException
- {
+ public static MathTransform forTargetCRS(final CoordinateOperation op) {
MathTransform tr = op.getMathTransform();
final CoordinateSystem targetCS = op.getTargetCRS().getCoordinateSystem();
for (final int wraparoundDimension : CoordinateOperations.wrapAroundChanges(op)) {
- tr = factory.createConcatenatedTransform(tr, create(factory, targetCS.getDimension(),
+ tr = MathTransforms.concatenate(tr, create(targetCS.getDimension(),
wraparoundDimension, targetCS.getAxis(wraparoundDimension), Double.NaN));
}
return tr;
@@ -171,22 +166,18 @@ public final class WraparoundTransform extends AbstractMathTransform {
* (e.g. when transforming a raster) and we want that output coordinates to be continuous
* in that domain, independently of axis ranges.
*
- * @param factory the factory to use for creating math transforms.
* @param tr the transform to augment with "wrap around" behavior.
* @param targetCS the target coordinate system.
* @param median the coordinates to put at the center of new ranges.
* @return the math transform with wraparound if needed.
- * @throws FactoryException if an error occurred while creating the math transform.
*/
- public static MathTransform forDomainOfUse(final MathTransformFactory factory, MathTransform tr,
- final CoordinateSystem targetCS, final DirectPosition median) throws FactoryException
- {
+ public static MathTransform forDomainOfUse(MathTransform tr, final CoordinateSystem targetCS, final DirectPosition median) {
final int dimension = targetCS.getDimension();
for (int i=0; i steps = MathTransforms.getSteps(wt);
assertEquals(3, steps.size());
assertEquals(1, ((WraparoundTransform) steps.get(1)).wraparoundDimension);
@@ -111,11 +108,10 @@ public final strictfp class WraparoundTransformTest extends TestCase {
* transform between them. The absence of separation between the two {@link WraparoundTransform}s is an
* indirect test of {@link WraparoundTransform#tryConcatenate(boolean, MathTransform, MathTransformFactory)}.
*
- * @throws FactoryException if the transform can not be created.
* @throws NoninvertibleMatrixException if the expected matrix can not be inverted.
*/
@Test
- public void testTwoAxes() throws FactoryException, NoninvertibleMatrixException {
+ public void testTwoAxes() throws NoninvertibleMatrixException {
final AbstractCoordinateOperation op = new AbstractCoordinateOperation(
Collections.singletonMap(AbstractCoordinateOperation.NAME_KEY, "Wrapper"),
HardCodedCRS.WGS84_3D_TIME.forConvention(AxesConvention.POSITIVE_RANGE),
@@ -126,7 +122,7 @@ public final strictfp class WraparoundTransformTest extends TestCase {
* should have been moved by `WraparoundTransform.tryConcatenate(…)` in order to combine them with initial
* [normalization} and final {denormalization].
*/
- final MathTransform wt = WraparoundTransform.forTargetCRS(DefaultFactories.forClass(MathTransformFactory.class), op);
+ final MathTransform wt = WraparoundTransform.forTargetCRS(op);
final List steps = MathTransforms.getSteps(wt);
assertEquals(4, steps.size());
assertEquals(0, ((WraparoundTransform) steps.get(1)).wraparoundDimension);