Library decision: RBush

RBush was selected as the spatial indexing library for the plant layer.

The main reason is that the current use case requires querying two-dimensional bounding boxes. Each planting can be represented by a rectangular bounding box, and the visible viewport is also represented as a bounding box. RBush directly supports this type of query and is designed for efficient 2D spatial indexing of points and rectangles.

Other libraries were considered:

  • Flatbush is also suitable for 2D bounding-box queries and can be very fast, but it is mainly intended for static indexes. This makes it less flexible for map elements that may be added, moved, transformed, or deleted during editing.
  • KDBush is efficient for indexing points, but it is less suitable here because plantings are represented as rectangular areas rather than only point coordinates.
  • Larger geometry libraries such as JSTS provide more advanced geometry operations, but they would add more complexity than necessary for this specific use case.

RBush is small, focused on the required problem, available under the MIT license, and provides the needed functionality without introducing a larger geometry-processing dependency