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 f668f82  Documentation fixes and renaming of 
`WraparoundTransform.create(…)` for clarity.
f668f82 is described below

commit f668f82f4af5ca74da1aaa03403c57ddcba2fb86
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Sep 3 19:30:04 2020 +0200

    Documentation fixes and renaming of `WraparoundTransform.create(…)` for 
clarity.
---
 .../java/org/apache/sis/coverage/grid/ImageRenderer.java   | 14 ++++++++++++--
 .../src/main/java/org/apache/sis/image/ResampledImage.java |  5 +++++
 .../sis/internal/referencing/WraparoundTransform.java      |  7 +++----
 .../sis/internal/referencing/WraparoundTransformTest.java  |  4 ++--
 .../java/org/apache/sis/internal/netcdf/CRSBuilder.java    |  2 +-
 5 files changed, 23 insertions(+), 9 deletions(-)

diff --git 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ImageRenderer.java
 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ImageRenderer.java
index 749dcce..403553d 100644
--- 
a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ImageRenderer.java
+++ 
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ImageRenderer.java
@@ -32,6 +32,7 @@ import java.awt.image.RasterFormatException;
 import java.awt.image.Raster;
 import org.opengis.util.FactoryException;
 import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.MathTransformFactory;
 import org.apache.sis.image.DataType;
 import org.apache.sis.coverage.SubspaceNotSpecifiedException;
 import org.apache.sis.coverage.MismatchedCoverageRangeException;
