Skip to content

lib/octree: Added octree library - #7324

Open
cwhite911 wants to merge 13 commits into
OSGeo:mainfrom
cwhite911:octree
Open

cwhite911 wants to merge 13 commits into
OSGeo:mainfrom
cwhite911:octree

Conversation

@cwhite911

@cwhite911 cwhite911 commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Added a new lib/octree/ spatial indexing library for 3D points. The octree recursively subdivides space into octants with adaptive subdivision and a depth limit for coincident points. It supports point insertion, axis-aligned range queries, depth-limited traversal, cached subtree point counts, and subtree centroids.

The areas I was thinking about when writing this are, but I'm sure there are many other use cases as well.

  • LiDAR ingest (v.in.pdal)
  • v.vol.rst
  • spatial decimation (v.decimate)
  • level-of-detail (LOD) rendering of point clouds in the NVIZ GUI, where loading everything into memory currently bogs the system down.

@cwhite911 cwhite911 self-assigned this Apr 17, 2026
@github-actions github-actions Bot added CI Continuous integration C Related code is in C libraries docs tests Related to Test Suite CMake labels Apr 17, 2026
@petrasovaa

Copy link
Copy Markdown
Contributor

Are you using it for something specific now? Do you plan to integrate the library into one of the suggested tools?

@petrasovaa petrasovaa closed this Apr 17, 2026
@petrasovaa petrasovaa reopened this Apr 17, 2026
@metzm

metzm commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

How about adding some id to OctreePoint3D? With such an id, it would be easy to retrieve the corresponding points together with any attributes from the actual points vector when querying the octree. Or is this covered with any provided user_data?

@cwhite911

Copy link
Copy Markdown
Contributor Author

How about adding some id to OctreePoint3D? With such an id, it would be easy to retrieve the corresponding points together with any attributes from the actual points vector when querying the octree. Or is this covered with any provided user_data?

@metzm you're right, user_data doesn't cover it. It's a per-query callback parameter, not a per-point attribute, so there was no way to map a queried point back to its source. I added a caller-defined grass_int64 id to OctreePoint3D that can be set to a vector cat or a source index or leave it OCTREE_NO_ID.

@cwhite911 cwhite911 mentioned this pull request Jun 5, 2026
@cwhite911
cwhite911 requested a review from petrasovaa July 14, 2026 15:37
@echoix echoix added the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Jul 17, 2026
@echoix echoix removed the conflicts/needs rebase Rebase to or merge with the latest base branch is needed label Jul 17, 2026
@cwhite911

Copy link
Copy Markdown
Contributor Author

Are you using it for something specific now? Do you plan to integrate the library into one of the suggested tools?

Yes. The octree will be used for new 3D tiling capabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C CI Continuous integration CMake docs libraries tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants