kdbush icon indicating copy to clipboard operation
kdbush copied to clipboard

How to retrieve bounding boxes/generate bounding boxes

Open paddymul opened this issue 2 years ago • 3 comments

I am looking to serialize indexes into smaller chunks for better performance in a KV store. If there are boxes at each tree level, I would like to be able to get the pre-configured bounding box coordinates from the tree root. Then I will construct a kdbush from just those coordinates.

I'm still not 100% clear on the rtree algorithm. If there is a node size of 16, does that mean that the first level has 16 leaves?

I would be happy to use a combination of flatbush and kdbush.

paddymul avatar May 29 '23 10:05 paddymul

I'm a little confused, can you please describe your question in more detail? KDBush is already fully serializable since v4, with the whole index stored as index.data ArrayBuffer which can then be deserialized with KDBush.from(data).

mourner avatar May 29 '23 11:05 mourner

So I want to start with an index of 350k points, this will serialize to an index of approximately 6MB. I want to split this index into separate smaller indexes (hopefully each smaller index can use only a 16bit index, so split it into 8 sub indexes with around 45k points in each). My data, and my application deals with very localized data, so the first step is to find the appropriate localized index, then just work inside of that. I'm guessing I would use Flatbush for the first smaller index, then kdbush for the smaller indexes.

I will be building my app on top of cloudlfare workers, and cloudflare KV. So each request requires downloading a whole index (it doesn't stay resident in memory). Essentially downloading too big an index times out a response.

paddymul avatar May 29 '23 11:05 paddymul

Maybe if you build a temporary global tree, and then descend it while building the final subtree arrays. The global tree could even be done with a different package in different software, if convenient.

phobrain avatar Aug 22 '24 20:08 phobrain