@turf/bbox
Advanced tools
Comparing version 4.1.0 to 4.2.0
30
index.js
@@ -1,2 +0,2 @@ | ||
var each = require('@turf/meta').coordEach; | ||
var coordEach = require('@turf/meta').coordEach; | ||
@@ -7,24 +7,22 @@ /** | ||
* @name bbox | ||
* @param {(Feature|FeatureCollection)} geojson input features | ||
* @param {FeatureCollection|Feature<any>} geojson input features | ||
* @returns {Array<number>} bbox extent in [minX, minY, maxX, maxY] order | ||
* @addToMap features, bboxPolygon | ||
* @example | ||
* var pt1 = turf.point([114.175329, 22.2524]) | ||
* var pt2 = turf.point([114.170007, 22.267969]) | ||
* var pt3 = turf.point([114.200649, 22.274641]) | ||
* var pt4 = turf.point([114.200649, 22.274641]) | ||
* var pt5 = turf.point([114.186744, 22.265745]) | ||
* var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5]) | ||
* var line = { | ||
* "type": "Feature", | ||
* "properties": {}, | ||
* "geometry": { | ||
* "type": "LineString", | ||
* "coordinates": [[-74, 40], [-78, 42], [-82, 35]] | ||
* } | ||
* } | ||
* var bbox = turf.bbox(line); | ||
* | ||
* var bbox = turf.bbox(features); | ||
* | ||
* //addToMap | ||
* var bboxPolygon = turf.bboxPolygon(bbox); | ||
* | ||
* //=bbox | ||
* | ||
* //=bboxPolygon | ||
* var addToMap = [line, bboxPolygon] | ||
*/ | ||
module.exports = function (geojson) { | ||
var bbox = [Infinity, Infinity, -Infinity, -Infinity]; | ||
each(geojson, function (coord) { | ||
coordEach(geojson, function (coord) { | ||
if (bbox[0] > coord[0]) bbox[0] = coord[0]; | ||
@@ -31,0 +29,0 @@ if (bbox[1] > coord[1]) bbox[1] = coord[1]; |
{ | ||
"name": "@turf/bbox", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "turf bbox module", | ||
@@ -38,4 +38,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@turf/meta": "^4.1.0" | ||
"@turf/meta": "^4.2.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # @turf/bbox | ||
- `geojson` **([Feature](http://geojson.org/geojson-spec.html#feature-objects) \| [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects))** input features | ||
- `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** input features | ||
@@ -15,16 +15,15 @@ **Examples** | ||
```javascript | ||
var pt1 = turf.point([114.175329, 22.2524]) | ||
var pt2 = turf.point([114.170007, 22.267969]) | ||
var pt3 = turf.point([114.200649, 22.274641]) | ||
var pt4 = turf.point([114.200649, 22.274641]) | ||
var pt5 = turf.point([114.186744, 22.265745]) | ||
var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5]) | ||
var line = { | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[-74, 40], [-78, 42], [-82, 35]] | ||
} | ||
} | ||
var bbox = turf.bbox(line); | ||
var bbox = turf.bbox(features); | ||
//addToMap | ||
var bboxPolygon = turf.bboxPolygon(bbox); | ||
//=bbox | ||
//=bboxPolygon | ||
var addToMap = [line, bboxPolygon] | ||
``` | ||
@@ -31,0 +30,0 @@ |
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
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
4682
42
55
Updated@turf/meta@^4.2.0