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

turf-convex

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-convex - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

60

index.js

@@ -1,30 +0,46 @@

// 1. run tin on points
// 2. merge the tin
//var topojson = require('')
var t = {}
t.tin = require('turf-tin')
t.merge = require('turf-merge')
t.buffer = require('turf-buffer')
// http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript
module.exports = function(points, done){
var tinPolys = t.tin(points, null),
mergePolys;
module.exports = function(fc){
var points = fc.features.map(function(point){
return point.geometry.coordinates
})
done = done || function () {};
points.sort(function(a, b) {
return a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]
})
if (tinPolys instanceof Error) {
done(tinPolys);
return tinPolys;
var lower = []
for (var i = 0; i < points.length; i++) {
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], points[i]) <= 0) {
lower.pop()
}
lower.push(points[i])
}
//mergePolys = t.merge(t.buffer(tinPolys, .05, 'miles'));
mergePolys = t.merge(tinPolys);
var upper = []
for (var i = points.length - 1; i >= 0; i--) {
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], points[i]) <= 0) {
upper.pop()
}
upper.push(points[i])
}
if (mergePolys instanceof Error) {
done(mergePolys);
} else {
done(null, mergePolys);
upper.pop()
lower.pop()
var coords = lower.concat(upper)
coords.push(coords[0])
return {
type:'Feature',
properties: {},
geometry: {
type:'Polygon',
coordinates: [
coords
]
}
}
}
return mergePolys;
}
function cross(o, a, b) {
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
}
{
"name": "turf-convex",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -30,7 +30,3 @@ "main": "index.js",

},
"dependencies": {
"turf-tin": "0.0.2",
"turf-buffer": "0.1.0",
"turf-merge": "0.0.2"
}
"dependencies": {}
}

@@ -6,3 +6,3 @@ var convex = require('../'),

var REGEN = false;
var REGEN = true;

@@ -9,0 +9,0 @@ test('intersect', function(t){

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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