mourner / kdbush

A fast static index for 2D points

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should range request include all boundaries?

TomasZamecnik opened this issue · comments

Is it intent that range function captures points on both left and right (or top and bottom) boundaries? When I look at argument names (minX, maxX) than this behavior is understandable, but it can lead to bugs when used in map tilification - one point can be assigned in two tiles.

Btw. thank you for great open source libraries!

Tomas Zamecnik
Windy.com

I'm not sure — do you know how other indexing libraries like boost::rtree deal with this? If there's a precedent for treating maxX/Y as exclusive (so that query is [minX...maxX), [minY...maxT)), I could change this quickly, but I'm not sure this is a norm, so want to avoid users confusion.

Meanwhile, could filtering out points that are on two of the four boundaries (e.g. minX and minY) be good enough as a workaround?

I can imagine that both approaches could be useful. Boost rtree can use any predicate. If you use "within" predicate it behaves symmetricaly for minX, maxX and by default excludes both :-)
I think that your approach is good for many cases and is understandable, only for purposes of the tilification it is not sufficient and must be adjusted manually.
Filtering out points on two of four boundaries: yes, I am doing it this way.

Since there's an easy workaround, let's keep things simple for the time being. I'm still open to alternatives though.