How KDBush works: Static 2D Spatial Indexing
mainKDBush is a high-performance, static spatial index for 2D points based on a flat KD-tree.
Key Characteristics:
- Points Only: Unlike RBush, it does not support rectangles.
- Static: Once you call
index.finish(), you cannot add or remove items. This allows for a highly optimized, compact memory footprint. - Memory Efficient: The index is stored as a single
ArrayBuffer, making it extremely fast to transfer between threads (usingpostMessage) or to save to a file. - Performance: It offers faster indexing and search with lower memory usage compared to RBush or Flatbush (when indexing points).