Skip to content

Instantly share code, notes, and snippets.

@andrewharvey

andrewharvey/index.md

Last active Jun 13, 2021
Embed
What would you like to do?
Comparison of point and box spatial index libraries for JavaScript
Library Static / Dynamic Cartesian / Geographic kNN Index containing points Index containing boxes Within radius
rbush dynamic 🗺️ cartesian ❌ ✔️ ✔️ ❌
rbush-knn dynamic 🗺️ cartesian ✔️ ✔️ ✔️ ✔️
kdbush static 🗺️ cartesian ❌ ✔️ ❌ ✔️
geokdbush static 🌏 geo ✔️ ✔️ ❌ ✔️
flatbush static 🗺️ cartesian ✔️ ✔️ ✔️ ✔️
geoflatbush static 🌏 geo ✔️ ✔️ ✔️ ✔️

Definitions:

  • Static: All items must be added to the index initially, they cannot be modified once initialised.
  • Dynamic: Items in the index can be added and removed at any time
  • Cartesian: Operations an x, y Cartesian coordinates.
  • Geographic: Operations on geographic coordinates, lng, lat on a spheroid earth accounting for curvature of the earth and wrapping around the dateline.
  • kNN: Find the k (arbitrary number) of items closest to the query point
  • Index containing points: The index can contain points as items.
  • Index containing boxes: The index can contain rectangles or bounding boxes as items.
  • Within radius: Find all the items within a distance of the query point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment