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 975a19153ba0e9d30096cec9b995f46d7125b62b Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Sep 22 17:04:16 2021 +0200 Rename `insert(…)` as `insertDimension` and `reduce(…)` as `reduceDimension`. --- .../org/apache/sis/coverage/grid/GridExtent.java | 34 +++++++++++++++++----- .../org/apache/sis/coverage/grid/GridGeometry.java | 2 +- .../apache/sis/coverage/grid/SliceGeometry.java | 2 +- .../apache/sis/coverage/grid/GridExtentTest.java | 16 +++++----- .../sis/internal/storage/AbstractGridResource.java | 2 +- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java index 2e967b1..7368d8e 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java +++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java @@ -314,7 +314,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @see #getLow() * @see #getHigh() - * @see #insert(int, DimensionNameType, long, long, boolean) + * @see #insertDimension(int, DimensionNameType, long, long, boolean) */ public GridExtent(final DimensionNameType[] axisTypes, final long[] low, final long[] high, final boolean isHighIncluded) { ArgumentChecks.ensureNonNull("high", high); @@ -625,7 +625,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @return the number of dimensions. * - * @see #reduce(int...) + * @see #reduceDimension(int[]) */ @Override public final int getDimension() { @@ -1049,6 +1049,14 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable } /** + * @deprecated Renamed {@link #insertDimension(int, DimensionNameType, long, long, boolean)}. + */ + @Deprecated + public GridExtent insert(final int offset, final DimensionNameType axisType, final long low, long high, final boolean isHighIncluded) { + return insertDimension(offset, axisType, low, high, isHighIncluded); + } + + /** * Returns a new grid envelope with the specified dimension inserted at the given index in this grid envelope. * To append a new dimension after all existing dimensions, set {@code offset} to {@link #getDimension()}. * @@ -1061,8 +1069,10 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * This argument does not apply to {@code low} value, which is always inclusive. * @return a new grid envelope with the specified dimension added. * @throws IllegalArgumentException if the low coordinate value is greater than the high coordinate value. + * + * @since 1.1 */ - public GridExtent insert(final int offset, final DimensionNameType axisType, final long low, long high, final boolean isHighIncluded) { + public GridExtent insertDimension(final int offset, final DimensionNameType axisType, final long low, long high, final boolean isHighIncluded) { final int dimension = getDimension(); ArgumentChecks.ensureBetween("offset", 0, dimension, offset); if (!isHighIncluded) { @@ -1231,13 +1241,21 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable } /** + * @deprecated Renamed {@link #reduceDimension(int...)}. + */ + @Deprecated + public GridExtent reduce(int... dimensions) { + return reduceDimension(dimensions); + } + + /** * Returns a grid extent that encompass only some dimensions of this grid extent. * This method copies the specified dimensions of this grid extent into a new grid extent. * The given dimensions must be in strictly ascending order without duplicated values. * The number of dimensions of the sub grid envelope will be {@code dimensions.length}. * * <p>This method performs a <cite>dimensionality reduction</cite> and can be used as the - * converse of {@link #insert(int, DimensionNameType, long, long, boolean)}. + * converse of {@link #insertDimension(int, DimensionNameType, long, long, boolean)}. * This method can not be used for changing dimension order.</p> * * @param dimensions the dimensions to select, in strictly increasing order. @@ -1246,8 +1264,10 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @see #getSubspaceDimensions(int) * @see GridGeometry#reduce(int...) + * + * @since 1.1 */ - public GridExtent reduce(int... dimensions) { + public GridExtent reduceDimension(int... dimensions) { dimensions = verifyDimensions(dimensions, getDimension()); return (dimensions != null) ? reorder(dimensions) : this; } @@ -1289,7 +1309,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * grid borders.</div> * * This method does not reduce the number of dimensions of the grid extent. - * For dimensionality reduction, see {@link #reduce(int...)}. + * For dimensionality reduction, see {@link #reduceDimension(int[])}. * * <h4>Number of arguments</h4> * The {@code periods} array length should be equal to the {@linkplain #getDimension() number of dimensions}. @@ -1352,7 +1372,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * in the given point will be rounded to nearest integer. * * <p>This method does not reduce the number of dimensions of the grid extent. - * For dimensionality reduction, see {@link #reduce(int...)}.</p> + * For dimensionality reduction, see {@link #reduceDimension(int[])}.</p> * * @param slicePoint where to take a slice. NaN values are handled as if their dimensions were absent. * @param modifiedDimensions mapping from {@code slicePoint} dimensions to this {@code GridExtent} dimensions, 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 2f1e160..d9e6d8c 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 @@ -1353,7 +1353,7 @@ public class GridGeometry implements LenientComparable, Serializable { * @throws IndexOutOfBoundsException if an index is out of bounds. * * @see GridExtent#getSubspaceDimensions(int) - * @see GridExtent#reduce(int...) + * @see GridExtent#reduceDimension(int[]) * @see org.apache.sis.referencing.CRS#reduce(CoordinateReferenceSystem, int...) */ public GridGeometry reduce(int... dimensions) { diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/SliceGeometry.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/SliceGeometry.java index 264dabe..0279bac 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/SliceGeometry.java +++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/SliceGeometry.java @@ -176,7 +176,7 @@ final class SliceGeometry implements Function<RenderedImage, GridGeometry> { extent = sliceExtent; } if (extent != null) { - extent = extent.reduce(gridDimensions); + extent = extent.reduceDimension(gridDimensions); } GeneralEnvelope subArea = null; if (useSubExtent && cornerToCRS != null) try { diff --git a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java index 46858d1..91123d1 100644 --- a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java +++ b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java @@ -133,7 +133,7 @@ public final strictfp class GridExtentTest extends TestCase { } /** - * Tests {@link GridExtent#insert(int, DimensionNameType, long, long, boolean)} + * Tests {@link GridExtent#insertDimension(int, DimensionNameType, long, long, boolean)} * with {@code offset} set to {@link GridExtent#getDimension()}. */ @Test @@ -142,10 +142,10 @@ public final strictfp class GridExtentTest extends TestCase { } /** - * Tests {@link GridExtent#insert(int, DimensionNameType, long, long, boolean)}. + * Tests {@link GridExtent#insertDimension(int, DimensionNameType, long, long, boolean)}. */ @Test - public void testInsert() { + public void testInsertDimension() { appendOrInsert(1, 2); } @@ -155,7 +155,7 @@ public final strictfp class GridExtentTest extends TestCase { private void appendOrInsert(final int offset, final int rowIndex) { GridExtent extent = new GridExtent(new DimensionNameType[] {DimensionNameType.COLUMN, DimensionNameType.ROW}, new long[] {100, 200}, new long[] {500, 800}, true); - extent = extent.insert(offset, DimensionNameType.TIME, 40, 50, false); + extent = extent.insertDimension(offset, DimensionNameType.TIME, 40, 50, false); assertEquals("dimension", 3, extent.getDimension()); assertExtentEquals(extent, 0, 100, 500); assertExtentEquals(extent, rowIndex, 200, 800); @@ -219,19 +219,19 @@ public final strictfp class GridExtentTest extends TestCase { } /** - * Tests {@link GridExtent#reduce(int...)}. + * Tests {@link GridExtent#reduceDimension(int[])}. */ @Test - public void testReduce() { + public void testReduceDimension() { final GridExtent extent = create3D(); - GridExtent reduced = extent.reduce(0, 1); + GridExtent reduced = extent.reduceDimension(0, 1); assertEquals("dimension", 2, reduced.getDimension()); assertExtentEquals(reduced, 0, 100, 499); assertExtentEquals(reduced, 1, 200, 799); assertEquals(DimensionNameType.COLUMN, reduced.getAxisType(0).get()); assertEquals(DimensionNameType.ROW, reduced.getAxisType(1).get()); - reduced = extent.reduce(2); + reduced = extent.reduceDimension(2); assertEquals("dimension", 1, reduced.getDimension()); assertExtentEquals(reduced, 0, 40, 49); assertEquals(DimensionNameType.TIME, reduced.getAxisType(0).get()); diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java index 0e60107..6ed632f 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractGridResource.java @@ -350,7 +350,7 @@ public abstract class AbstractGridResource extends AbstractResource implements G public GridExtent insertBandDimension(final GridExtent areaOfInterest, final int bandDimension) { first = getSourceIndex(0); last = getSourceIndex(packed.length - 1); - return areaOfInterest.insert(bandDimension, DimensionNameType.valueOf("BAND"), first, last, true); + return areaOfInterest.insertDimension(bandDimension, DimensionNameType.valueOf("BAND"), first, last, true); } /**