Skip to content

Commit

Permalink
Revert the geom relations tests for #135
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Jun 11, 2024
1 parent c46c2d8 commit 458b62b
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions test/methods/geom_relations.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Test
import GeometryOps as GO
import GeoInterface as GI
import LibGEOS as LG
Expand Down Expand Up @@ -171,36 +170,37 @@ function test_geom_relation(GO_f, LG_f, f_name; swap_points = false)
end
end

@testset "Covered By" begin test_geom_relation(GO.coveredby, (x, y) -> GO.coveredby(GO.GEOS(), x, y), "coveredby") end
@testset "Contains" begin test_geom_relation(GO.contains, (x, y) -> GO.contains(GO.GEOS(), x, y), "contains"; swap_points = true) end
@testset "Covers" begin test_geom_relation(GO.covers, (x, y) -> GO.covers(GO.GEOS(), x, y), "covers"; swap_points = true) end
@testset "Disjoint" begin test_geom_relation(GO.disjoint, (x, y) -> GO.disjoint(GO.GEOS(), x, y), "disjoint")end
@testset "Intersect" begin test_geom_relation(GO.intersects, (x, y) -> GO.intersects(GO.GEOS(), x, y), "intersects") end
@testset "Touches" begin test_geom_relation(GO.touches, (x, y) -> GO.touches(GO.GEOS(), x, y), "touches") end
@testset "Within" begin test_geom_relation(GO.within, (x, y) -> GO.within(GO.GEOS(), x, y), "within") end
@testset "Contains" begin test_geom_relation(GO.contains, LG.contains, "contains"; swap_points = true) end
@testset "Covered By" begin test_geom_relation(GO.coveredby, LG.coveredby, "coveredby") end
@testset "Covers" begin test_geom_relation(GO.covers, LG.covers, "covers"; swap_points = true) end
@testset "Disjoint" begin test_geom_relation(GO.disjoint, LG.disjoint, "disjoint")end
@testset "Intersect" begin test_geom_relation(GO.intersects, LG.intersects, "intersects") end
@testset "Touches" begin test_geom_relation(GO.touches, LG.touches, "touches") end
@testset "Within" begin test_geom_relation(GO.within, LG.within, "within") end


@testset "Overlaps" begin
@testset "Points/MultiPoints" begin
p1 = LG.Point([0.0, 0.0])
p2 = LG.Point([0.0, 1.0])
# Two points can't overlap
@test GO.overlaps(p1, p1) == GO.overlaps(GO.GEOS(), p1, p2)
@test GO.overlaps(p1, p1) == LG.overlaps(p1, p2)

mp1 = LG.MultiPoint([[0.0, 1.0], [4.0, 4.0]])
mp2 = LG.MultiPoint([[0.0, 1.0], [2.0, 2.0]])
mp3 = LG.MultiPoint([[0.0, 1.0], [2.0, 2.0], [3.0, 3.0]])
# No shared points, doesn't overlap
@test GO.overlaps(p1, mp1) == GO.overlaps(GO.GEOS(), p1, mp1)
@test GO.overlaps(p1, mp1) == LG.overlaps(p1, mp1)
# One shared point, does overlap
@test GO.overlaps(p2, mp1) == GO.overlaps(GO.GEOS(), p2, mp1)
@test GO.overlaps(p2, mp1) == LG.overlaps(p2, mp1)
# All shared points, doesn't overlap
@test GO.overlaps(mp1, mp1) == GO.overlaps(GO.GEOS(), mp1, mp1)
@test GO.overlaps(mp1, mp1) == LG.overlaps(mp1, mp1)
# Not all shared points, overlaps
@test GO.overlaps(mp1, mp2) == GO.overlaps(GO.GEOS(), mp1, mp2)
@test GO.overlaps(mp1, mp2) == LG.overlaps(mp1, mp2)
# One set of points entirely inside other set, doesn't overlap
@test GO.overlaps(mp2, mp3) == GO.overlaps(GO.GEOS(), mp2, mp3)
@test GO.overlaps(mp2, mp3) == LG.overlaps(mp2, mp3)
# Not all points shared, overlaps
@test GO.overlaps(mp1, mp3) == GO.overlaps(GO.GEOS(), mp1, mp3)
@test GO.overlaps(mp1, mp3) == LG.overlaps(mp1, mp3)

