JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 38934
  • Score
    100M100P100Q147831F
  • License ISC

Package Exports

  • geokdbush

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (geokdbush) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

geokdbush Build Status

A geographic extension for kdbush, the fastest static spatial index for points in JavaScript.

It implements fast nearest neighbors queries for locations on Earth, taking Earth curvature and date line wrapping into account. Inspired by sphere-knn, but uses a different algorithm.

Example

var kdbush = require('kdbush');
var geokdbush = require('geokdbush');

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

var nearest = geokdbush.around(index, -119.7051, 34.4363, 1000);

API

geokdbush.around(index, longitude, latitude[, maxResults, maxDistance, filterFn])

Returns an array of the closest points from a given location in order of increasing distance.

  • index: kdbush index.
  • longitude: query point longitude.
  • latitude: query point latitude.
  • maxResults: (optional) maximum number of points to return (Infinity by default).
  • maxDistance: (optional) maximum distance to search within (Infinity by default).
  • filterFn: (optional) a function to filter the results with.

Performance

This library is incredibly fast. The results below were obtained with npm run bench (Node v7.7.2, Macbook Pro 15 mid-2012).

benchmark geokdbush sphere-knn naive
index 138398 points 69ms 1027ms n/a
query 1000 closest 4ms 5ms 155ms
query 50000 closest 31ms 391ms 155ms
query all 138398 80ms 29.9s 155ms
1000 queries of 1 123ms 169ms 18.4s