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 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

lib/index.js

@@ -1,1 +0,1 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.default=closest;var _pointInPolygon=require('point-in-polygon');var _pointInPolygon2=_interopRequireDefault(_pointInPolygon);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function closest(point,features){var distance=Infinity;var result={};features.some(function(feature){if((0,_pointInPolygon2.default)(point,feature.geometry.coordinates[0])){result=feature.properties;return true}else{feature.geometry.coordinates[0].forEach(function(coord){var d=Math.abs(Math.pow(point[0]-coord[0],2)+Math.pow(point[1]-coord[1],2));if(d<distance){distance=d;result=feature.properties}})}});return result}
'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.default=closest;var _pointInPolygon=require('point-in-polygon');var _pointInPolygon2=_interopRequireDefault(_pointInPolygon);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function closest(point,features){var distance=Infinity;var result={};features.some(function(feature){if(feature.geometry.type==='MultiPolygon'){feature.geometry.type='Polygon';feature.geometry.coordinates=feature.geometry.coordinates[0]}if((0,_pointInPolygon2.default)(point,feature.geometry.coordinates[0])){result=feature.properties;return true}else{feature.geometry.coordinates[0].forEach(function(coord){var d=Math.abs(Math.pow(point[0]-coord[0],2)+Math.pow(point[1]-coord[1],2));if(d<distance){distance=d;result=feature.properties}})}});return result}
{
"name": "closest-feature",
"version": "1.0.1",
"version": "1.0.2",
"description": "find the closest geojson feature (or the one the point is inside) from a point",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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