mp1 = LG.MultiPoint([
[-36.05712890625, 26.480407161007275],
Expand All @@ -218,7 +218,7 @@ end
[-34.9969482421875, 26.455820238459893],
])
# Some shared points, overlaps
@test GO.overlaps(mp1, mp2) == GO.overlaps(GO.GEOS(), mp1, mp2)
@test GO.overlaps(mp1, mp2) == LG.overlaps(mp1, mp2)
@test GO.overlaps(mp1, mp2) == GO.overlaps(mp2, mp1)
end

Expand All @@ -228,17 +228,17 @@ end
l3 = LG.LineString([[0.0, -10.0], [0.0, 3.0]])
l4 = LG.LineString([[5.0, -5.0], [5.0, 5.0]])
# Line can't overlap with itself
@test GO.overlaps(l1, l1) == GO.overlaps(GO.GEOS(), l1, l1)
@test GO.overlaps(l1, l1) == LG.overlaps(l1, l1)
# Line completely within other line doesn't overlap
@test GO.overlaps(l1, l2) == GO.overlaps(l2, l1) == GO.overlaps(GO.GEOS(), l1, l2)
@test GO.overlaps(l1, l2) == GO.overlaps(l2, l1) == LG.overlaps(l1, l2)
# Overlapping lines
@test GO.overlaps(l1, l3) == GO.overlaps(l3, l1) == GO.overlaps(GO.GEOS(), l1, l3)
@test GO.overlaps(l1, l3) == GO.overlaps(l3, l1) == LG.overlaps(l1, l3)
# Lines that don't touch
@test GO.overlaps(l1, l4) == GO.overlaps(GO.GEOS(), l1, l4)
@test GO.overlaps(l1, l4) == LG.overlaps(l1, l4)
# Linear rings that intersect but don't overlap
r1 = LG.LinearRing([[0.0, 0.0], [0.0, 5.0], [5.0, 5.0], [5.0, 0.0], [0.0, 0.0]])
r2 = LG.LinearRing([[1.0, 1.0], [1.0, 6.0], [6.0, 6.0], [6.0, 1.0], [1.0, 1.0]])
@test GO.overlaps(r1, r2) == GO.overlaps(GO.GEOS(), r1, r2)
@test GO.overlaps(r1, r2) == LG.overlaps(r1, r2)
end

@testset "Polygons/MultiPolygons" begin
Expand All @@ -248,17 +248,17 @@ end
[[15.0, 1.0], [15.0, 11.0], [25.0, 11.0], [25.0, 1.0], [15.0, 1.0]]
])
# Test basic polygons that don't overlap
@test GO.overlaps(p1, p2) == GO.overlaps(GO.GEOS(), p1, p2)
@test GO.overlaps(p1, p2) == LG.overlaps(p1, p2)
@test !GO.overlaps(p1, (1, 1))
@test !GO.overlaps((1, 1), p2)

p3 = LG.Polygon([[[1.0, 1.0], [1.0, 6.0], [6.0, 6.0], [6.0, 1.0], [1.0, 1.0]]])
# Test basic polygons that overlap
@test GO.overlaps(p1, p3) == GO.overlaps(GO.GEOS(), p1, p3)
@test GO.overlaps(p1, p3) == LG.overlaps(p1, p3)

p4 = LG.Polygon([[[20.0, 5.0], [20.0, 10.0], [18.0, 10.0], [18.0, 5.0], [20.0, 5.0]]])
# Test one polygon within the other
@test GO.overlaps(p2, p4) == GO.overlaps(p4, p2) == GO.overlaps(GO.GEOS(), p2, p4)
@test GO.overlaps(p2, p4) == GO.overlaps(p4, p2) == LG.overlaps(p2, p4)

p5 = LG.Polygon(
[[
Expand All @@ -269,7 +269,7 @@ end
]]
)
# Test equal polygons
@test GO.overlaps(p5, p5) == GO.overlaps(GO.GEOS(), p5, p5)
@test GO.overlaps(p5, p5) == LG.overlaps(p5, p5)

# Test multipolygons
m1 = LG.MultiPolygon([
Expand All @@ -280,9 +280,9 @@ end
]
])
# Test polygon that overlaps with multipolygon
@test GO.overlaps(m1, p3) == GO.overlaps(GO.GEOS(), m1, p3)
@test GO.overlaps(m1, p3) == LG.overlaps(m1, p3)
# Test polygon in hole of multipolygon, doesn't overlap
@test GO.overlaps(m1, p4) == GO.overlaps(GO.GEOS(), m1, p4)
@test GO.overlaps(m1, p4) == LG.overlaps(m1, p4)
end
end
@testset "Crosses" begin
Expand Down

0 comments on commit 458b62b

Please sign in to comment.