Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-nearest

Package Overview
Dependencies
Maintainers
8
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-nearest

turf nearest module

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-4.84%
Maintainers
8
Weekly downloads
 
Created
Source

turf-nearest

build status

turf nearest module

turf.nearest(point, against)

Takes a Point feature and a FeatureCollection of Point features and returns the Point feature from the FeatureCollection closest to the input point.

Parameters

parametertypedescription
pointPointthe reference point
againstFeatureCollectiona FeatureCollection of Point features

Example

var point = turf.point([28.965797, 41.010086]);
point.properties['marker-color'] = '#0f0';
var against = turf.featurecollection([
 turf.point([28.973865, 41.011122]),
 turf.point([28.948459, 41.024204]),
 turf.point([28.938674, 41.013324])
]);

var nearest = turf.nearest(point, against);
nearest.properties['marker-color'] = '#f00';

var result = turf.featurecollection(
  against.features.concat(point));

//=result

Installation

Requires nodejs.

$ npm install turf-nearest

Tests

$ npm test

Keywords

FAQs

Package last updated on 06 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc