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 cd7680c97a9cc3cae2c59dfb86cfbbf8b3dcef12
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Wed Feb 21 11:47:57 2024 +0100

    JTS envelope may be empty, for example when created from a multi-polygon 
containing 0 polygon.
---
 .../main/org/apache/sis/geometry/wrapper/jts/Wrapper.java   | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
index 695fe65cd1..9cfb4bc5b5 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/geometry/wrapper/jts/Wrapper.java
@@ -199,15 +199,12 @@ final class Wrapper extends GeometryWrapper {
     public GeneralEnvelope getEnvelope() {
         final Envelope bounds = geometry.getEnvelopeInternal();
         final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
-        final GeneralEnvelope env;
-        if (crs != null) {
-            env = new GeneralEnvelope(crs);
-            env.setToNaN();
-        } else {
-            env = new GeneralEnvelope(Factory.BIDIMENSIONAL);
+        final var env = (crs != null) ? new GeneralEnvelope(crs) : new 
GeneralEnvelope(Factory.BIDIMENSIONAL);
+        env.setToNaN();
+        if (!bounds.isNull()) {
+            env.setRange(0, bounds.getMinX(), bounds.getMaxX());
+            env.setRange(1, bounds.getMinY(), bounds.getMaxY());
         }
-        env.setRange(0, bounds.getMinX(), bounds.getMaxX());
-        env.setRange(1, bounds.getMinY(), bounds.getMaxY());
         return env;
     }
 

Reply via email to