Skip to content

Latest commit

 

History

History
49 lines (30 loc) · 1.03 KB

README.md

File metadata and controls

49 lines (30 loc) · 1.03 KB

indexed-geo

Indexed geospatial functions for Node.js, built using Turf, rbush and rbush-knn.

Installation & Usage

Installation:

npm install nypl-spacetime/indexed-geo

Usage:

const IndexedGeo = require('indexed-geo')

const polygons = JSON.parse(fs.readFileSync('polygons.geojson'))

const point = {
  type: 'Point',
  coordinates: [
    -73.954875,
    40.733697
  ]
}

const indexedGeo = IndexedGeo()
indexedGeo.index(polygons)

const results = indexedGeo.intersects(point)
// results now contains all the polygons intersecting with point

API

index(geojson)

Indexes GeoJSON object.

search(point)

Searches the index and returns all objects of which the bounding box intersects with point.

inside(point)

Finds all indexed objects which intersect point.

nearest(point, k, filterFn)

Finds k nearest neighbors. See rbush-knn's documentation for details.