Custom data format for search/collide
simast opened this issue · comments
Hi,
This is an amazing lib, thanks for working on this!
I just upgraded to 2.0 and noticed that search/collide methods seem to always accept input with only the new minX/minY/maxX/maxY data format properties. Would it make sense to support custom data formats here for consistency?
I considered this but decided against that. For example imagine a situation where you set format to ['[0]', '[1]', '[0]', '[1]']
to support points of [x, y]
format. If search
used that format for the argument, how would you search a bounding box? It would be converted to a point by the format. So you would have to specify two different formats, one for the items, and another for search/collide methods. I think this is too confusing. And the current approach seems pretty OK too.
Another situation: you have a custom format where bouding box is in a .bbox
property of an object. Then you would have to search using dummy objects like this, which is pretty inconvenient:
tree.search({
bbox: ...
});
Yes, as I was suggesting this I thought the array example would cause some issues :) I understand that, it's a minor issue. It can get a bit confusing tho if you use custom formats with a coordinate space that is not X/Y, but X/Z for example.