-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathintersection_points.jl
More file actions
43 lines (34 loc) · 2.38 KB
/
intersection_points.jl
File metadata and controls
43 lines (34 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Test
import GeoInterface as GI
import GeometryOps as GO
import LibGEOS as LG
using ..TestHelpers
l1 = GI.LineString([(90000.0, 1000.0), (90000.0, 22500.0), (95000.0, 22500.0), (95000.0, 1000.0), (90000.0, 1000.0)])
l2 = GI.LineString([(90000.0, 7500.0), (107500.0, 27500.0), (112500.0, 27500.0), (95000.0, 7500.0), (90000.0, 7500.0)])
l3 = GI.LineString([(90000.0, 90000.0), (90000.0, 105000.0), (105000.0, 105000.0), (105000.0, 90000.0), (90000.0, 90000.0)])
l4 = GI.LineString([(-98000.0, 90000.0), (-98000.0, 105000.0), (98000.0, 105000.0), (98000.0, 90000.0), (-98000.0, 90000.0)])
l5 = GI.LineString([(19999.999, 25000.0), (19999.999, 29000.0), (39999.998999999996, 29000.0), (39999.998999999996, 25000.0), (19999.999, 25000.0)])
l6 = GI.LineString([(0.0, 25000.0), (0.0, 29000.0), (20000.0, 29000.0), (20000.0, 25000.0), (0.0, 25000.0)])
p1, p2 = GI.Polygon([l1]), GI.Polygon([l2])
mp1 = GI.MultiPolygon([p1, GI.Polygon([l3])])
struct TrackingExact end
GO.GeometryOpsCore.booltype(::TrackingExact) = error("tracking exact forwarded")
@testset_implementations begin
# Three intersection points
LG_l1_l2_mp = GI.MultiPoint(collect(GI.getpoint(LG.intersection($l1, $l2))))
@test GO.equals(GI.MultiPoint(GO.intersection_points($l1, $l2)), LG_l1_l2_mp)
@test GO.equals(GI.MultiPoint(GO.intersection_points($l1, $l2; exact = false)), LG_l1_l2_mp)
@test GO.equals(GI.MultiPoint(GO.intersection($l1, $l2; target = GI.PointTrait(), exact = false)), LG_l1_l2_mp)
# Four intersection points with large intersection
LG_l3_l4_mp = GI.MultiPoint(collect(GI.getpoint(LG.intersection($l3, $l4))))
@test GO.equals(GI.MultiPoint(GO.intersection_points($l3, $l4)), LG_l3_l4_mp)
# Four intersection points with very small intersection
LG_l5_l6_mp = GI.MultiPoint(collect(GI.getpoint(LG.intersection($l5, $l6))))
@test GO.equals(GI.MultiPoint(GO.intersection_points($l5, $l6)), LG_l5_l6_mp)
# Test that intersection points between lines and polygons is equivalent
@test GO.equals(GI.MultiPoint(GO.intersection_points($p1, $p2)), GI.MultiPoint(GO.intersection_points($l1, $l2)))
# No intersection points between polygon and line
@test isempty(GO.intersection_points($p1, $l6))
# Recursive polygon-multipolygon intersections should forward `exact`
@test_throws "tracking exact forwarded" GO.intersection($p1, $mp1; target = GI.PolygonTrait(), exact = TrackingExact())
end