Skip to content

Commit bb65e21

Browse files
authored
Merge pull request #195 from Esri/stolstov/convexhull_194
Fix convex hull crash for collection of polygons
2 parents b98b428 + 072434b commit bb65e21

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ ehthumbs.db
3535
Thumbs.db
3636
target/*
3737
/bin/
38+
/target/

src/main/java/com/esri/core/geometry/ogc/OGCConcreteGeometryCollection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,13 @@ else if (geom.getType() == Geometry.Type.Point) {
444444
}
445445

446446
if (!polygon.isEmpty()) {
447-
if (!resultGeom.isEmpty()) {
447+
if (resultGeom != null && !resultGeom.isEmpty()) {
448448
Geometry[] geoms = { resultGeom, polygon };
449449
resultGeom = OperatorConvexHull.local().execute(
450450
new SimpleGeometryCursor(geoms), true, null).next();
451451
}
452452
else {
453-
resultGeom = polygon;
453+
resultGeom = OperatorConvexHull.local().execute(polygon, null);
454454
}
455455
}
456456

src/test/java/com/esri/core/geometry/TestConvexHull.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,4 +1059,14 @@ public void testHullIssueGithub172() {
10591059
}
10601060
}
10611061

1062+
@Test
1063+
public void testHullIssueGithub194() {
1064+
{
1065+
//empty
1066+
OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POLYGON((0 0, 1 0, 1 1, 0 0)), POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10), (-5 -5, -5 5, 5 5, 5 -5, -5 -5)))");
1067+
OGCGeometry result = geom.convexHull();
1068+
String text = result.asText();
1069+
assertTrue(text.compareTo("POLYGON ((-10 -10, 10 -10, 10 10, -10 10, -10 -10))") == 0);
1070+
}
1071+
}
10621072
}

0 commit comments

Comments
 (0)