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

turf-isobands

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-isobands - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

bench.js

99

index.js
//https://github.com/jasondavies/conrec.js
//http://stackoverflow.com/questions/263305/drawing-a-topographical-map
var tin = require('turf-tin')
var inside = require('turf-inside')
var grid = require('turf-grid')
var extent = require('turf-extent')
var planepoint = require('turf-planepoint')
var featurecollection = require('turf-featurecollection')
var linestring = require('turf-linestring')
var polygon = require('turf-polygon')
var point = require('turf-point')
var square = require('turf-square')
var size = require('turf-size')
var tin = require('turf-tin');
var inside = require('turf-inside');
var grid = require('turf-grid');
var extent = require('turf-extent');
var planepoint = require('turf-planepoint');
var featurecollection = require('turf-featurecollection');
var linestring = require('turf-linestring');
var polygon = require('turf-polygon');
var point = require('turf-point');
var square = require('turf-square');
var size = require('turf-size');

@@ -18,45 +18,40 @@ module.exports = function(points, z, resolution, breaks){

if (typeof addEdgesResult === 'Error') {
done(addEdgesResult);
return addEdgesResult;
}
var tinResult = tin(points, z);
var extentBBox = extent(points);
var squareBBox = square(extentBBox);
var gridResult = grid(squareBBox, resolution);
var data = [];
var tinResult = tin(points, z)
var extentBBox = extent(points)
var squareBBox = square(extentBBox)
var gridResult = grid(squareBBox, resolution)
var data = []
gridResult.features.forEach(function(pt){
tinResult.features.forEach(function(triangle){
if (inside(pt, triangle)) {
pt.properties = {}
pt.properties = {};
pt.properties[z] = planepoint(pt, triangle);
}
})
});
if(!pt.properties){
pt.properties = {}
pt.properties[z] = -100
pt.properties = {};
pt.properties[z] = -100;
}
})
});
var depth = Math.sqrt(gridResult.features.length)
var depth = Math.sqrt(gridResult.features.length);
for (var x=0; x<depth; x++){
var xGroup = gridResult.features.slice(x * depth, (x + 1) * depth)
var xFlat = []
var xGroup = gridResult.features.slice(x * depth, (x + 1) * depth);
var xFlat = [];
xGroup.forEach(function(verticalPoint){
if(verticalPoint.properties){
xFlat.push(verticalPoint.properties[z])
xFlat.push(verticalPoint.properties[z]);
} else{
xFlat.push(0)
xFlat.push(0);
}
})
data.push(xFlat)
data.push(xFlat);
}
var interval = (squareBBox[2] - squareBBox[0]) / depth
var xCoordinates = []
var yCoordinates = []
var interval = (squareBBox[2] - squareBBox[0]) / depth;
var xCoordinates = [];
var yCoordinates = [];
for (var x=0; x<depth; x++){
xCoordinates.push(x * interval + squareBBox[0])
yCoordinates.push(x * interval + squareBBox[1])
xCoordinates.push(x * interval + squareBBox[0]);
yCoordinates.push(x * interval + squareBBox[1]);
}

@@ -67,29 +62,29 @@

if(num === 0){
return .01
return .01;
}
else{
return num
return num;
}
})
//deduplicate breaks
breaks = unique(breaks)
breaks = unique(breaks);
var c = new Conrec
c.contour(data, 0, resolution, 0, resolution, xCoordinates, yCoordinates, breaks.length, breaks)
var contourList = c.contourList()
var c = new Conrec;
c.contour(data, 0, resolution, 0, resolution, xCoordinates, yCoordinates, breaks.length, breaks);
var contourList = c.contourList();
var fc = featurecollection([])
var fc = featurecollection([]);
contourList.forEach(function(c){
if(c.length > 2){
var polyCoordinates = []
var polyCoordinates = [];
c.forEach(function(coord){
polyCoordinates.push([coord.x, coord.y])
})
var poly = polygon([polyCoordinates])
poly.properties = {}
poly.properties[z] = c.level
polyCoordinates.push([coord.x, coord.y]);
});
var poly = polygon([polyCoordinates]);
poly.properties = {};
poly.properties[z] = c.level;
fc.features.push(poly)
fc.features.push(poly);
}
})
});

@@ -96,0 +91,0 @@ return fc;

{
"name": "turf-isobands",
"version": "0.1.1",
"version": "1.0.0",
"description": "turf isobands module",

@@ -29,17 +29,18 @@ "main": "index.js",

"devDependencies": {
"tape": "^2.13.4"
"benchmark": "^1.0.0",
"tape": "^3.0.3"
},
"dependencies": {
"turf-extent": "^0.1.4",
"turf-featurecollection": "^0.1.0",
"turf-extent": "^1.0.0",
"turf-featurecollection": "^1.0.0",
"turf-grid": "0.1.0",
"turf-inside": "^0.1.4",
"turf-linestring": "^0.1.1",
"turf-inside": "^1.1.2",
"turf-linestring": "^1.0.0",
"turf-planepoint": "0.1.0",
"turf-point": "^0.1.1",
"turf-polygon": "^0.1.1",
"turf-size": "^0.1.3",
"turf-square": "^0.1.3",
"turf-point": "^1.2.0",
"turf-polygon": "^1.0.0",
"turf-size": "^1.1.0",
"turf-square": "^1.0.0",
"turf-tin": "0.1.0"
}
}

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

var test = require('tape')
var fs = require('fs')
var isobands = require('./')
var test = require('tape');
var fs = require('fs');
var isobands = require('./');
test('isobands', function(t){
var points = JSON.parse(fs.readFileSync(__dirname+'/geojson/Points.geojson'))
var points = JSON.parse(fs.readFileSync(__dirname+'/geojson/Points.geojson'));
var isobanded = isobands(points, 'elevation', 15, [5, 45, 55, 65, 85, 95, 105, 120, 180], false)
var isobanded = isobands(points, 'elevation', 15, [5, 45, 55, 65, 85, 95, 105, 120, 180], false);
t.ok(isobanded.features, 'should take a set of points with z values and output a set of filled contour polygons')
t.equal(isobanded.features[0].geometry.type, 'Polygon')
t.ok(isobanded.features, 'should take a set of points with z values and output a set of filled contour polygons');
t.equal(isobanded.features[0].geometry.type, 'Polygon');
fs.writeFileSync(__dirname+'/geojson/isobands.geojson', JSON.stringify(isobanded))
t.end()
fs.writeFileSync(__dirname+'/geojson/isobands.geojson', JSON.stringify(isobanded));
t.end();
})
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