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 ddc02b267de5851a7e73368da8c589ec4d570d55
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Wed Dec 8 10:57:25 2021 +0100

    Reverse the order of elements in `GridCoverageResource.getResolutions()`:
    from finest (smallest numbers) to coarsest (larger numbers).
---
 .../sis/internal/map/coverage/MultiResolutionCoverageLoader.java  | 8 +++-----
 .../internal/map/coverage/MultiResolutionCoverageLoaderTest.java  | 6 +++---
 .../java/org/apache/sis/storage/geotiff/MultiResolutionImage.java | 3 +--
 .../java/org/apache/sis/internal/storage/GridResourceWrapper.java | 1 +
 .../main/java/org/apache/sis/storage/GridCoverageResource.java    | 2 +-
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git 
a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java
 
b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java
index 93e0238..53610b5 100644
--- 
a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java
+++ 
b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java
@@ -38,7 +38,6 @@ import org.apache.sis.coverage.grid.GridRoundingMode;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.io.TableAppender;
-import org.apache.sis.util.ArraysExt;
 
 
 /**
@@ -88,8 +87,8 @@ public class MultiResolutionCoverageLoader {
 
     /**
      * Squares of resolution at each pyramid level, from finest (smaller 
numbers) to coarsest (largest numbers).
-     * Note that this is the reverse order of {@link 
GridCoverageResource#getResolutions()}. For a given level,
-     * the array {@code resolutionSquared[level]} gives the squares of the 
resolution for each CRS dimension.
+     * This is same same order than {@link 
GridCoverageResource#getResolutions()}. For a given level, the array
+     * {@code resolutionSquared[level]} gives the squares of the resolution 
for each CRS dimension.
      */
     private final double[][] resolutionSquared;
 
@@ -128,7 +127,6 @@ public class MultiResolutionCoverageLoader {
         areaOfInterest = domain;
         readRanges     = range;
         double[][] resolutions = 
CollectionsExt.toArray(resource.getResolutions(), double[].class);
-        ArraysExt.reverse(resolutions);                     // From finest to 
coarsest resolution.
         if (resolutions.length <= 1) {
             final GridGeometry gg = resource.getGridGeometry();
             if (resolutions.length != 0) {
@@ -248,7 +246,7 @@ dimensions: for (int j=0; j<tgtDim; j++) {
                 }
                 /*
                  * Can not use `Arrays.binarySearch(…)` because elements are 
not guaranteed to be sorted.
-                 * Even if `GridCoverageResource.getResolutions()` contract 
said "coarsest to finest",
+                 * Even if `GridCoverageResource.getResolutions()` contract 
said "finest to coarsest",
                  * it may not be possible to respect this condition on all 
dimensions in same time.
                  * The main goal is to have a `level` value as high as 
possible while having a resolution
                  * equals or better than `sum`.
diff --git 
a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoaderTest.java
 
b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoaderTest.java
index 1be2007..77bb343 100644
--- 
a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoaderTest.java
+++ 
b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoaderTest.java
@@ -100,7 +100,7 @@ public final strictfp class 
MultiResolutionCoverageLoaderTest extends TestCase {
 
     /**
      * A dummy resource with arbitrary resolutions for testing purpose.
-     * Resolutions are ordered from coarsest (largest numbers) to finest 
(smallest numbers).
+     * Resolutions are ordered from finest (smallest numbers) to coarsest 
(largest numbers).
      */
     private static final class DummyResource extends AbstractGridResource {
         /** Creates a dummy resource. */
@@ -111,9 +111,9 @@ public final strictfp class 
MultiResolutionCoverageLoaderTest extends TestCase {
         /** Returns the preferred resolutions in units of CRS axes. */
         @Override public List<double[]> getResolutions() {
             return Arrays.asList(
-                    new double[] {8, 9, 5},
+                    new double[] {2, 3, 1},
                     new double[] {4, 4, 3},
-                    new double[] {2, 3, 1});
+                    new double[] {8, 9, 5});
         }
 
         /** Returns a grid geometry with the resolution of finest level. */
diff --git 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
index 5c1b205..84e550e 100644
--- 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
+++ 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
@@ -21,7 +21,6 @@ import java.util.Arrays;
 import java.io.IOException;
 import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.util.ArraysExt;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridCoverage;
@@ -142,6 +141,7 @@ final class MultiResolutionImage extends 
GridResourceWrapper {
 
     /**
      * Returns the preferred resolutions (in units of CRS axes) for read 
operations in this data store.
+     * Elements are ordered from finest (smallest numbers) to coarsest 
(largest numbers) resolution.
      */
     @Override
     public List<double[]> getResolutions() throws DataStoreException {
@@ -151,7 +151,6 @@ final class MultiResolutionImage extends 
GridResourceWrapper {
                 copy[i] = resolution(i).clone();
             }
         }
-        ArraysExt.reverse(copy);
         return Arrays.asList(copy);
     }
 
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/GridResourceWrapper.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/GridResourceWrapper.java
index 3794c4f..e922a12 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/GridResourceWrapper.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/GridResourceWrapper.java
@@ -150,6 +150,7 @@ public abstract class GridResourceWrapper implements 
GridCoverageResource {
 
     /**
      * Returns the preferred resolutions (in units of CRS axes) for read 
operations in this data store.
+     * Elements are ordered from finest (smallest numbers) to coarsest 
(largest numbers) resolution.
      *
      * @return preferred resolutions for read operations in this data store, 
or an empty array if none.
      * @throws DataStoreException if an error occurred while reading 
definitions from the underlying data store.
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
index e2eceb5..9b96bb9 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
@@ -111,7 +111,7 @@ public interface GridCoverageResource extends DataSet {
     /**
      * Returns the preferred resolutions (in units of CRS axes) for read 
operations in this data store.
      * If the storage supports pyramid, then the list should contain the 
resolution at each pyramid level
-     * ordered from coarsest (largest numbers) to finest (smallest numbers) 
resolution.
+     * ordered from finest (smallest numbers) to coarsest (largest numbers) 
resolution.
      * Otherwise the list contains a single element which is the {@linkplain 
#getGridGeometry() grid geometry}
      * resolution, or an empty list if no resolution is applicable to the 
coverage (e.g. because non-constant).
      *

Reply via email to