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 2022/09/12 15:47:59 UTC
[sis] 01/03: Fix an erroneous calculation of resolution on call to `GridGeometry.upsample(…)`.
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 db2229823d3a15229bce912a169d7d2c2a978bee
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Mon Sep 12 12:10:21 2022 +0200
Fix an erroneous calculation of resolution on call to `GridGeometry.upsample(…)`.
---
.../main/java/org/apache/sis/coverage/grid/GridGeometry.java | 11 ++++++-----
.../java/org/apache/sis/coverage/grid/GridGeometryTest.java | 5 +++--
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
index 1c0d5e8f5c..936b9b0888 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java
@@ -1422,11 +1422,12 @@ public class GridGeometry implements LenientComparable, Serializable {
newResolution = resolution.clone();
final DoubleDouble div = new DoubleDouble();
for (int i = Math.min(srcDim, periods.length); --i >= 0;) {
- for (int j=0; j<tgtDim; j++) {
- div.error = 0;
- div.value = periods[i];
- if (div.value != 1) {
- newResolution[i] /= div.value;
+ final double p = periods[i];
+ if (p != 1) {
+ newResolution[i] /= p;
+ for (int j=0; j<tgtDim; j++) {
+ div.error = 0;
+ div.value = p;
div.inverseDivide(DoubleDouble.castOrCopy(matrix.getNumber(j, i)));
matrix.setNumber(j, i, div);
changed = true;
diff --git a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
index 4654589a6b..fc47a135b5 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
@@ -494,8 +494,9 @@ public final strictfp class GridGeometryTest extends TestCase {
final MathTransform gridToCRS = MathTransforms.linear(mat);
expected = new GridGeometry(extent, PixelInCell.CELL_CENTER, gridToCRS, HardCodedCRS.CARTESIAN_2D);
}
- assertSame(grid.getEnvelope(), upsampled.getEnvelope());
- assertEquals(expected, upsampled);
+ assertSame("envelope", grid.getEnvelope(), upsampled.getEnvelope());
+ assertEquals("GridGeometry", expected, upsampled);
+ assertArrayEquals("resolution", new double[] {0.25, 0.5}, expected.getResolution(false), STRICT);
}
/**