Skip to content

Tree based acceleration for polygon clipping / boolean ops #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5a38180
include LoopStateMachine and STI
asinghvi17 Mar 4, 2025
837b080
Implement natural indexing from `tg`
asinghvi17 Mar 4, 2025
2387291
Implement `foreach_pair_of_maybe_intersecting_edges_in_order`
asinghvi17 Mar 4, 2025
2932b2a
Test all single accelerators in poly clipping tests
asinghvi17 Mar 4, 2025
c002b6e
Move imports to main file
asinghvi17 Mar 14, 2025
c8fe71a
Add comments to naturalindexing and clean up
asinghvi17 Mar 14, 2025
5bf1184
Adapt to refactor of SpatialTreeInterface
asinghvi17 Apr 20, 2025
73d66bf
add `isspatialtree` to NaturalIndexing
asinghvi17 Apr 20, 2025
7c54be8
add tests for NaturalIndex in SpatialTreeInterface tests
asinghvi17 Apr 20, 2025
b2bb3be
Rename NaturalTree -> NaturalIndex and fix typos everywhere
asinghvi17 May 1, 2025
52d42e9
Fix minor stupidity in singlestr implementation
asinghvi17 May 10, 2025
1c24e83
make it easier to tell where errors are happening
asinghvi17 May 10, 2025
56348cf
fix multiple type declarations
asinghvi17 May 10, 2025
8308ae7
Fix doc build error
asinghvi17 May 10, 2025
7468796
fix dual type declarations, again
asinghvi17 May 10, 2025
8a5a12f
actually fix dual type declarations
asinghvi17 Jul 23, 2025
556372c
add spatial index building gif
asinghvi17 Jul 26, 2025
d0dfef4
Rationalize test helper codegen
asinghvi17 Jul 26, 2025
1f924da
Comment out shapefile tests since it's broken somehow
asinghvi17 Jul 26, 2025
df8094f
Handle empty geoms in archgdal and gb by no op
asinghvi17 Jul 26, 2025
d9d59f4
Clean up comment
asinghvi17 Jul 26, 2025
d81140c
Multiple dispatchify all the intersection accelerators
asinghvi17 Jul 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/src/experiments/spatial_index_building.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using CairoMakie
import GeoInterface as GI, GeometryOps as GO
using NaturalEarth


using GeometryOps.SpatialTreeInterface
import GeometryOps.SpatialTreeInterface as STI
using SortTileRecursiveTree

function build_spatial_index_gif(geom, index_constructor, filename; plot_leaves = true, title = splitext(filename)[1], axis = (;), figure = (;), record = (;))
fig = Figure(; figure...)
ax = Axis(fig[1, 1]; title = title, axis...)

# Create a spatial index
index = index_constructor(geom)
ext = STI.node_extent(index)
limits!(ax, ext.X[1], ext.X[2], ext.Y[1], ext.Y[2])

rects = Rect2f[Rect2f((NaN, NaN), (NaN, NaN))]
colors = RGBAf[to_color(:transparent)]
palette = Makie.wong_colors(0.7)

plt = poly!(ax, rects; color = colors)

to_rect2(extent) = Rect2f((extent.X[1], extent.Y[1]), (extent.X[2] - extent.X[1], extent.Y[2] - extent.Y[1]))

function dive_in(io, plt, node, level)
if STI.isleaf(node) && plot_leaves
push!(rects, to_rect2(STI.node_extent(node)))
push!(colors, palette[level])
else
for child in STI.getchild(node)
dive_in(io, plt, child, level + 1)
end
push!(rects, to_rect2(STI.node_extent(node)))
push!(colors, palette[level])
end
update!(plt, rects; color = colors)
recordframe!(io)
return
end

Makie.record(fig, filename; record...) do io
empty!(rects)
empty!(colors)
dive_in(io, plt, index, 1)
end

end
10 changes: 10 additions & 0 deletions src/GeometryOps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ export TraitTarget, Manifold, Planar, Spherical, Geodesic, apply, applyreduce, f
using GeoInterface
using LinearAlgebra, Statistics

using StaticArrays

import Tables, DataAPI
import StaticArrays
import DelaunayTriangulation # for convex hull and triangulation
import ExactPredicates
import Base.@kwdef
import GeoInterface.Extents: Extents
import SortTileRecursiveTree
import SortTileRecursiveTree: STRtree

const GI = GeoInterface

Expand All @@ -43,6 +47,12 @@ include("utils/SpatialTreeInterface/SpatialTreeInterface.jl")

using .LoopStateMachine, .SpatialTreeInterface

include("utils/NaturalIndexing.jl")
using .NaturalIndexing


# Load utility modules in
using .NaturalIndexing, .SpatialTreeInterface, .LoopStateMachine

include("methods/angles.jl")
include("methods/area.jl")
Expand Down
Loading
Loading