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 2021/11/25 14:57:22 UTC
[sis] 02/05: Allow `GridDerivation.subgrid(GridGeometry)` to work when the query contains only a "grid to CRS" transform, without envelope or grid extent.
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 9a928b798090ac2944fcd2edf27694adc3a5cb6b
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Nov 25 11:54:50 2021 +0100
Allow `GridDerivation.subgrid(GridGeometry)` to work when the query contains only a "grid to CRS" transform, without envelope or grid extent.
---
.../apache/sis/coverage/grid/GridDerivation.java | 3 +++
.../sis/coverage/grid/GridDerivationTest.java | 24 +++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridDerivation.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridDerivation.java
index bb33976..9041ca6 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridDerivation.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridDerivation.java
@@ -500,6 +500,9 @@ public class GridDerivation {
if (base.equals(areaOfInterest)) {
return this;
}
+ if (areaOfInterest.extent == null && areaOfInterest.resolution != null) {
+ return subgrid(areaOfInterest.envelope, areaOfInterest.resolution);
+ }
final MathTransform mapCenters;
final GridExtent domain = areaOfInterest.getExtent(); // May throw IncompleteGridGeometryException.
try {
diff --git a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridDerivationTest.java b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridDerivationTest.java
index baa2c34..a4ab028 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridDerivationTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridDerivationTest.java
@@ -55,7 +55,7 @@ import static org.apache.sis.coverage.grid.GridGeometryTest.assertExtentEquals;
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
* @author Johann Sorel (Geomatys)
- * @version 1.1
+ * @version 1.2
* @since 1.0
* @module
*/
@@ -305,7 +305,8 @@ public final strictfp class GridDerivationTest extends TestCase {
}
/**
- * Tests {@link GridDerivation#subgrid(GridExtent)} with an integer amount of tiles, operating only on extents.
+ * Tests {@link GridDerivation#subgrid(GridExtent, int...)}
+ * with an integer amount of tiles, operating only on extents.
*/
@Test
public void testSubgridWithTilingOnExtent() {
@@ -404,7 +405,24 @@ public final strictfp class GridDerivationTest extends TestCase {
}
/**
- * Tests {@link GridDerivation#subgrid(GridExtent)} with a null "grid to CRS" transform.
+ * Tests {@link GridDerivation#subgrid(GridGeometry)} with only a "grid to CRS" transform.
+ */
+ @Test
+ public void testSubgridWithTransformOnly() {
+ GridGeometry base = grid(2000, -1000, 9000, 8000, 2, -1);
+ GridGeometry query = new GridGeometry(null, PixelInCell.CELL_CENTER, MathTransforms.scale(10, 40), null);
+ GridDerivation change = base.derive().subgrid(query);
+ GridGeometry result = change.build();
+ Matrix toCRS = MathTransforms.getMatrix(result.getGridToCRS(PixelInCell.CELL_CENTER));
+ assertArrayEquals(new double[] {10, 40}, result.getResolution(false), STRICT);
+ assertMatrixEquals("gridToCRS", new Matrix3(
+ 10, 0, 205,
+ 0, -40, 480, // Note the negative sign, preserved from base grid geometry.
+ 0, 0, 1), toCRS, STRICT);
+ }
+
+ /**
+ * Tests {@link GridDerivation#subgrid(GridExtent, int...)} with a null "grid to CRS" transform.
*/
@Test
public void testSubgridWithoutTransform() {