JSPM

oh-snap

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q23247F
  • License MIT

Snap points to the nearest point in a GeoJSON collection of points.

Package Exports

  • oh-snap

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 (oh-snap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

oh-snap

Snap points to nearest point in a different set.

Installation

Install via npm:

npm install oh-snap

Usage

snap(points,snapTo[,maxDistance])

points is a GeoJSON feature collection of points.

snapTo is another GeoJSON feature collection of points.

maxDistance is an optional maximum distance, in meters (the default is no maximum). If specified, a point in points will only be counted as being at the nearest point in snapTo if it's less than maxDistance meters away.

Example

Let's say you have a GeoJSON collection of points where car crashes happened, and a GeoJSON collection of points for intersections, and you want to get a list of intersections with the number of crashes at/near each.

var snap = require("oh-snap");

//crashes is a GeoJSON FeatureCollection of points
//intersections is another GeoJSON FeatureCollection of points

var result = snap(crashes,intersections);

result will be another GeoJSON FeatureCollection with the same points as intersections. Each one will have one new property, called snapped:

snapped: {
  count: 4,
  details: [{...},{...},{...},{...}]
}

That means 4 points in crashes were closest to this intersection. details is an array of those four crashes' properties, in case you want it.