@turf/bbox 6.0.0 → 6.0.1

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 CHANGED
@@ -8,7 +8,7 @@ Takes a set of features, calculates the bbox of all input features, and returns
8
8
 
9
9
  **Parameters**
10
10
 
11
- - `geojson` **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** any GeoJSON object
11
+ - `geojson` **[GeoJSON][1]** any GeoJSON object
12
12
 
13
13
  **Examples**
14
14
 
@@ -21,7 +21,11 @@ var bboxPolygon = turf.bboxPolygon(bbox);
21
21
  var addToMap = [line, bboxPolygon]
22
22
  ```
23
23
 
24
- Returns **[BBox](https://tools.ietf.org/html/rfc7946#section-5)** bbox extent in [minX, minY, maxX, maxY] order
24
+ Returns **[BBox][2]** bbox extent in [minX, minY, maxX, maxY] order
25
+
26
+ [1]: https://tools.ietf.org/html/rfc7946#section-3
27
+
28
+ [2]: https://tools.ietf.org/html/rfc7946#section-5
25
29
 
26
30
  <!-- This file is automatically generated. Please don't edit it directly:
27
31
  if you find an error, edit the source file (likely index.js), and re-run
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { BBox } from "@turf/helpers";
2
+ /**
3
+ * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
4
+ *
5
+ * @name bbox
6
+ * @param {GeoJSON} geojson any GeoJSON object
7
+ * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
8
+ * @example
9
+ * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
10
+ * var bbox = turf.bbox(line);
11
+ * var bboxPolygon = turf.bboxPolygon(bbox);
12
+ *
13
+ * //addToMap
14
+ * var addToMap = [line, bboxPolygon]
15
+ */
16
+ export default function bbox(geojson: any): BBox;
package/index.js CHANGED
@@ -16,17 +16,21 @@ var meta_1 = require("@turf/meta");
16
16
  * var addToMap = [line, bboxPolygon]
17
17
  */
18
18
  function bbox(geojson) {
19
- var BBox = [Infinity, Infinity, -Infinity, -Infinity];
19
+ var result = [Infinity, Infinity, -Infinity, -Infinity];
20
20
  meta_1.coordEach(geojson, function (coord) {
21
- if (BBox[0] > coord[0])
22
- BBox[0] = coord[0];
23
- if (BBox[1] > coord[1])
24
- BBox[1] = coord[1];
25
- if (BBox[2] < coord[0])
26
- BBox[2] = coord[0];
27
- if (BBox[3] < coord[1])
28
- BBox[3] = coord[1];
21
+ if (result[0] > coord[0]) {
22
+ result[0] = coord[0];
23
+ }
24
+ if (result[1] > coord[1]) {
25
+ result[1] = coord[1];
26
+ }
27
+ if (result[2] < coord[0]) {
28
+ result[2] = coord[0];
29
+ }
30
+ if (result[3] < coord[1]) {
31
+ result[3] = coord[1];
32
+ }
29
33
  });
30
- return BBox;
34
+ return result;
31
35
  }
32
36
  exports.default = bbox;
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@turf/bbox",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "turf bbox module",
5
5
  "main": "index",
6
+ "types": "index.d.ts",
6
7
  "files": [
7
8
  "index.js",
8
- "index.ts"
9
+ "index.d.ts"
9
10
  ],
10
11
  "scripts": {
12
+ "prepare": "tsc",
11
13
  "pretest": "tsc",
12
14
  "test": "node test.js",
13
15
  "bench": "node bench.js",
@@ -34,7 +36,9 @@
34
36
  "devDependencies": {
35
37
  "benchmark": "*",
36
38
  "typescript": "*",
37
- "tape": "*"
39
+ "tape": "*",
40
+ "tslint": "*",
41
+ "@types/tape": "*"
38
42
  },
39
43
  "dependencies": {
40
44
  "@turf/helpers": "6.x",
package/index.ts DELETED
@@ -1,29 +0,0 @@
1
- import { AllGeoJSON } from '@turf/helpers';
2
- import { coordEach } from '@turf/meta';
3
-
4
- /**
5
- * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
6
- *
7
- * @name bbox
8
- * @param {GeoJSON} geojson any GeoJSON object
9
- * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
10
- * @example
11
- * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
12
- * var bbox = turf.bbox(line);
13
- * var bboxPolygon = turf.bboxPolygon(bbox);
14
- *
15
- * //addToMap
16
- * var addToMap = [line, bboxPolygon]
17
- */
18
- function bbox(geojson: AllGeoJSON) {
19
- const BBox = [Infinity, Infinity, -Infinity, -Infinity];
20
- coordEach(geojson, coord => {
21
- if (BBox[0] > coord[0]) BBox[0] = coord[0];
22
- if (BBox[1] > coord[1]) BBox[1] = coord[1];
23
- if (BBox[2] < coord[0]) BBox[2] = coord[0];
24
- if (BBox[3] < coord[1]) BBox[3] = coord[1];
25
- });
26
- return BBox;
27
- }
28
-
29
- export default bbox;