@turf/square 7.1.0-alpha.7 → 7.1.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 +3 -3
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +12 -1
- package/dist/esm/index.d.ts +12 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@ would contain the input.
|
|
|
14
14
|
### Examples
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const bbox = [-20, -20, -15, 0];
|
|
18
|
+
const squared = turf.square(bbox);
|
|
19
19
|
|
|
20
20
|
//addToMap
|
|
21
|
-
|
|
21
|
+
const addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Returns **[BBox][1]** a square surrounding `bbox`
|
package/dist/cjs/index.cjs
CHANGED
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAAA,SAAS,gBAAgB;AAiBzB,SAAS,OAAO,MAAkB;AAChC,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAClB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAElB,MAAI,qBAAqB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AACjE,MAAI,mBAAmB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AAC/D,MAAI,sBAAsB,kBAAkB;AAC1C,QAAI,oBAAoB,QAAQ,SAAS;AACzC,WAAO;AAAA,MACL;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,MACnC;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF,OAAO;AACL,QAAI,sBAAsB,OAAO,QAAQ;AACzC,WAAO;AAAA,MACL,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,MACA,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;AAGA,IAAO,sBAAQ","sourcesContent":["import { distance } from \"@turf/distance\";\nimport { BBox } from \"geojson\";\n\n/**\n * Takes a bounding box and calculates the minimum square bounding box that\n * would contain the input.\n *\n * @name square\n * @param {BBox} bbox extent in [west, south, east, north] order\n * @returns {BBox} a square surrounding `bbox`\n * @example\n * const bbox = [-20, -20, -15, 0];\n * const squared = turf.square(bbox);\n *\n * //addToMap\n * const addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]\n */\nfunction square(bbox: BBox): BBox {\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);\n var verticalDistance = distance(bbox.slice(0, 2), [west, north]);\n if (horizontalDistance >= verticalDistance) {\n var verticalMidpoint = (south + north) / 2;\n return [\n west,\n verticalMidpoint - (east - west) / 2,\n east,\n verticalMidpoint + (east - west) / 2,\n ];\n } else {\n var horizontalMidpoint = (west + east) / 2;\n return [\n horizontalMidpoint - (north - south) / 2,\n south,\n horizontalMidpoint + (north - south) / 2,\n north,\n ];\n }\n}\n\nexport { square };\nexport default square;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { BBox } from 'geojson';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Takes a bounding box and calculates the minimum square bounding box that
|
|
5
|
+
* would contain the input.
|
|
6
|
+
*
|
|
7
|
+
* @name square
|
|
8
|
+
* @param {BBox} bbox extent in [west, south, east, north] order
|
|
9
|
+
* @returns {BBox} a square surrounding `bbox`
|
|
10
|
+
* @example
|
|
11
|
+
* const bbox = [-20, -20, -15, 0];
|
|
12
|
+
* const squared = turf.square(bbox);
|
|
13
|
+
*
|
|
14
|
+
* //addToMap
|
|
15
|
+
* const addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
|
|
5
16
|
*/
|
|
6
17
|
declare function square(bbox: BBox): BBox;
|
|
7
18
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { BBox } from 'geojson';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Takes a bounding box and calculates the minimum square bounding box that
|
|
5
|
+
* would contain the input.
|
|
6
|
+
*
|
|
7
|
+
* @name square
|
|
8
|
+
* @param {BBox} bbox extent in [west, south, east, north] order
|
|
9
|
+
* @returns {BBox} a square surrounding `bbox`
|
|
10
|
+
* @example
|
|
11
|
+
* const bbox = [-20, -20, -15, 0];
|
|
12
|
+
* const squared = turf.square(bbox);
|
|
13
|
+
*
|
|
14
|
+
* //addToMap
|
|
15
|
+
* const addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
|
|
5
16
|
*/
|
|
6
17
|
declare function square(bbox: BBox): BBox;
|
|
7
18
|
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { distance } from \"@turf/distance\";\nimport { BBox } from \"geojson\";\n\n/**\n * Takes a bounding box and calculates the minimum square bounding box that\n * would contain the input.\n *\n * @name square\n * @param {BBox} bbox extent in [west, south, east, north] order\n * @returns {BBox} a square surrounding `bbox`\n * @example\n * const bbox = [-20, -20, -15, 0];\n * const squared = turf.square(bbox);\n *\n * //addToMap\n * const addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]\n */\nfunction square(bbox: BBox): BBox {\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);\n var verticalDistance = distance(bbox.slice(0, 2), [west, north]);\n if (horizontalDistance >= verticalDistance) {\n var verticalMidpoint = (south + north) / 2;\n return [\n west,\n verticalMidpoint - (east - west) / 2,\n east,\n verticalMidpoint + (east - west) / 2,\n ];\n } else {\n var horizontalMidpoint = (west + east) / 2;\n return [\n horizontalMidpoint - (north - south) / 2,\n south,\n horizontalMidpoint + (north - south) / 2,\n north,\n ];\n }\n}\n\nexport { square };\nexport default square;\n"],"mappings":";AAAA,SAAS,gBAAgB;AAiBzB,SAAS,OAAO,MAAkB;AAChC,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAClB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAElB,MAAI,qBAAqB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AACjE,MAAI,mBAAmB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AAC/D,MAAI,sBAAsB,kBAAkB;AAC1C,QAAI,oBAAoB,QAAQ,SAAS;AACzC,WAAO;AAAA,MACL;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,MACnC;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF,OAAO;AACL,QAAI,sBAAsB,OAAO,QAAQ;AACzC,WAAO;AAAA,MACL,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,MACA,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;AAGA,IAAO,sBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/square",
|
|
3
|
-
"version": "7.1.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "turf square module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,15 +51,20 @@
|
|
|
51
51
|
"test:tape": "tsx test.ts"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
+
"@types/benchmark": "^2.1.5",
|
|
55
|
+
"@types/tape": "^4.2.32",
|
|
54
56
|
"benchmark": "^2.1.4",
|
|
55
57
|
"npm-run-all": "^4.1.5",
|
|
56
58
|
"tape": "^5.7.2",
|
|
57
59
|
"tsup": "^8.0.1",
|
|
58
|
-
"tsx": "^4.6.2"
|
|
60
|
+
"tsx": "^4.6.2",
|
|
61
|
+
"typescript": "^5.2.2"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"@turf/distance": "^7.1.0
|
|
62
|
-
"@turf/helpers": "^7.1.0
|
|
64
|
+
"@turf/distance": "^7.1.0",
|
|
65
|
+
"@turf/helpers": "^7.1.0",
|
|
66
|
+
"@types/geojson": "^7946.0.10",
|
|
67
|
+
"tslib": "^2.6.2"
|
|
63
68
|
},
|
|
64
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
|
|
65
70
|
}
|