@turf/bbox
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
import { coordEach } from "@turf/meta"; | ||
/** | ||
* Takes a set of features, calculates the bbox of all input features, and returns a bounding box. | ||
* Calculates the bounding box for any GeoJSON object, including FeatureCollection. | ||
* Uses geojson.bbox if available and options.recompute is not set. | ||
* | ||
* @name bbox | ||
* @param {GeoJSON} geojson any GeoJSON object | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson | ||
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order | ||
@@ -16,5 +19,8 @@ * @example | ||
*/ | ||
function bbox(geojson) { | ||
var result = [Infinity, Infinity, -Infinity, -Infinity]; | ||
coordEach(geojson, function (coord) { | ||
function bbox(geojson, options = {}) { | ||
if (geojson.bbox != null && true !== options.recompute) { | ||
return geojson.bbox; | ||
} | ||
const result = [Infinity, Infinity, -Infinity, -Infinity]; | ||
coordEach(geojson, (coord) => { | ||
if (result[0] > coord[0]) { | ||
@@ -21,0 +27,0 @@ result[0] = coord[0]; |
@@ -1,7 +0,11 @@ | ||
import { BBox } from "@turf/helpers"; | ||
import { BBox } from "geojson"; | ||
import { AllGeoJSON } from "@turf/helpers"; | ||
/** | ||
* Takes a set of features, calculates the bbox of all input features, and returns a bounding box. | ||
* Calculates the bounding box for any GeoJSON object, including FeatureCollection. | ||
* Uses geojson.bbox if available and options.recompute is not set. | ||
* | ||
* @name bbox | ||
* @param {GeoJSON} geojson any GeoJSON object | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson | ||
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order | ||
@@ -16,3 +20,5 @@ * @example | ||
*/ | ||
declare function bbox(geojson: any): BBox; | ||
declare function bbox(geojson: AllGeoJSON, options?: { | ||
recompute?: boolean; | ||
}): BBox; | ||
export default bbox; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var meta_1 = require("@turf/meta"); | ||
const meta_1 = require("@turf/meta"); | ||
/** | ||
* Takes a set of features, calculates the bbox of all input features, and returns a bounding box. | ||
* Calculates the bounding box for any GeoJSON object, including FeatureCollection. | ||
* Uses geojson.bbox if available and options.recompute is not set. | ||
* | ||
* @name bbox | ||
* @param {GeoJSON} geojson any GeoJSON object | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson | ||
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order | ||
@@ -18,5 +21,8 @@ * @example | ||
*/ | ||
function bbox(geojson) { | ||
var result = [Infinity, Infinity, -Infinity, -Infinity]; | ||
meta_1.coordEach(geojson, function (coord) { | ||
function bbox(geojson, options = {}) { | ||
if (geojson.bbox != null && true !== options.recompute) { | ||
return geojson.bbox; | ||
} | ||
const result = [Infinity, Infinity, -Infinity, -Infinity]; | ||
meta_1.coordEach(geojson, (coord) => { | ||
if (result[0] > coord[0]) { | ||
@@ -23,0 +29,0 @@ result[0] = coord[0]; |
{ | ||
"name": "@turf/bbox", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf bbox module", | ||
@@ -60,6 +60,7 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/meta": "^6.5.0" | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/meta": "^7.0.0-alpha.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -7,10 +7,14 @@ # @turf/bbox | ||
Takes a set of features, calculates the bbox of all input features, and returns a bounding box. | ||
Calculates the bounding box for any GeoJSON object, including FeatureCollection. | ||
Uses geojson.bbox if available and options.recompute is not set. | ||
**Parameters** | ||
### Parameters | ||
- `geojson` **[GeoJSON][1]** any GeoJSON object | ||
* `geojson` **[GeoJSON][1]** any GeoJSON object | ||
* `options` **[Object][2]** Optional parameters (optional, default `{}`) | ||
**Examples** | ||
* `options.recompute` **[boolean][3]?** Whether to ignore an existing bbox property on geojson | ||
### Examples | ||
```javascript | ||
@@ -25,8 +29,12 @@ var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]); | ||
Returns **[BBox][2]** bbox extent in [minX, minY, maxX, maxY] order | ||
Returns **[BBox][4]** bbox extent in \[minX, minY, maxX, maxY] order | ||
[1]: https://tools.ietf.org/html/rfc7946#section-3 | ||
[2]: https://tools.ietf.org/html/rfc7946#section-5 | ||
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean | ||
[4]: https://tools.ietf.org/html/rfc7946#section-5 | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -33,0 +41,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
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
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
7935
107
62
3
1
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.1.0(transitive)
+ Added@turf/meta@7.1.0(transitive)
+ Added@types/geojson@7946.0.14(transitive)
+ Addedtslib@2.7.0(transitive)
- Removed@turf/helpers@6.5.0(transitive)
- Removed@turf/meta@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0
Updated@turf/meta@^7.0.0-alpha.0