Coder Social home page Coder Social logo

mourner / geokdbush Goto Github PK

View Code? Open in Web Editor NEW
331.0 13.0 36.0 27 KB

The fastest spatial index for geographic locations in JavaScript

License: ISC License

JavaScript 100.00%
earth spatial-index algorithm javascript awesome fast computational-geometry

geokdbush's Introduction

Stand with Ukraine

Hi! I'm Volodymyr Agafonkin.

I'm a software engineer. I created Leaflet, the number one library for interactive web maps, and maintain 40+ other open source projects with a focus on algorithms, computational geometry and data visualization. I'm building the future of maps at Mapbox. Here are a few of my best tech articles: https://agafonkin.com

I'm a musician. I write songs, play guitar and sing in Obiymy Doschu. If you like beautiful, evocative rock music with lush string arrangements, check out our last album.

I'm a father to beautiful 9-year-old twin girls, I'm happily married and live in Kyiv, Ukraine. I love baking, photography, strength training, martial arts, reading sci-fi and fantasy, and exploring quiet parks. You can find tidbits of my life on X (Twitter), Instagram and Facebook.

geokdbush's People

Contributors

andrewharvey avatar dependabot[bot] avatar kkdd avatar mourner avatar msfstef avatar msftenhanceprovenance avatar tyrasd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geokdbush's Issues

Better lower bound

The current lower bound of great circle distance from a point to any point inside a bounding box is quickly hacked together and pretty poor. I found this algorithm for computing a proper lower bound, although it's a bit complicated:

image

Will try to implement and see how it goes.

Fix example: kdbush(...) → new kdbush(...)

The code from example doesn't work for me, but when I add the new operator to kdbush, it starts working:

var index = kdbush(points, (p) => p.lon, (p) => p.lat);

should become

var index = new kdbush(points, (p) => p.lon, (p) => p.lat);

geokdbush fails where kdbush.within succeedes

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.

CommonJS and kdbush

Hi @mourner,

First of all, thank you so much for your work on this project. I've tried several libraries, and this is by far the fastest nearby geo library I've used in a few non-commercial projects.

Unfortunately, it's not working anymore due to the lack of CommonJS support in kdbush. I've integrated geokdbush into my web application, which I cannot easily migrate to ESM. It would be different if it was a simple standalone script running on the backend.

If possible, would it be feasible to reintroduce CommonJS support to kdbush and update this library to reflect v4.* of kdbush? That would be greatly appreciated.

Thanks!

compatibility with kdbush 4.x

kdbush 4.x changed the internal interface so that index.points no longer exists, but the latest version of geokdbush still relies on it.

I was able to work around it by manually setting index.points to an array matching what I wanted (lng/lat points).

It might make sense to just return an index.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.