mourner / geokdbush

The fastest spatial index for geographic locations in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

geokdbush fails where kdbush.within succeedes

ilblog opened this issue · comments

We use kdbush index and used kdbush.within for a lot of time. Recently we started to use geokdbush and it sometimes failed to find the NN on some locations (especially the ones that were really very close). We have used 50.000 set with lat,lons and I was unable to replicate where it failed, but was unable to trace the error inside the lib (since chrome dev tools killed my CPU when trying to investigate content of index).

I am sure kdbush index was correct and contained all the points since kdbush worked fine.

We switched back to kdbush.within and all is ok now.

If you find it useful I can send you the data set for investigation and piece of code but I consider kdbush.within to be much faster.

@ilblog sure, send in the data — I could try stress-testing it. There's no way to fix this without finding a failing test case.

Regarding kdbush.within vs geokdbush — the latter is supposed to be slower because it uses great circle (real geographic) distances, while within uses simple Euclidean ones. So kdbush.within is much less accurate for locations, especially with big distances, and doesn't handle dateline wrapping and distances over poles. It's a tradeoff of accuracy vs performance.

@ilblog any chance for a test case, or data I could try to reproduce on?

No reproducible test case, so have to close this.