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 e8850ce897 fix(Shapefile): handle case of bad geometry lines with NaN 
values
e8850ce897 is described below

commit e8850ce897aa31b588cc3bc181b54e33607924c3
Author: jsorel <[email protected]>
AuthorDate: Tue Nov 28 12:33:18 2023 +0100

    fix(Shapefile): handle case of bad geometry lines with NaN values
---
 .../apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
index 314f6338f0..f3ab943720 100644
--- 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
+++ 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
@@ -193,6 +193,16 @@ public abstract class ShapeGeometryEncoder<T extends 
Geometry> {
         final int numPoints = channel.readInt();
         final int[] offsets = channel.readInts(numParts);
 
+        if (!shape.bbox.isFinite()) {
+            //a broken geometry with NaN, until we replace JTS we need to 
create an empty geometry
+            switch (nbOrdinates) {
+                case 2 : channel.seek(channel.getStreamPosition() + 
2*8*numPoints); break;
+                case 3 : channel.seek(channel.getStreamPosition() + 
3*8*numPoints); break;
+                case 4 : channel.seek(channel.getStreamPosition() + 
4*8*numPoints); break;
+            }
+            return new LineString[0];
+        }
+
         final LineString[] lines = new LineString[numParts];
 
         //XY

Reply via email to