|
19 | 19 |
|
20 | 20 | function factcheck(f::Function, g1::String, g2::String, expected::Bool) |
21 | 21 | @test f(readgeom(g1),readgeom(g2)) == expected |
| 22 | + @test f(prepareGeom(readgeom(g1)),readgeom(g2)) == expected |
22 | 23 | end |
23 | 24 |
|
24 | 25 | @testset "GEOS operations" begin |
|
35 | 36 | @test equals(interpolate(ls, test_dist), dest) |
36 | 37 | end |
37 | 38 |
|
38 | | - g1 = readgeom("POLYGON EMPTY") |
39 | | - g2 = readgeom("POLYGON EMPTY") |
40 | | - @test !LibGEOS.contains(g1, g2) |
41 | | - @test !LibGEOS.contains(g2, g1) |
42 | | - |
43 | | - g1 = readgeom("POLYGON((1 1,1 5,5 5,5 1,1 1))") |
44 | | - g2 = readgeom("POINT(2 2)") |
45 | | - @test LibGEOS.contains(g1, g2) |
46 | | - @test !LibGEOS.contains(g2, g1) |
47 | | - |
48 | | - g1 = readgeom("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))") |
49 | | - g2 = readgeom("POLYGON((1 1,1 2,2 2,2 1,1 1))") |
50 | | - @test LibGEOS.contains(g1, g2) |
51 | | - @test !LibGEOS.contains(g2, g1) |
52 | | - |
53 | | - |
54 | 39 | # GEOSConvexHullTest |
55 | 40 | input = readgeom("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)") |
56 | 41 | expected = readgeom("LINESTRING (130 240, 650 240)") |
|
114 | 99 | "POLYGON((0 1,0 2,10 2,10 1,0 1))", |
115 | 100 | "GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), LINESTRING (2 1, 1 1), POLYGON ((0.5 1, 1 2, 1 1, 0.5 1)), POLYGON ((9 2, 9.5 1, 2 1, 2 2, 9 2)))") |
116 | 101 |
|
117 | | - # GEOSIntersectsTest |
118 | | - test_intersects(g1::String, g2::String, expected::Bool) = factcheck(intersects, g1, g2, expected) |
119 | | - test_intersects("POLYGON EMPTY", "POLYGON EMPTY", false) |
120 | | - test_intersects("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", true) |
121 | | - test_intersects("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true) |
122 | | - test_intersects("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true) |
123 | | - test_intersects("POLYGON((1 1,1 2,2 2,2 1,1 1))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true) |
124 | | - |
125 | 102 | # LineString_PointTest |
126 | 103 | g1 = readgeom("LINESTRING(0 0, 5 5, 10 10)") |
127 | 104 | @test !isClosed(g1) |
@@ -232,13 +209,37 @@ end |
232 | 209 | test_unaryunion("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)), MULTIPOINT(6 6.5, 6 1, 12 2, 6 1))", |
233 | 210 | "GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))") |
234 | 211 |
|
235 | | - # GEOSWithinTest |
236 | | - test_within(g1::String, g2::String, expected::Bool) = factcheck(within, g1, g2, expected) |
237 | | - test_within("POLYGON EMPTY", "POLYGON EMPTY", false) |
238 | | - test_within("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", false) |
239 | | - test_within("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true) |
240 | | - test_within("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "POLYGON((1 1,1 2,2 2,2 1,1 1))", false) |
241 | | - test_within("POLYGON((1 1,1 2,2 2,2 1,1 1))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true) |
| 212 | + for (g1, g2, testvalue) in ( |
| 213 | + ("POLYGON EMPTY", "POLYGON EMPTY", false), |
| 214 | + ("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", false), |
| 215 | + ("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true), |
| 216 | + ("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "POLYGON((1 1,1 2,2 2,2 1,1 1))", false), |
| 217 | + ("POLYGON((1 1,1 2,2 2,2 1,1 1))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true), |
| 218 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 200 201, 300 300)", false), |
| 219 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 200 200, 300 300)", false), |
| 220 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 300 100)", false) |
| 221 | + ) |
| 222 | + for f in (within, coveredby) |
| 223 | + factcheck(f, g1, g2, testvalue) |
| 224 | + end |
| 225 | + for f in (contains, covers) |
| 226 | + factcheck(f, g2, g1, testvalue) |
| 227 | + end |
| 228 | + end |
| 229 | + |
| 230 | + for (g1, g2, testvalue) in ( |
| 231 | + ("POLYGON EMPTY", "POLYGON EMPTY", false), |
| 232 | + ("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", true), |
| 233 | + ("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true), |
| 234 | + ("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true), |
| 235 | + ("POLYGON((1 1,1 2,2 2,2 1,1 1))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true), |
| 236 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 200 201, 300 300)", false), |
| 237 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 200 200, 300 300)", true), |
| 238 | + ("LINESTRING (100 200, 300 200)", "LINESTRING (100 300, 300 100)", true) |
| 239 | + ) |
| 240 | + factcheck(intersects, g1, g2, testvalue) |
| 241 | + factcheck(disjoint, g1, g2, !testvalue) |
| 242 | + end |
242 | 243 |
|
243 | 244 | # GEOSisClosedTest |
244 | 245 | @test !isClosed(readgeom("LINESTRING(0 0, 1 0, 1 1)")) |
|
0 commit comments