@turf/bbox 6.5.0 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/dist/es/index.js +10 -4
- package/dist/js/index.d.ts +9 -3
- package/dist/js/index.js +11 -5
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
## bbox
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
8
|
+
Uses geojson.bbox if available and options.recompute is not set.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
### Parameters
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
* `geojson` **[GeoJSON][1]** any GeoJSON object
|
|
13
|
+
* `options` **[Object][2]** Optional parameters (optional, default `{}`)
|
|
12
14
|
|
|
13
|
-
**
|
|
15
|
+
* `options.recompute` **[boolean][3]?** Whether to ignore an existing bbox property on geojson
|
|
16
|
+
|
|
17
|
+
### Examples
|
|
14
18
|
|
|
15
19
|
```javascript
|
|
16
20
|
var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
@@ -21,11 +25,15 @@ var bboxPolygon = turf.bboxPolygon(bbox);
|
|
|
21
25
|
var addToMap = [line, bboxPolygon]
|
|
22
26
|
```
|
|
23
27
|
|
|
24
|
-
Returns **[BBox][
|
|
28
|
+
Returns **[BBox][4]** bbox extent in \[minX, minY, maxX, maxY] order
|
|
25
29
|
|
|
26
30
|
[1]: https://tools.ietf.org/html/rfc7946#section-3
|
|
27
31
|
|
|
28
|
-
[2]: https://
|
|
32
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
33
|
+
|
|
34
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
35
|
+
|
|
36
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-5
|
|
29
37
|
|
|
30
38
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
31
39
|
if you find an error, edit the source file (likely index.js), and re-run
|
package/dist/es/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { coordEach } from "@turf/meta";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
4
|
+
* Uses geojson.bbox if available and options.recompute is not set.
|
|
4
5
|
*
|
|
5
6
|
* @name bbox
|
|
6
7
|
* @param {GeoJSON} geojson any GeoJSON object
|
|
8
|
+
* @param {Object} [options={}] Optional parameters
|
|
9
|
+
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson
|
|
7
10
|
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
8
11
|
* @example
|
|
9
12
|
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
@@ -13,9 +16,12 @@ import { coordEach } from "@turf/meta";
|
|
|
13
16
|
* //addToMap
|
|
14
17
|
* var addToMap = [line, bboxPolygon]
|
|
15
18
|
*/
|
|
16
|
-
function bbox(geojson) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
function bbox(geojson, options = {}) {
|
|
20
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
21
|
+
return geojson.bbox;
|
|
22
|
+
}
|
|
23
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
24
|
+
coordEach(geojson, (coord) => {
|
|
19
25
|
if (result[0] > coord[0]) {
|
|
20
26
|
result[0] = coord[0];
|
|
21
27
|
}
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { BBox } from "
|
|
1
|
+
import { BBox } from "geojson";
|
|
2
|
+
import { AllGeoJSON } from "@turf/helpers";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
5
|
+
* Uses geojson.bbox if available and options.recompute is not set.
|
|
4
6
|
*
|
|
5
7
|
* @name bbox
|
|
6
8
|
* @param {GeoJSON} geojson any GeoJSON object
|
|
9
|
+
* @param {Object} [options={}] Optional parameters
|
|
10
|
+
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson
|
|
7
11
|
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
8
12
|
* @example
|
|
9
13
|
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
@@ -13,5 +17,7 @@ import { BBox } from "@turf/helpers";
|
|
|
13
17
|
* //addToMap
|
|
14
18
|
* var addToMap = [line, bboxPolygon]
|
|
15
19
|
*/
|
|
16
|
-
declare function bbox(geojson:
|
|
20
|
+
declare function bbox(geojson: AllGeoJSON, options?: {
|
|
21
|
+
recompute?: boolean;
|
|
22
|
+
}): BBox;
|
|
17
23
|
export default bbox;
|
package/dist/js/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const meta_1 = require("@turf/meta");
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
6
|
+
* Uses geojson.bbox if available and options.recompute is not set.
|
|
6
7
|
*
|
|
7
8
|
* @name bbox
|
|
8
9
|
* @param {GeoJSON} geojson any GeoJSON object
|
|
10
|
+
* @param {Object} [options={}] Optional parameters
|
|
11
|
+
* @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson
|
|
9
12
|
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
10
13
|
* @example
|
|
11
14
|
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
@@ -15,9 +18,12 @@ var meta_1 = require("@turf/meta");
|
|
|
15
18
|
* //addToMap
|
|
16
19
|
* var addToMap = [line, bboxPolygon]
|
|
17
20
|
*/
|
|
18
|
-
function bbox(geojson) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
function bbox(geojson, options = {}) {
|
|
22
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
23
|
+
return geojson.bbox;
|
|
24
|
+
}
|
|
25
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
26
|
+
meta_1.coordEach(geojson, (coord) => {
|
|
21
27
|
if (result[0] > coord[0]) {
|
|
22
28
|
result[0] = coord[0];
|
|
23
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/bbox",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf bbox module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,8 +57,9 @@
|
|
|
57
57
|
"typescript": "*"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@turf/helpers": "^
|
|
61
|
-
"@turf/meta": "^
|
|
60
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
61
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
62
|
+
"tslib": "^2.3.0"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
64
65
|
}
|