@@ -252,6 +253,15 @@ public class ImageRenderer {
     private Hashtable<String,Object> properties;
 
     /**
+     * The factory to use for {@link 
org.opengis.referencing.operation.MathTransform} creations,
+     * or {@code null} for a default factory.
+     *
+     * <p>For now this is fixed to {@code null}. But it may become a 
non-static, non-final field
+     * in a future version if we want to make this property configurable.</p>
+     */
+    private static final MathTransformFactory mtFactory = null;
+
+    /**
      * Creates a new image renderer for the given slice extent.
      *
      * @param  coverage     the source coverage for which to build an image.
@@ -382,7 +392,7 @@ public class ImageRenderer {
             if (isSameGeometry(dimCRS)) {
                 ig = geometry;
             } else try {
-                ig = new SliceGeometry(geometry, sliceExtent, gridDimensions, 
null)
+                ig = new SliceGeometry(geometry, sliceExtent, gridDimensions, 
mtFactory)
                         .reduce(new GridExtent(imageX, imageY, width, height), 
dimCRS);
             } catch (FactoryException e) {
                 throw SliceGeometry.canNotCompute(e);
@@ -670,7 +680,7 @@ public class ImageRenderer {
             if (isSameGeometry(GridCoverage2D.BIDIMENSIONAL)) {
                 imageGeometry = geometry;
             } else {
-                supplier = new SliceGeometry(geometry, sliceExtent, 
gridDimensions, null);
+                supplier = new SliceGeometry(geometry, sliceExtent, 
gridDimensions, mtFactory);
             }
         }
         final WritableRaster wr = (raster instanceof WritableRaster) ? 
(WritableRaster) raster : null;
diff --git 
a/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java 
b/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
index f053baa..c0f9cb4 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
@@ -126,6 +126,11 @@ public class ResampledImage extends ComputedImage {
      * That transform may be non-invertible. Consequently this transform 
should not be used for inverse operations
      * and should not be made accessible to the user.</p>
      *
+     * <p>This transform maps pixel centers of both images, except in the case 
of nearest-neighbor interpolation.
+     * In that special case only, the transform maps target pixel 
<em>center</em> to source pixel <em>corner</em>.
+     * We have to map corners in source images because source pixel 
coordinates are computed by taking the integer
+     * parts of {@code toSourceSupport} results, without rounding.</p>
+     *
      * @see #interpolationSupportOffset(int)
      */
     private final MathTransform toSourceSupport;
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 7366cf6..f92bda5 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
@@ -49,7 +49,7 @@ import org.apache.sis.util.logging.Logging;
  * <p>{@code WraparoundTransform}s are not created automatically by {@link 
org.apache.sis.referencing.CRS#findOperation
  * CRS.findOperation(…)} because they introduce a discontinuity in coordinate 
transformations. Such discontinuities are
  * hurtless when transforming only a cloud of points, but produce undesirable 
artifacts when transforming geometries.
- * Callers need to invoke {@link #create create} explicitly if discontinuities 
are acceptable.</p>
+ * Callers need to invoke {@link #forTargetCRS forTargetCRS(…)} explicitly if 
discontinuities are acceptable.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
@@ -97,15 +97,14 @@ public final class WraparoundTransform extends 
AbstractMathTransform {
      * @return the math transform for the given coordinate operation.
      * @throws FactoryException if an error occurred while creating the math 
transform.
      */
-    public static MathTransform create(final MathTransformFactory factory, 
final CoordinateOperation op)
+    public static MathTransform forTargetCRS(final MathTransformFactory 
factory, final CoordinateOperation op)
             throws FactoryException
     {
         MathTransform tr = op.getMathTransform();
         final CoordinateSystem cs = op.getTargetCRS().getCoordinateSystem();
-        final int dimension = cs.getDimension();
         for (final int wraparoundDimension : 
CoordinateOperations.wrapAroundChanges(op)) {
             final CoordinateSystemAxis axis = cs.getAxis(wraparoundDimension);
-            final MathTransform wraparound  = create(factory, dimension, 
wraparoundDimension,
+            final MathTransform wraparound  = create(factory, 
cs.getDimension(), wraparoundDimension,
                                                      axis.getMinimumValue(), 
axis.getMaximumValue());
             tr = factory.createConcatenatedTransform(tr, wraparound);
         }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
index 492d2a5..f66d662 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WraparoundTransformTest.java
@@ -62,7 +62,7 @@ public final strictfp class WraparoundTransformTest extends 
TestCase {
          * Wrararound is often (but not always) unnecessary on source 
coordinates if the operation
          * uses trigonometric functions.
          */
-        final MathTransform wt = 
WraparoundTransform.create(DefaultFactories.forClass(MathTransformFactory.class),
 op);
+        final MathTransform wt = 
WraparoundTransform.forTargetCRS(DefaultFactories.forClass(MathTransformFactory.class),
 op);
         final List<MathTransform> steps = MathTransforms.getSteps(wt);
         assertEquals(3, steps.size());
         assertEquals(1, ((WraparoundTransform) 
steps.get(1)).wraparoundDimension);
@@ -106,7 +106,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.create(DefaultFactories.forClass(MathTransformFactory.class),
 op);
+        final MathTransform wt = 
WraparoundTransform.forTargetCRS(DefaultFactories.forClass(MathTransformFactory.class),
 op);
         final List<MathTransform> steps = MathTransforms.getSteps(wt);
         assertEquals(4, steps.size());
         assertEquals(0, ((WraparoundTransform) 
steps.get(1)).wraparoundDimension);
diff --git 
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/CRSBuilder.java
 
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/CRSBuilder.java
index bd05ee9..255bad3 100644
--- 
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/CRSBuilder.java
+++ 
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/CRSBuilder.java
@@ -647,7 +647,7 @@ previous:   for (int i=components.size(); --i >= 0;) {
         private CommonCRS sphericalDatum;
 
         /**
-         * Defining conversion for "Not specified (presumed Plate Carrée)". 
This conversion use spherical formulas.
+         * Defining conversion for "Not specified (presumed Plate Carrée)". 
This conversion uses spherical formulas.
          * Consequently it should be used with {@link #sphericalDatum} instead 
of {@link #defaultCRS}.
          */
         private static final Conversion UNKNOWN_PROJECTION;

Reply via email to