Skip to content

Implement SpatialTreeInterface for packed R-tree#12

Draft
repro-code wants to merge 1 commit into
evetion:masterfrom
repro-code:spatial-tree-interface
Draft

Implement SpatialTreeInterface for packed R-tree#12
repro-code wants to merge 1 commit into
evetion:masterfrom
repro-code:spatial-tree-interface

Conversation

@repro-code

Copy link
Copy Markdown

Summary

  • Add PackedRTree and PackedRTreeNode types that provide a hierarchical view over the flat-packed R-tree array
  • Implement the SpatialTreeInterface from GeometryOps.jl, enabling generic spatial tree algorithms
  • Rewrite filter!/search to use the new interface via depth-first search
  • Preserve backwards-compatible legacy search function

Details

The implementation introduces:

New types in packedrtree.jl:

  • PackedRTree{T,V} - wrapper around the flat array with tree metadata
  • PackedRTreeNode{T,V} - lightweight view into a single node

SpatialTreeInterface methods:

  • isspatialtree - predicate for spatial tree types
  • isleaf - check if node is a leaf
  • getchild / nchild - access children
  • child_indices_extents - iterator over (index, extent) for leaves
  • node_extent - bounding box of a node

Generic algorithms:

  • depth_first_search(f, predicate, tree) - DFS with predicate filtering
  • query(tree, predicate) - returns matching feature offsets

The interface is designed to be generic over node element types (not just NodeItem), allowing reuse for other packed R-tree implementations.

Test plan

  • Existing tests pass (verified locally)
  • Integration with GeometryOps.SpatialTreeInterface (when both packages loaded)

🤖 Generated with Claude Code

Add PackedRTree and PackedRTreeNode types that provide a hierarchical view
over the flat-packed R-tree array. This implements the SpatialTreeInterface
from GeometryOps.jl, enabling generic spatial tree algorithms.

Key changes:
- New packedrtree.jl with PackedRTree wrapper types
- Implements isspatialtree, isleaf, getchild, nchild, child_indices_extents,
  node_extent interface methods
- Includes generic depth_first_search and query functions
- Rewrite filter!/search to use the new interface
- Backwards-compatible legacy search function preserved

The interface is designed to be generic over node element types, not just
NodeItem, allowing reuse for other packed R-tree implementations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant