turf-explode
Advanced tools
Comparing version 1.0.1 to 3.0.0-canary.2f5f7167
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]]]); |
26
index.js
@@ -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 @@ | ||
34
test.js
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
2
4
0
66
4994
7
68
1
1
+ Addedturf-helpers@3.0.12(transitive)
+ Addedturf-meta@3.0.12(transitive)
- Removedturf-featurecollection@^1.0.0
- Removedturf-point@^2.0.0
- Removedminimist@1.2.8(transitive)
- Removedturf-featurecollection@1.0.1(transitive)
- Removedturf-meta@1.0.2(transitive)
- Removedturf-point@2.0.1(transitive)