@turf/bbox 7.0.0-alpha.1 → 7.0.0-alpha.111
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 +4 -9
- package/dist/cjs/index.cjs +33 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{js → cjs}/index.d.ts +5 -3
- package/dist/esm/index.d.mts +25 -0
- package/dist/esm/index.mjs +33 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +30 -25
- package/dist/es/index.js +0 -41
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -43
package/README.md
CHANGED
|
@@ -35,26 +35,21 @@ Returns **[BBox][4]** bbox extent in \[minX, minY, maxX, maxY] order
|
|
|
35
35
|
|
|
36
36
|
[4]: https://tools.ietf.org/html/rfc7946#section-5
|
|
37
37
|
|
|
38
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
39
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
40
|
-
./scripts/generate-readmes in the turf project. -->
|
|
38
|
+
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
41
39
|
|
|
42
40
|
---
|
|
43
41
|
|
|
44
|
-
This module is part of the [Turfjs project](
|
|
45
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
46
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
47
|
-
PRs and issues.
|
|
42
|
+
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
48
43
|
|
|
49
44
|
### Installation
|
|
50
45
|
|
|
51
|
-
Install this module individually:
|
|
46
|
+
Install this single module individually:
|
|
52
47
|
|
|
53
48
|
```sh
|
|
54
49
|
$ npm install @turf/bbox
|
|
55
50
|
```
|
|
56
51
|
|
|
57
|
-
Or install the
|
|
52
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
58
53
|
|
|
59
54
|
```sh
|
|
60
55
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
var _meta = require('@turf/meta');
|
|
6
|
+
function bbox(geojson, options = {}) {
|
|
7
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
8
|
+
return geojson.bbox;
|
|
9
|
+
}
|
|
10
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
11
|
+
_meta.coordEach.call(void 0, geojson, (coord) => {
|
|
12
|
+
if (result[0] > coord[0]) {
|
|
13
|
+
result[0] = coord[0];
|
|
14
|
+
}
|
|
15
|
+
if (result[1] > coord[1]) {
|
|
16
|
+
result[1] = coord[1];
|
|
17
|
+
}
|
|
18
|
+
if (result[2] < coord[0]) {
|
|
19
|
+
result[2] = coord[0];
|
|
20
|
+
}
|
|
21
|
+
if (result[3] < coord[1]) {
|
|
22
|
+
result[3] = coord[1];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
__name(bbox, "bbox");
|
|
28
|
+
var turf_bbox_default = bbox;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.bbox = bbox; exports.default = turf_bbox_default;
|
|
33
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAEA,SAAS,iBAAiB;AAmB1B,SAAS,KACP,SACA,UAEI,CAAC,GACC;AACN,MAAI,QAAQ,QAAQ,QAAQ,SAAS,QAAQ,WAAW;AACtD,WAAO,QAAQ;AAAA,EACjB;AACA,QAAM,SAAe,CAAC,UAAU,UAAU,WAAW,SAAS;AAC9D,YAAU,SAAS,CAAC,UAAU;AAC5B,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAzBS;AA4BT,IAAO,oBAAQ","sourcesContent":["import { BBox } from \"geojson\";\nimport { AllGeoJSON } from \"@turf/helpers\";\nimport { coordEach } from \"@turf/meta\";\n\n/**\n * Calculates the bounding box for any GeoJSON object, including FeatureCollection.\n * Uses geojson.bbox if available and options.recompute is not set.\n *\n * @name bbox\n * @param {GeoJSON} geojson any GeoJSON object\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson\n * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order\n * @example\n * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);\n * var bbox = turf.bbox(line);\n * var bboxPolygon = turf.bboxPolygon(bbox);\n *\n * //addToMap\n * var addToMap = [line, bboxPolygon]\n */\nfunction bbox(\n geojson: AllGeoJSON,\n options: {\n recompute?: boolean;\n } = {}\n): BBox {\n if (geojson.bbox != null && true !== options.recompute) {\n return geojson.bbox;\n }\n const result: BBox = [Infinity, Infinity, -Infinity, -Infinity];\n coordEach(geojson, (coord) => {\n if (result[0] > coord[0]) {\n result[0] = coord[0];\n }\n if (result[1] > coord[1]) {\n result[1] = coord[1];\n }\n if (result[2] < coord[0]) {\n result[2] = coord[0];\n }\n if (result[3] < coord[1]) {\n result[3] = coord[1];\n }\n });\n return result;\n}\n\nexport { bbox };\nexport default bbox;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BBox } from
|
|
2
|
-
import { AllGeoJSON } from
|
|
1
|
+
import { BBox } from 'geojson';
|
|
2
|
+
import { AllGeoJSON } from '@turf/helpers';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
5
6
|
* Uses geojson.bbox if available and options.recompute is not set.
|
|
@@ -20,4 +21,5 @@ import { AllGeoJSON } from "@turf/helpers";
|
|
|
20
21
|
declare function bbox(geojson: AllGeoJSON, options?: {
|
|
21
22
|
recompute?: boolean;
|
|
22
23
|
}): BBox;
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
export { bbox, bbox as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BBox } from 'geojson';
|
|
2
|
+
import { AllGeoJSON } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
6
|
+
* Uses geojson.bbox if available and options.recompute is not set.
|
|
7
|
+
*
|
|
8
|
+
* @name bbox
|
|
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
|
|
12
|
+
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
13
|
+
* @example
|
|
14
|
+
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
15
|
+
* var bbox = turf.bbox(line);
|
|
16
|
+
* var bboxPolygon = turf.bboxPolygon(bbox);
|
|
17
|
+
*
|
|
18
|
+
* //addToMap
|
|
19
|
+
* var addToMap = [line, bboxPolygon]
|
|
20
|
+
*/
|
|
21
|
+
declare function bbox(geojson: AllGeoJSON, options?: {
|
|
22
|
+
recompute?: boolean;
|
|
23
|
+
}): BBox;
|
|
24
|
+
|
|
25
|
+
export { bbox, bbox as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { coordEach } from "@turf/meta";
|
|
6
|
+
function bbox(geojson, options = {}) {
|
|
7
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
8
|
+
return geojson.bbox;
|
|
9
|
+
}
|
|
10
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
11
|
+
coordEach(geojson, (coord) => {
|
|
12
|
+
if (result[0] > coord[0]) {
|
|
13
|
+
result[0] = coord[0];
|
|
14
|
+
}
|
|
15
|
+
if (result[1] > coord[1]) {
|
|
16
|
+
result[1] = coord[1];
|
|
17
|
+
}
|
|
18
|
+
if (result[2] < coord[0]) {
|
|
19
|
+
result[2] = coord[0];
|
|
20
|
+
}
|
|
21
|
+
if (result[3] < coord[1]) {
|
|
22
|
+
result[3] = coord[1];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
__name(bbox, "bbox");
|
|
28
|
+
var turf_bbox_default = bbox;
|
|
29
|
+
export {
|
|
30
|
+
bbox,
|
|
31
|
+
turf_bbox_default as default
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { BBox } from \"geojson\";\nimport { AllGeoJSON } from \"@turf/helpers\";\nimport { coordEach } from \"@turf/meta\";\n\n/**\n * Calculates the bounding box for any GeoJSON object, including FeatureCollection.\n * Uses geojson.bbox if available and options.recompute is not set.\n *\n * @name bbox\n * @param {GeoJSON} geojson any GeoJSON object\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.recompute] Whether to ignore an existing bbox property on geojson\n * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order\n * @example\n * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);\n * var bbox = turf.bbox(line);\n * var bboxPolygon = turf.bboxPolygon(bbox);\n *\n * //addToMap\n * var addToMap = [line, bboxPolygon]\n */\nfunction bbox(\n geojson: AllGeoJSON,\n options: {\n recompute?: boolean;\n } = {}\n): BBox {\n if (geojson.bbox != null && true !== options.recompute) {\n return geojson.bbox;\n }\n const result: BBox = [Infinity, Infinity, -Infinity, -Infinity];\n coordEach(geojson, (coord) => {\n if (result[0] > coord[0]) {\n result[0] = coord[0];\n }\n if (result[1] > coord[1]) {\n result[1] = coord[1];\n }\n if (result[2] < coord[0]) {\n result[2] = coord[0];\n }\n if (result[3] < coord[1]) {\n result[3] = coord[1];\n }\n });\n return result;\n}\n\nexport { bbox };\nexport default bbox;\n"],"mappings":";;;;AAEA,SAAS,iBAAiB;AAmB1B,SAAS,KACP,SACA,UAEI,CAAC,GACC;AACN,MAAI,QAAQ,QAAQ,QAAQ,SAAS,QAAQ,WAAW;AACtD,WAAO,QAAQ;AAAA,EACjB;AACA,QAAM,SAAe,CAAC,UAAU,UAAU,WAAW,SAAS;AAC9D,YAAU,SAAS,CAAC,UAAU;AAC5B,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AACA,QAAI,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG;AACxB,aAAO,CAAC,IAAI,MAAM,CAAC;AAAA,IACrB;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAzBS;AA4BT,IAAO,oBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/bbox",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.111+08576cb50",
|
|
4
4
|
"description": "turf bbox module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,43 +24,48 @@
|
|
|
24
24
|
"featurecollection",
|
|
25
25
|
"geojson"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"main": "dist/cjs/index.cjs",
|
|
29
|
+
"module": "dist/esm/index.mjs",
|
|
30
|
+
"types": "dist/cjs/index.d.ts",
|
|
29
31
|
"exports": {
|
|
30
32
|
"./package.json": "./package.json",
|
|
31
33
|
".": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/esm/index.d.mts",
|
|
36
|
+
"default": "./dist/esm/index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/cjs/index.d.ts",
|
|
40
|
+
"default": "./dist/cjs/index.cjs"
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
|
-
"types": "dist/js/index.d.ts",
|
|
38
44
|
"sideEffects": false,
|
|
39
45
|
"files": [
|
|
40
46
|
"dist"
|
|
41
47
|
],
|
|
42
48
|
"scripts": {
|
|
43
|
-
"bench": "tsx bench.
|
|
44
|
-
"build": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"test": "npm-run-all test:*",
|
|
49
|
-
"test:tape": "tsx test.js"
|
|
49
|
+
"bench": "tsx bench.ts",
|
|
50
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
51
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
52
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
53
|
+
"test:tape": "tsx test.ts"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
|
-
"@types/
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
56
|
+
"@types/benchmark": "^2.1.5",
|
|
57
|
+
"@types/tape": "^4.2.32",
|
|
58
|
+
"benchmark": "^2.1.4",
|
|
59
|
+
"npm-run-all": "^4.1.5",
|
|
60
|
+
"tape": "^5.7.2",
|
|
61
|
+
"tsup": "^8.0.1",
|
|
62
|
+
"tsx": "^4.6.2",
|
|
63
|
+
"typescript": "^5.2.2"
|
|
59
64
|
},
|
|
60
65
|
"dependencies": {
|
|
61
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
62
|
-
"@turf/meta": "^7.0.0-alpha.
|
|
63
|
-
"tslib": "^2.
|
|
66
|
+
"@turf/helpers": "^7.0.0-alpha.111+08576cb50",
|
|
67
|
+
"@turf/meta": "^7.0.0-alpha.111+08576cb50",
|
|
68
|
+
"tslib": "^2.6.2"
|
|
64
69
|
},
|
|
65
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "08576cb50376e0199aea02dbd887e3af83672246"
|
|
66
71
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { coordEach } from "@turf/meta";
|
|
2
|
-
/**
|
|
3
|
-
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
4
|
-
* Uses geojson.bbox if available and options.recompute is not set.
|
|
5
|
-
*
|
|
6
|
-
* @name bbox
|
|
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
|
|
10
|
-
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
11
|
-
* @example
|
|
12
|
-
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
13
|
-
* var bbox = turf.bbox(line);
|
|
14
|
-
* var bboxPolygon = turf.bboxPolygon(bbox);
|
|
15
|
-
*
|
|
16
|
-
* //addToMap
|
|
17
|
-
* var addToMap = [line, bboxPolygon]
|
|
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) => {
|
|
25
|
-
if (result[0] > coord[0]) {
|
|
26
|
-
result[0] = coord[0];
|
|
27
|
-
}
|
|
28
|
-
if (result[1] > coord[1]) {
|
|
29
|
-
result[1] = coord[1];
|
|
30
|
-
}
|
|
31
|
-
if (result[2] < coord[0]) {
|
|
32
|
-
result[2] = coord[0];
|
|
33
|
-
}
|
|
34
|
-
if (result[3] < coord[1]) {
|
|
35
|
-
result[3] = coord[1];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
bbox["default"] = bbox;
|
|
41
|
-
export default bbox;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const meta_1 = require("@turf/meta");
|
|
4
|
-
/**
|
|
5
|
-
* Calculates the bounding box for any GeoJSON object, including FeatureCollection.
|
|
6
|
-
* Uses geojson.bbox if available and options.recompute is not set.
|
|
7
|
-
*
|
|
8
|
-
* @name bbox
|
|
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
|
|
12
|
-
* @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
|
|
13
|
-
* @example
|
|
14
|
-
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
|
|
15
|
-
* var bbox = turf.bbox(line);
|
|
16
|
-
* var bboxPolygon = turf.bboxPolygon(bbox);
|
|
17
|
-
*
|
|
18
|
-
* //addToMap
|
|
19
|
-
* var addToMap = [line, bboxPolygon]
|
|
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) => {
|
|
27
|
-
if (result[0] > coord[0]) {
|
|
28
|
-
result[0] = coord[0];
|
|
29
|
-
}
|
|
30
|
-
if (result[1] > coord[1]) {
|
|
31
|
-
result[1] = coord[1];
|
|
32
|
-
}
|
|
33
|
-
if (result[2] < coord[0]) {
|
|
34
|
-
result[2] = coord[0];
|
|
35
|
-
}
|
|
36
|
-
if (result[3] < coord[1]) {
|
|
37
|
-
result[3] = coord[1];
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
bbox["default"] = bbox;
|
|
43
|
-
exports.default = bbox;
|