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 475fd862fd0beeff776e70584fc5941431647c9c Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed Sep 2 12:51:43 2020 +0200 More accurate identification of error when image size is not an integer multiple of tile size. --- .../src/main/java/org/apache/sis/image/PlanarImage.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java index f32d979..276729a 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java +++ b/core/sis-feature/src/main/java/org/apache/sis/image/PlanarImage.java @@ -521,7 +521,9 @@ public abstract class PlanarImage implements RenderedImage { * <li>{@code "tileWidth"} — tile width is greater than sample model width.</li> * <li>{@code "tileHeight"} — tile height is greater than sample model height.</li> * <li>{@code "numXTiles"} — number of tiles on the X axis is inconsistent with image width.</li> + * <li>{@code "width"} — image width is not an integer multiple of tile width.</li> * <li>{@code "numYTiles"} — number of tiles on the Y axis is inconsistent with image height.</li> + * <li>{@code "height"} — image height is not an integer multiple of tile height.</li> * <li>{@code "tileX"} — {@ode minTileX} and/or {@code tileGridXOffset} is inconsistent.</li> * <li>{@code "tileY"} — {@ode minTileY} and/or {@code tileGridYOffset} is inconsistent.</li> * </ul> @@ -548,8 +550,16 @@ public abstract class PlanarImage implements RenderedImage { if (sm.getWidth() < tileWidth) return "tileWidth"; if (sm.getHeight() < tileHeight) return "tileHeight"; } - if (JDK9.multiplyFull(getNumXTiles(), tileWidth) != getWidth()) return "numXTiles"; - if (JDK9.multiplyFull(getNumYTiles(), tileHeight) != getHeight()) return "numYTiles"; + long size = getWidth(); + long remainder = size - JDK9.multiplyFull(getNumXTiles(), tileWidth); + if (remainder != 0) { + return (remainder >= 0 && remainder < size) ? "width" : "numXTiles"; + } + size = getHeight(); + remainder = size - JDK9.multiplyFull(getNumYTiles(), tileHeight); + if (remainder != 0) { + return (remainder >= 0 && remainder < size) ? "height" : "numYTiles"; + } if (JDK9.multiplyFull(getMinTileX(), tileWidth) + getTileGridXOffset() != getMinX()) return "tileX"; if (JDK9.multiplyFull(getMinTileY(), tileHeight) + getTileGridYOffset() != getMinY()) return "tileY"; return null;
