turf-envelope
Advanced tools
Comparing version 1.0.2 to 3.0.0-canary.2f5f7167
@@ -5,3 +5,3 @@ var envelope = require('./'); | ||
var fixture = require('./geojson/fc.js'); | ||
var fixture = require('./test/fc.js'); | ||
var suite = new Benchmark.Suite('turf-envelope'); | ||
@@ -18,2 +18,2 @@ suite | ||
}) | ||
.run(); | ||
.run(); |
18
index.js
@@ -1,11 +0,11 @@ | ||
var extent = require('turf-extent'); | ||
var bbox = require('turf-bbox'); | ||
var bboxPolygon = require('turf-bbox-polygon'); | ||
/** | ||
* Takes a {@link Feature} or {@link FeatureCollection} and returns a rectangular {@link Polygon} feature that encompasses all vertices. | ||
* Takes any number of features and returns a rectangular {@link Polygon} that encompasses all vertices. | ||
* | ||
* @module turf/envelope | ||
* @name envelope | ||
* @category measurement | ||
* @param {FeatureCollection} fc a FeatureCollection of any type | ||
* @return {Polygon} a rectangular Polygon feature that encompasses all vertices | ||
* @param {FeatureCollection} fc input features | ||
* @return {Feature<Polygon>} a rectangular Polygon feature that encompasses all vertices | ||
* @example | ||
@@ -57,6 +57,4 @@ * var fc = { | ||
module.exports = function(features, done){ | ||
var bbox = extent(features); | ||
var poly = bboxPolygon(bbox); | ||
return poly; | ||
} | ||
module.exports = function (features) { | ||
return bboxPolygon(bbox(features)); | ||
}; |
{ | ||
"name": "turf-envelope", | ||
"version": "1.0.2", | ||
"version": "3.0.0-canary.2f5f7167", | ||
"description": "turf envelope module", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js", | ||
"doc": "dox -r < index.js | doxme --readme > README.md" | ||
"test": "node test.js" | ||
}, | ||
@@ -29,10 +28,8 @@ "repository": { | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.5.0", | ||
"dox": "^0.6.1", | ||
"doxme": "^1.4.3" | ||
"tape": "^3.5.0" | ||
}, | ||
"dependencies": { | ||
"turf-bbox-polygon": "^1.0.0", | ||
"turf-extent": "^1.0.3" | ||
"turf-bbox-polygon": "^3.0.0-canary.2f5f7167", | ||
"turf-bbox": "^3.0.0-canary.2f5f7167" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # turf-envelope | ||
Takes a Feature or FeatureCollection and returns a rectangular Polygon feature that encompasses all vertices. | ||
Takes any number of features and returns a rectangular Polygon that encompasses all vertices. | ||
@@ -16,5 +16,5 @@ | ||
| parameter | type | description | | ||
| --------- | ----------------- | ------------------------------- | | ||
| `fc` | FeatureCollection | a FeatureCollection of any type | | ||
| parameter | type | description | | ||
| --------- | ----------------- | -------------- | | ||
| `fc` | FeatureCollection | input features | | ||
@@ -25,12 +25,43 @@ | ||
```js | ||
var fc = turf.featurecollection([ | ||
turf.point([-75.343, 39.984], {name: 'Location A'}), | ||
turf.point([-75.833, 39.284], {name: 'Location B'}), | ||
turf.point([-75.534, 39.123], {name: 'Location C'}) | ||
]); | ||
var fc = { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"name": "Location A" | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [-75.343, 39.984] | ||
} | ||
}, { | ||
"type": "Feature", | ||
"properties": { | ||
"name": "Location B" | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [-75.833, 39.284] | ||
} | ||
}, { | ||
"type": "Feature", | ||
"properties": { | ||
"name": "Location C" | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [-75.534, 39.123] | ||
} | ||
} | ||
] | ||
}; | ||
var enveloped = turf.envelope(fc); | ||
var result = turf.featurecollection( | ||
fc.features.concat(enveloped)); | ||
var resultFeatures = fc.features.concat(enveloped); | ||
var result = { | ||
"type": "FeatureCollection", | ||
"features": resultFeatures | ||
}; | ||
@@ -40,2 +71,5 @@ //=result | ||
**Returns** `Feature.<Polygon>`, a rectangular Polygon feature that encompasses all vertices | ||
## Installation | ||
@@ -55,1 +89,2 @@ | ||
var test = require('tape'); | ||
var envelope = require('./'); | ||
var fc = require('./geojson/fc.js'); | ||
var fc = require('./test/geojson/fc.json'); | ||
@@ -9,3 +9,6 @@ test('envelope', function(t){ | ||
t.equal(enveloped.geometry.type, 'Polygon'); | ||
t.deepEqual(enveloped.geometry.coordinates, | ||
[ [ [ 20, -10 ], [ 130, -10 ], [ 130, 4 ], [ 20, 4 ], [ 20, -10 ] ] ] , | ||
'positions are correct'); | ||
t.end(); | ||
}) | ||
}) |
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
0
86
5632
7
84
1
1
+ Addedturf-bbox@3.0.12(transitive)
+ Addedturf-bbox-polygon@3.0.12(transitive)
+ Addedturf-helpers@3.0.12(transitive)
+ Addedturf-meta@3.0.12(transitive)
- Removedturf-extent@^1.0.3
- Removedturf-bbox-polygon@1.0.2(transitive)
- Removedturf-extent@1.0.4(transitive)
- Removedturf-meta@1.0.2(transitive)
- Removedturf-polygon@1.0.3(transitive)