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

turf-explode

Package Overview
Dependencies
Maintainers
9
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-explode - npm Package Compare versions

Comparing version 1.0.1 to 3.0.0-canary.2f5f7167

6

bench.js
global.explode = require('./');
var Benchmark = require('benchmark');
var fs = require('fs');
var polygon = require('turf-polygon');
var point = require('turf-point');
var featurecollection = require('turf-featurecollection');
var polygon = require('turf-helpers').polygon;
var point = require('turf-helpers').point;
var featurecollection = require('turf-helpers').featureCollection;

@@ -8,0 +8,0 @@ global.poly = polygon([[[0,0], [0,10], [10,10] , [10,0]]]);

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

var featureCollection = require('turf-featurecollection');
var featureCollection = require('turf-helpers').featureCollection;
var each = require('turf-meta').coordEach;
var point = require('turf-point');
var point = require('turf-helpers').point;
/**
* Takes any {@link GeoJSON} object and return all positions as
* a {@link FeatureCollection} of {@link Point} features.
* Takes a feature or set of features and returns all positions as
* {@link Point|points}.
*
* @module turf/explode
* @name explode
* @category misc
* @param {GeoJSON} input input features
* @return {FeatureCollection} a FeatureCollection of {@link Point} features representing the exploded input features
* @param {(Feature|FeatureCollection)} input input features
* @return {FeatureCollection<point>} points representing the exploded input features
* @throws {Error} if it encounters an unknown geometry type

@@ -38,8 +38,8 @@ * @example

*/
module.exports = function(layer) {
var points = [];
each(layer, function(coord) {
points.push(point(coord));
});
return featureCollection(points);
module.exports = function (layer) {
var points = [];
each(layer, function (coord) {
points.push(point(coord));
});
return featureCollection(points);
};
{
"name": "turf-explode",
"version": "1.0.1",
"version": "3.0.0-canary.2f5f7167",
"description": "turf explode module",
"main": "index.js",
"scripts": {
"test": "node test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
"test": "node test.js"
},

@@ -29,12 +28,9 @@ "repository": {

"tape": "^3.5.0",
"turf-linestring": "^1.0.1",
"turf-polygon": "^1.0.2",
"dox": "^0.6.1",
"doxme": "^1.4.3"
"geojson-fixtures": "^0.6.1",
"turf-helpers": "^3.0.0-canary.2f5f7167"
},
"dependencies": {
"turf-featurecollection": "^1.0.0",
"turf-meta": "^1.0.2",
"turf-point": "^2.0.0"
"turf-meta": "^3.0.0-canary.2f5f7167",
"turf-helpers": "^3.0.0-canary.2f5f7167"
}
}

@@ -10,4 +10,4 @@ # turf-explode

Takes any GeoJSON object and return all positions as
a FeatureCollection of Point features.
Takes a feature or set of features and returns all positions as
Point|points.

@@ -17,5 +17,5 @@

| parameter | type | description |
| --------- | ------- | -------------- |
| `input` | GeoJSON | input features |
| parameter | type | description |
| --------- | -------------------------- | -------------- |
| `input` | Feature\,FeatureCollection | input features |

@@ -26,11 +26,18 @@

```js
var poly = turf.polygon([[
[177.434692, -17.77517],
[177.402076, -17.779093],
[177.38079, -17.803937],
[177.40242, -17.826164],
[177.438468, -17.824857],
[177.454948, -17.796746],
[177.434692, -17.77517]
]]);
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[
[177.434692, -17.77517],
[177.402076, -17.779093],
[177.38079, -17.803937],
[177.40242, -17.826164],
[177.438468, -17.824857],
[177.454948, -17.796746],
[177.434692, -17.77517]
]]
}
};

@@ -44,2 +51,5 @@ var points = turf.explode(poly);

**Returns** `FeatureCollection.<point>`, points representing the exploded input features
## Installation

@@ -59,1 +69,2 @@

@@ -1,32 +0,2 @@

var test = require('tape');
var polygon = require('turf-polygon');
var linestring = require('turf-linestring');
var point = require('turf-point');
var featurecollection = require('turf-featurecollection');
var explode = require('./index');
test('explode', function(t){
var poly = polygon([[[0,0], [0,10], [10,10], [10,0], [0,0]]]);
var p1 = point([0,0]),
p2 = point([0,10]),
p3 = point([10,10]),
p4 = point([10,0]);
var fc = featurecollection([p1,p2,p3,p4,p1]);
var exploded = explode(poly);
t.ok(exploded.features, 'should take a feature or feature collection and return all vertices');
t.deepEqual(exploded, fc);
t.deepEqual(explode(point([0,0])), featurecollection([point([0,0])]), 'explode a single point');
t.deepEqual(explode(featurecollection([point([0,0])])), featurecollection([point([0,0])]), 'explode a single point in a featurecollection');
t.deepEqual(explode(polygon([[[0,0],[1,1],[0,1],[0,0]]])),
featurecollection([point([0,0]), point([1,1]), point([0,1]), point([0,0])]), 'explode a polygon');
t.deepEqual(explode(linestring([[0,0],[1,1],[0,1],[0,0]])),
featurecollection([point([0,0]), point([1,1]), point([0,1]), point([0,0])]), 'explode a linestring');
t.throws(function() {
explode({});
}, /Unknown Geometry Type/);
t.end();
});
var geojsonFixtures = require('geojson-fixtures/helper');
geojsonFixtures(require('tape'), 'all', require('./'), __dirname + '/test');

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