Skip to content

Commit 1f2502b

Browse files
committed
Add TG extension tests
1 parent e116576 commit 1f2502b

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
6868
Rasters = "a3a2b9e3-a471-40c9-b274-f788e487c689"
6969
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
7070
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
71+
TGGeometry = "d7e755d2-3c95-4bcf-9b3c-79ab1a78647b"
7172
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7273

7374
[targets]
74-
test = ["ArchGDAL", "CoordinateTransformations", "DataFrames", "Distributions", "DimensionalData", "Downloads", "FlexiJoins", "GeoJSON", "Proj", "JLD2", "LibGEOS", "Random", "Rasters", "NaturalEarth", "OffsetArrays", "SafeTestsets", "Shapefile", "Test"]
75+
test = ["ArchGDAL", "CoordinateTransformations", "DataFrames", "Distributions", "DimensionalData", "Downloads", "FlexiJoins", "GeoJSON", "Proj", "JLD2", "LibGEOS", "Random", "Rasters", "NaturalEarth", "OffsetArrays", "SafeTestsets", "Shapefile", "TGGeometry", "Test"]

test/extensions/tggeometry.jl

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ end
4040
# Extensions
4141
@safetestset "FlexiJoins" begin include("extensions/flexijoins.jl") end
4242
@safetestset "LibGEOS" begin include("extensions/libgeos.jl") end
43+
@safetestset "TGGeometry" begin include("extensions/tggeometry.jl") end

0 commit comments

Comments
 (0)