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 ab25edabfa Use `addExact` for computing tile position.
ab25edabfa is described below
commit ab25edabfa44b43dd8f5f7513aa595d5eb8dead1
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue Jul 30 15:15:28 2024 +0200
Use `addExact` for computing tile position.
---
.../main/org/apache/sis/storage/base/TiledGridCoverage.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
index 29736007ca..30ef8a4108 100644
---
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
+++
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/TiledGridCoverage.java
@@ -224,8 +224,9 @@ public abstract class TiledGridCoverage extends
GridCoverage {
tmcOfFirstTile = new long[dimension];
tileStrides = new int [dimension];
final int[] subSize = new int [dimension];
- int tileStride = 1;
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
long indexOfFirstTile = 0;
+ int tileStride = 1;
for (int i=0; i<dimension; i++) {
final int ts = tileSize[i];
tmcOfFirstTile[i] = floorDiv(readExtent.getLow(i), ts);
@@ -241,6 +242,7 @@ public abstract class TiledGridCoverage extends
GridCoverage {
* This value is not stored but its computation is still useful because
* we want `ArithmeticException` to be thrown if the value is too high.
*/
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
SampleModel model = subset.modelForBandSubset;
if (model.getWidth() != subSize[X_DIMENSION] || model.getHeight() !=
subSize[Y_DIMENSION]) {
model = model.createCompatibleSampleModel(subSize[X_DIMENSION],
subSize[Y_DIMENSION]);
@@ -527,6 +529,7 @@ public abstract class TiledGridCoverage extends
GridCoverage {
* converts the `tileLower` coordinates to index in the
`tileOffsets` and `tileByteCounts` vectors.
*/
indexInTileVector = indexOfFirstTile;
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
int tileCountInQuery = 1;
for (int i=0; i<dimension; i++) {
final int lower = tileLower[i];
@@ -592,7 +595,9 @@ public abstract class TiledGridCoverage extends
GridCoverage {
*/
public final long[] getPositionInSource() {
final long[] coordinate = new long[tmcOfFirstTile.length];
- for (int i = 0; i < coordinate.length; i++) coordinate[i] =
(long)tmcOfFirstTile[i] + tmcInSubset[i];
+ for (int i = 0; i < coordinate.length; i++) {
+ coordinate[i] = Math.addExact(tmcOfFirstTile[i],
tmcInSubset[i]);
+ }
return coordinate;
}