• Stars
    star
    334
  • Rank 126,264 (Top 3 %)
  • Language
    JavaScript
  • License
    ISC License
  • Created over 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The fastest spatial index for geographic locations in JavaScript

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 in kilometers to search within (Infinity by default).
  • filterFn: (optional) a function to filter the results with.

geokdbush.distance(longitude1, latitude1, longitude2, latitude2)

Returns great circle distance between two locations in kilometers.

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 967ms n/a
query 1000 closest 4ms 4ms 155ms
query 50000 closest 31ms 368ms 155ms
query all 138398 80ms 29.7s 155ms
1000 queries of 1 55ms 165ms 18.4s

More Repositories

1

suncalc

A tiny JavaScript library for calculating sun/moon positions and phases.
JavaScript
3,056
star
2

rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
JavaScript
2,411
star
3

simplify-js

High-performance JavaScript polyline simplification library
JavaScript
2,274
star
4

bullshit.js

A bookmarklet for translating marketing speak into human-readable text. 💩
JavaScript
1,846
star
5

flatbush

A very fast static spatial index for 2D points and rectangles in JavaScript 🌱
JavaScript
1,404
star
6

simpleheat

A tiny JavaScript library for drawing heatmaps with Canvas
JavaScript
927
star
7

dead-simple-grid

Dead Simple Grid is a responsive CSS grid micro framework that is just that. Dead simple.
HTML
747
star
8

kdbush

A fast static index for 2D points
JavaScript
618
star
9

tinyqueue

The smallest and simplest priority queue in JavaScript.
JavaScript
428
star
10

projects

A list of awesome open source projects Volodymyr Agafonkin is involved in.
410
star
11

robust-predicates

Fast robust predicates for computational geometry in JavaScript
JavaScript
296
star
12

road-orientation-map

A visualization of road orientations on an interactive map
JavaScript
295
star
13

rbush-knn

k-nearest neighbors search (KNN) for RBush
JavaScript
207
star
14

delaunator-rs

Fast 2D Delaunay triangulation in Rust. A port of Delaunator.
Rust
201
star
15

tinyjam

A radically simple, zero-configuration static site generator in JavaScript
JavaScript
153
star
16

flatqueue

A very fast and simple JavaScript priority queue
JavaScript
133
star
17

quickselect

A fast selection algorithm in JavaScript.
JavaScript
82
star
18

seidel

[DEPRECATED] A JS polygon triangulation library
JavaScript
82
star
19

icomesh

Fast JavaScript icosphere mesh generation library for WebGL visualizations
JavaScript
53
star
20

bbtree

Self-balancing Binary Search Trees in JavaScript
JavaScript
49
star
21

yeahjs

A tiny, modern, fast EJS templating library
JavaScript
45
star
22

geoflatbush

Geographic kNN extension for Flatbush
JavaScript
43
star
23

kdbush.hpp

A fast static spatial index for 2D points in C++11
C++
33
star
24

worker-data-load

A test that shows the benefit of loading large amounts of data directly in a worker instead of a page.
JavaScript
33
star
25

Leaflet.TouchHover

A plugin for adding hover-like interaction to Leaflet maps on mobile devices
JavaScript
27
star
26

eslint-config-mourner

A strict ESLint config for my JavaScript projects
JavaScript
19
star
27

suncalc-go

SunCalc written in Go
Go
18
star
28

yeahml

A tiny subset of YAML for JavaScript
JavaScript
8
star
29

serenity-tm

Serenity is a light, minimal syntax highlighting theme for Sublime Text and Textmate.
8
star
30

pbf-split

Splits a Node stream of protocol buffer messages
JavaScript
7
star
31

hello-lib

Simple boilerplate for my small JS libraries.
JavaScript
7
star
32

color-metrics

JavaScript
6
star
33

agafonkin.com

My little personal page
HTML
5
star
34

fanny

A simple and fast multilayer feedforward neural network implementation in JS, made for learning purposes.
JavaScript
5
star
35

hain

Hain triangulation algorithm in JS (work in progress)
C++
4
star
36

mourner

2
star
37

mourner.github.com

Nothing here yet.
1
star