This is an automated email from the ASF dual-hosted git repository.
jsorel 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 2ca3cea Coverage : new DisjointExtentException used to detect
disjoint queries on coverages
2ca3cea is described below
commit 2ca3cea7475696eb9fc750edea477e0c47ab0b68
Author: jsorel <[email protected]>
AuthorDate: Wed Mar 20 11:51:31 2019 +0100
Coverage : new DisjointExtentException used to detect disjoint queries on
coverages
---
.../sis/coverage/grid/DisjointExtentException.java | 59 ++++++++++++++++++++++
.../org/apache/sis/coverage/grid/GridExtent.java | 2 +
2 files changed, 61 insertions(+)
diff --git
a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/DisjointExtentException.java
b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/DisjointExtentException.java
new file mode 100644
index 0000000..a3d72ff
--- /dev/null
+++
b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/DisjointExtentException.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.coverage.grid;
+
+/**
+ * Thrown when operations on a {@link GridGeometry} result in an area which
+ * do not intersect anymore the {@link GridExtent} of the {@link GridGeometry}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+public class DisjointExtentException extends IllegalGridGeometryException {
+
+ /**
+ * Serial number for inter-operability with different versions.
+ */
+ private static final long serialVersionUID = -1437479443547738220L;
+
+ /**
+ * Constructs an exception with no detail message.
+ */
+ public DisjointExtentException() {
+ }
+
+ /**
+ * Constructs an exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public DisjointExtentException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs an exception with the specified detail message and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause for this exception.
+ */
+ public DisjointExtentException(final String message, final Throwable
cause) {
+ super(message, cause);
+ }
+}
diff --git
a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
index 2dd3bf1..2ccc779 100644
--- a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
+++ b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridExtent.java
@@ -405,6 +405,8 @@ public class GridExtent implements Serializable {
if (enclosing != null) {
final int lo = (modifiedDimensions != null) ?
modifiedDimensions[i] : i;
final int hi = lo + m;
+ if (lower > coordinates[hi]) throw new
DisjointExtentException();
+ if (upper < coordinates[lo]) throw new
DisjointExtentException();
if (lower > coordinates[lo]) coordinates[lo] =
Math.min(coordinates[hi], lower);
if (upper < coordinates[hi]) coordinates[hi] =
Math.max(coordinates[lo], upper);
} else {