Skip to content

Commit

Permalink
Sg/de9im reorganization (#41)
Browse files Browse the repository at this point in the history
* Fix up intersection point base calculation

* Update intersects and add line tests

* Add more tests and debug intersects

* Add comments to point_in_poly

* Remove CairoMakie

* Update equals and overlaps

* Remove use of findfirst for 1.6 compat

* Updated geom, multi-geom equality

* Move DE-9IM functions into folder and consolidate tests

* Move DE-9IM tests from bools to geom_relations

* Cleanup
  • Loading branch information
skygering authored Jan 2, 2024
1 parent 135be02 commit 35a3f43
Show file tree
Hide file tree
Showing 12 changed files with 332 additions and 328 deletions.
22 changes: 11 additions & 11 deletions src/GeometryOps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ const Edge = Tuple{TuplePoint,TuplePoint}
include("primitives.jl")
include("utils.jl")

include("methods/bools.jl")
include("methods/distance.jl")
include("methods/area.jl")
include("methods/centroid.jl")
include("methods/intersects.jl")
include("methods/contains.jl")
include("methods/crosses.jl")
include("methods/disjoint.jl")
include("methods/overlaps.jl")
include("methods/within.jl")
include("methods/polygonize.jl")
include("methods/barycentric.jl")
include("methods/bools.jl")
include("methods/centroid.jl")
include("methods/distance.jl")
include("methods/equals.jl")
include("methods/geom_relations/intersects.jl")
include("methods/geom_relations/contains.jl")
include("methods/geom_relations/crosses.jl")
include("methods/geom_relations/disjoint.jl")
include("methods/geom_relations/overlaps.jl")
include("methods/geom_relations/within.jl")
include("methods/polygonize.jl")

include("transformations/extent.jl")
include("transformations/flip.jl")
include("transformations/simplify.jl")
include("transformations/reproject.jl")
include("transformations/simplify.jl")
include("transformations/tuples.jl")
include("transformations/transform.jl")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 0 additions & 64 deletions test/methods/bools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,68 +50,4 @@ import GeometryOps as GO
poly = GI.Polygon([[[-81, 41], [-81, 47], [-72, 47], [-72, 41], [-81, 41]]])

@test point_in_polygon(pt, poly) == true

poly3 = GI.Polygon([[(1, 1), (1, 10), (10, 10), (10, 1), (1, 1)]])
poly4 = GI.Polygon([[(1, 1), (2, 2), (3, 2), (1, 1)]])
line5 = GI.LineString([(1.0, 1.0), (2.0, 3.0), (2.0, 3.5)])

line6 = GI.LineString([(1.0, 1.0), (1.0, 2.0), (1.0, 3.0), (1.0, 4.0)])
poly5 = GI.Polygon([[(1.0, 1.0), (1.0, 20.0), (1.0, 3.0), (1.0, 4.0), (1.0, 1.0)]])
line7 = GI.LineString([(1.0, 2.0), (1.0, 3.0), (1.0, 3.5)])

@test GO.contains(poly3, poly4) == true
@test GO.contains(poly3, line5) == true
@test GO.contains(line6, (1, 2)) == true
@test GO.contains(poly3, poly5) == false
@test GO.contains(poly3 , line7) == false

@test GO.within(poly4, poly3) == true
@test GO.within(line5, poly3) == true
@test GO.within(poly5, poly3) == false
@test GO.within((1, 2), line6) == true
@test GO.within(line7, poly3) == false

poly6 = GI.Polygon([[(-11, -12), (-13, -12), (-13, -13), (-11, -13), (-11, -12)]])
poly7 = GI.Polygon([[(-1, 2), (3, 2), (3, 3), (-1, 3), (-1, 2)]])
poly8 = GI.Polygon([[(-1, 2), (-13, -12), (-13, -13), (-11, -13), (-1, 2)]])

@test GO.disjoint(poly7, poly6) == true
@test GO.disjoint(poly7, (1, 1)) == true
@test GO.disjoint(poly7, GI.LineString([(0, 0), (12, 2), (12, 3), (12, 4)])) == true
@test GO.disjoint(poly8, poly7) == false

line8 = GI.LineString([(124.584961, -12.768946), (126.738281, -17.224758)])
line9 = GI.LineString([(123.354492, -15.961329), (127.22168, -14.008696)])

@test all(GO.intersection(line8, line9)[1] .≈ (125.583754, -14.835723))

line10 = GI.LineString([
(142.03125, -11.695273),
(138.691406, -16.804541),
(136.40625, -14.604847),
(135.966797, -12.039321),
(131.308594, -11.436955),
(128.232422, -15.36895),
(125.947266, -13.581921),
(121.816406, -18.729502),
(117.421875, -20.632784),
(113.378906, -23.402765),
(114.169922, -26.667096),
])
line11 = GI.LineString([
(117.861328, -15.029686),
(122.124023, -24.886436),
(132.583008, -22.309426),
(132.890625, -7.754537),
])

points = GO.intersection(line10, line11)
@test all(points[1] .≈ (119.832884, -19.58857))
@test all(points[2] .≈ (132.808697, -11.6309378))

@test GO.crosses(GI.LineString([(-2, 2), (4, 2)]), line6) == true
@test GO.crosses(GI.LineString([(0.5, 2.5), (1.0, 1.0)]), poly7) == true
@test GO.crosses(GI.MultiPoint([(1, 2), (12, 12)]), GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)])) == true
@test GO.crosses(GI.MultiPoint([(1, 0), (12, 12)]), GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)])) == false
@test GO.crosses(GI.LineString([(-2, 2), (-4, 2)]), poly7) == false
end
Loading

0 comments on commit 35a3f43

Please sign in to comment.