1
+ using Test
2
+
3
+ import GeometryOps as GO, GeoInterface as GI
4
+ import TGGeometry
5
+
6
+ # This test file is only really certifying that the extension is working...
7
+ # we rely on TGGeometry.jl's tests to verify correctness, since it's not an exact
8
+ # library and a lot of our tests do check exactness.
9
+
10
+ # That's why it isn't included in the main polygon test suite.
11
+
12
+ point = (0.0 , 0.0 )
13
+ multipoint = GI. MultiPoint ([(0.0 , 0.0 ), (1.0 , 1.0 )])
14
+ linestring = GI. LineString ([(0.0 , 0.0 ), (1.0 , 1.0 )])
15
+ multilinestring = GI. MultiLineString ([[(0.0 , 0.0 ), (1.0 , 1.0 )], [(2.0 , 2.0 ), (3.0 , 3.0 )]])
16
+ polygon = GI. Polygon ([[(0.0 , 0.0 ), (1.0 , 0.0 ), (1.0 , 1.0 ), (0.0 , 1.0 ), (0.0 , 0.0 )]])
17
+ multipolygon = GI. MultiPolygon ([polygon, GO. transform (p -> (GI. x (p), GI. y (p) + 1.0 ), polygon)])
18
+
19
+ _xplus5 (g) = GO. transform (p -> (GI. x (p) + 5.0 , GI. y (p)), g)
20
+
21
+ disjoint_point = _xplus5 (point)
22
+ disjoint_multipoint = _xplus5 (multipoint)
23
+ disjoint_linestring = _xplus5 (linestring)
24
+ disjoint_multilinestring = _xplus5 (multilinestring)
25
+ disjoint_polygon = _xplus5 (polygon)
26
+ disjoint_multipolygon = _xplus5 (multipolygon)
27
+
28
+ @testset " Internal consistency with TGGeometry.jl" begin
29
+ for funsym in TGGeometry. TG_PREDICATES
30
+ for geom1 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
31
+ for geom2 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
32
+ @testset let predicate = funsym, geom1 = geom1, geom2 = geom2
33
+ @test Base. getproperty (TGGeometry, predicate)(geom1, geom2) == Base. getproperty (GO, predicate)(GO. TG (), geom1, geom2)
34
+ end
35
+ end
36
+ for geom2 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
37
+ @testset let predicate = funsym, geom1 = geom1, geom2 = geom2
38
+ @test Base. getproperty (TGGeometry, predicate)(geom1, geom2) == Base. getproperty (GO, predicate)(GO. TG (), geom1, geom2)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ @testset " Consistency with GeometryOps algorithms for simple cases" begin
46
+ for funsym in TGGeometry. TG_PREDICATES
47
+ for geom1 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
48
+ for geom2 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
49
+ @testset let predicate = funsym, geom1 = geom1, geom2 = geom2
50
+ @test Base. getproperty (TGGeometry, predicate)(geom1, geom2) == Base. getproperty (GO, predicate)(GO. TG (), geom1, geom2)
51
+ end
52
+ end
53
+ for geom2 in (point, multipoint, linestring, multilinestring, polygon, multipolygon)
54
+ @testset let predicate = funsym, geom1 = geom1, geom2 = geom2
55
+ @test Base. getproperty (TGGeometry, predicate)(geom1, geom2) == Base. getproperty (GO, predicate)(GO. TG (), geom1, geom2)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
0 commit comments