This is an automated email from the ASF dual-hosted git repository.
amanin 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 617c6d0 fix(Feature): Do not fail decoding a linestring with only
three points whose first and last are the same.
617c6d0 is described below
commit 617c6d06b49dbed1a927c44d1261623d682bf399
Author: Alexis Manin <[email protected]>
AuthorDate: Mon Jan 20 11:24:43 2020 +0100
fix(Feature): Do not fail decoding a linestring with only three points
whose first and last are the same.
---
.../apache/sis/internal/feature/jts/Factory.java | 23 ++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git
a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/Factory.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/Factory.java
index 8428a33..8688584 100644
---
a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/Factory.java
+++
b/core/sis-feature/src/main/java/org/apache/sis/internal/feature/jts/Factory.java
@@ -21,6 +21,17 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+import org.apache.sis.internal.feature.Geometries;
+import org.apache.sis.internal.feature.GeometryWrapper;
+import org.apache.sis.internal.util.Strings;
+import org.apache.sis.math.Vector;
+import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.util.Classes;
+import org.apache.sis.util.resources.Errors;
+
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@@ -31,14 +42,6 @@ import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKBReader;
import org.locationtech.jts.io.WKTReader;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.setup.GeometryLibrary;
-import org.apache.sis.internal.feature.Geometries;
-import org.apache.sis.internal.feature.GeometryWrapper;
-import org.apache.sis.internal.util.Strings;
-import org.apache.sis.math.Vector;
-import org.apache.sis.util.Classes;
-import org.apache.sis.util.resources.Errors;
/**
@@ -202,8 +205,8 @@ public final class Factory extends Geometries<Geometry> {
final Geometry geom;
if (polygon) {
geom = factory.createPolygon(ca);
- } else if (ca[0].equals2D(ca[s-1])) {
- geom = factory.createLinearRing(ca); // Throws an
exception if s < 4.
+ } else if (ca.length > 3 && ca[0].equals2D(ca[s-1])) {
+ geom = factory.createLinearRing(ca);
} else {
geom = factory.createLineString(ca); // Throws an
exception if contains duplicated point.
}