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

closest-feature

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

closest-feature

find the closest geojson feature (or the one the point is inside) from a point

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

closest-feature

About

Measure distances

NPM

npm install --save closest-feature

YARN

yarn add closest-feature

Use

// ES6
import closest from 'closest-feature';
// older
const closest = require('closest-feature').default;

let features = [
  { "type": "Feature", "properties": { "COUNTYNBR": "18", "NAME": "Herriman", "COUNTYSEAT": 0, "SHORTDESC": "HERRIMAN TOWN", "UPDATED": "2016\/09\/02", "FIPS": "34970", "ENTITYNBR": 3035, "SALESTAXID": "060", "IMSCOLOR": 1, "MINNAME": null, "POPLASTCEN": 22018, "POPLASTEST": 30835, "GNIS": "1428675", "Shape_Leng": 57216.656373500002, "Shape_Area": 55755135.693899997 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -111.999923241180639, 40.536929968126046 ],
  ...
  [ -111.999923241180639, 40.536929968126046 ] ] ] } },

  { "type": "Feature", "properties": { "COUNTYNBR": "18", "NAME": "Riverton", "COUNTYSEAT": 0, "SHORTDESC": "RIVERTON", "UPDATED": "2016\/09\/02", "FIPS": "64340", "ENTITYNBR": 3060, "SALESTAXID": "118", "IMSCOLOR": 2, "MINNAME": null, "POPLASTCEN": 39330, "POPLASTEST": 41900, "GNIS": "1431862", "Shape_Leng": 34602.250230700003, "Shape_Area": 32683657.6131 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -111.999080957488104, 40.523382315465085 ],
  ...
  [ -111.999080957488104, 40.523382315465085 ] ] ] } }
];

let props = closest([-112.09698739755993, 40.49797074565671], features);

console.log(props === features[0].properties) // true

ISC License (ISC)

Copyright 2017 Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") Copyright (c) 1995-2003 by Internet Software Consortium

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

FAQs

Package last updated on 25 Jan 2018

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