|
27 | 27 | import junit.framework.TestCase; |
28 | 28 | import org.junit.Test; |
29 | 29 |
|
| 30 | +import com.esri.core.geometry.ogc.OGCGeometry; |
| 31 | + |
30 | 32 | public class TestConvexHull extends TestCase { |
31 | 33 | @Override |
32 | 34 | protected void setUp() throws Exception { |
@@ -992,5 +994,69 @@ public void testHullTickTock() { |
992 | 994 | assertTrue(p5.x == -5.0 && p5.y == 1.25); |
993 | 995 | assertTrue(p6.x == 0.0 && p6.y == 10.0); |
994 | 996 | } |
| 997 | + |
| 998 | + @Test |
| 999 | + public void testHullIssueGithub172() { |
| 1000 | + { |
| 1001 | + //empty |
| 1002 | + OGCGeometry geom = OGCGeometry.fromText("MULTIPOINT EMPTY"); |
| 1003 | + OGCGeometry result = geom.convexHull(); |
| 1004 | + String text = result.asText(); |
| 1005 | + assertTrue(text.compareTo("POINT EMPTY") == 0); |
| 1006 | + } |
| 1007 | + { |
| 1008 | + //Point |
| 1009 | + OGCGeometry geom = OGCGeometry.fromText("POINT (1 2)"); |
| 1010 | + OGCGeometry result = geom.convexHull(); |
| 1011 | + String text = result.asText(); |
| 1012 | + assertTrue(text.compareTo("POINT (1 2)") == 0); |
| 1013 | + } |
| 1014 | + { |
| 1015 | + //line |
| 1016 | + OGCGeometry geom = OGCGeometry.fromText("MULTIPOINT (1 1, 2 2)"); |
| 1017 | + OGCGeometry result = geom.convexHull(); |
| 1018 | + String text = result.asText(); |
| 1019 | + assertTrue(text.compareTo("LINESTRING (1 1, 2 2)") == 0); |
| 1020 | + } |
| 1021 | + { |
| 1022 | + //empty |
| 1023 | + OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION EMPTY"); |
| 1024 | + OGCGeometry result = geom.convexHull(); |
| 1025 | + String text = result.asText(); |
| 1026 | + assertTrue(text.compareTo("POINT EMPTY") == 0); |
| 1027 | + } |
| 1028 | + |
| 1029 | + { |
| 1030 | + //empty |
| 1031 | + OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 2))"); |
| 1032 | + OGCGeometry result = geom.convexHull(); |
| 1033 | + String text = result.asText(); |
| 1034 | + assertTrue(text.compareTo("POINT (1 2)") == 0); |
| 1035 | + } |
| 1036 | + |
| 1037 | + { |
| 1038 | + //empty |
| 1039 | + OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"); |
| 1040 | + OGCGeometry result = geom.convexHull(); |
| 1041 | + String text = result.asText(); |
| 1042 | + assertTrue(text.compareTo("POINT (1 1)") == 0); |
| 1043 | + } |
| 1044 | + |
| 1045 | + { |
| 1046 | + //empty |
| 1047 | + OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, LINESTRING (1 1, 2 2), POINT(3 3), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"); |
| 1048 | + OGCGeometry result = geom.convexHull(); |
| 1049 | + String text = result.asText(); |
| 1050 | + assertTrue(text.compareTo("LINESTRING (1 1, 3 3)") == 0); |
| 1051 | + } |
| 1052 | + |
| 1053 | + { |
| 1054 | + //empty |
| 1055 | + OGCGeometry geom = OGCGeometry.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, LINESTRING (1 1, 2 2), POINT(3 3), LINESTRING EMPTY, POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10), (-5 -5, -5 5, 5 5, 5 -5, -5 -5)))"); |
| 1056 | + OGCGeometry result = geom.convexHull(); |
| 1057 | + String text = result.asText(); |
| 1058 | + assertTrue(text.compareTo("POLYGON ((-10 -10, 10 -10, 10 10, -10 10, -10 -10))") == 0); |
| 1059 | + } |
| 1060 | + } |
995 | 1061 |
|
996 | 1062 | } |
0 commit comments