@turf/triangle-grid 7.0.0 → 7.1.0-alpha.70
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 +15 -17
- package/dist/cjs/index.cjs +1 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -4
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
## triangleGrid
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Creates a grid of triangular polygons.
|
|
8
8
|
|
|
9
9
|
### Parameters
|
|
10
10
|
|
|
11
|
-
* `bbox` **[
|
|
12
|
-
* `cellSide` **[number][
|
|
13
|
-
* `options` **[Object][
|
|
11
|
+
* `bbox` **[BBox][1]** extent of grid in \[minX, minY, maxX, maxY] order
|
|
12
|
+
* `cellSide` **[number][2]** dimension of each grid cell. Two triangles are created in each cell.
|
|
13
|
+
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
|
|
14
14
|
|
|
15
|
-
* `options.units` **
|
|
16
|
-
* `options.mask` **[Feature][
|
|
17
|
-
* `options.properties` **[Object][
|
|
15
|
+
* `options.units` **Units** used in calculating cellSide. Supports all valid Turf [Units][4] (optional, default `'kilometers'`)
|
|
16
|
+
* `options.mask` **[Feature][5]<[Polygon][6]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
|
|
17
|
+
* `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`)
|
|
18
18
|
|
|
19
19
|
### Examples
|
|
20
20
|
|
|
@@ -29,23 +29,21 @@ var triangleGrid = turf.triangleGrid(bbox, cellSide, options);
|
|
|
29
29
|
var addToMap = [triangleGrid];
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Returns **[FeatureCollection][
|
|
32
|
+
Returns **[FeatureCollection][7]<[Polygon][6]>** grid of polygons
|
|
33
33
|
|
|
34
|
-
[1]: https://tools.ietf.org/html/rfc7946#section-
|
|
34
|
+
[1]: https://tools.ietf.org/html/rfc7946#section-5
|
|
35
35
|
|
|
36
|
-
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
36
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
37
37
|
|
|
38
|
-
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
38
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
39
39
|
|
|
40
|
-
[4]: https://
|
|
40
|
+
[4]: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md
|
|
41
41
|
|
|
42
|
-
[5]: https://
|
|
42
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
43
43
|
|
|
44
|
-
[6]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
44
|
+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
45
45
|
|
|
46
|
-
[7]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
47
|
-
|
|
48
|
-
[8]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
46
|
+
[7]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
49
47
|
|
|
50
48
|
<!-- 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. -->
|
|
51
49
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
5
2
|
var _distance = require('@turf/distance');
|
|
6
3
|
var _intersect = require('@turf/intersect');
|
|
7
4
|
var _helpers = require('@turf/helpers');
|
|
@@ -129,7 +126,6 @@ function triangleGrid(bbox, cellSide, options = {}) {
|
|
|
129
126
|
}
|
|
130
127
|
return _helpers.featureCollection.call(void 0, results);
|
|
131
128
|
}
|
|
132
|
-
__name(triangleGrid, "triangleGrid");
|
|
133
129
|
var turf_triangle_grid_default = triangleGrid;
|
|
134
130
|
|
|
135
131
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAOA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,yBAAgC;AAuBlD,SAAS,aACP,MACA,UACA,UAII,CAAC,GAC0B;AAE/B,MAAI,UAAiC,CAAC;AAYtC,MAAI,YACF,WAAW,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,OAAO;AACrE,MAAI,YAAY,aAAa,KAAK,CAAC,IAAI,KAAK,CAAC;AAC7C,MAAI,YACF,WAAW,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,OAAO;AACrE,MAAI,aAAa,aAAa,KAAK,CAAC,IAAI,KAAK,CAAC;AAE9C,MAAI,KAAK;AACT,MAAI,WAAW,KAAK,CAAC;AACrB,SAAO,YAAY,KAAK,CAAC,GAAG;AAC1B,QAAI,KAAK;AACT,QAAI,WAAW,KAAK,CAAC;AACrB,WAAO,YAAY,KAAK,CAAC,GAAG;AAC1B,UAAI,gBAAgB;AACpB,UAAI,gBAAgB;AAEpB,UAAI,KAAK,MAAM,KAAK,KAAK,MAAM,GAAG;AAChC,wBAAgB;AAAA,UACd;AAAA,YACE;AAAA,cACE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ance\";\nimport { intersect } from \"@turf/intersect\";\nimport { polygon, featureCollection, Units } from \"@turf/helpers\";\n\n/**\n * Creates a grid of triangular polygons.\n *\n * @name triangleGrid\n * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order\n * @param {number} cellSide dimension of each grid cell. Two triangles are created in each cell.\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] used in calculating cellSide. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}\n * @param {Feature<Polygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} grid of polygons\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var triangleGrid = turf.triangleGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [triangleGrid];\n */\nfunction triangleGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon>;\n } = {}\n): FeatureCollection<Polygon, P> {\n // Containers\n var results: Feature<Polygon, P>[] = [];\n\n // Input Validation is being handled by Typescript\n\n // if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');\n // if (!isNumber(cellSide)) throw new Error('cellSide is invalid');\n // if (!bbox) throw new Error('bbox is required');\n // if (!Array.isArray(bbox)) throw new Error('bbox must be array');\n // if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');\n // if (mask && ['Polygon', 'MultiPolygon'].indexOf(getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');\n\n // Main\n var xFraction =\n cellSide / distance([bbox[0], bbox[1]], [bbox[2], bbox[1]], options);\n var cellWidth = xFraction * (bbox[2] - bbox[0]);\n var yFraction =\n cellSide / distance([bbox[0], bbox[1]], [bbox[0], bbox[3]], options);\n var cellHeight = yFraction * (bbox[3] - bbox[1]);\n\n var xi = 0;\n var currentX = bbox[0];\n while (currentX <= bbox[2]) {\n var yi = 0;\n var currentY = bbox[1];\n while (currentY <= bbox[3]) {\n var cellTriangle1 = null;\n var cellTriangle2 = null;\n\n if (xi % 2 === 0 && yi % 2 === 0) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY + cellHeight],\n ],\n ],\n options.properties\n );\n } else if (xi % 2 === 0 && yi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n } else if (yi % 2 === 0 && xi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n } else if (yi % 2 === 1 && xi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY + cellHeight],\n ],\n ],\n options.properties\n );\n }\n if (options.mask) {\n if (intersect(featureCollection([options.mask, cellTriangle1!])))\n results.push(cellTriangle1!);\n if (intersect(featureCollection([options.mask, cellTriangle2!])))\n results.push(cellTriangle2!);\n } else {\n results.push(cellTriangle1!);\n results.push(cellTriangle2!);\n }\n\n currentY += cellHeight;\n yi++;\n }\n xi++;\n currentX += cellWidth;\n }\n return featureCollection(results);\n}\n\nexport { triangleGrid };\nexport default triangleGrid;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2,13 +2,13 @@ import { GeoJsonProperties, BBox, Feature, Polygon, FeatureCollection } from 'ge
|
|
|
2
2
|
import { Units } from '@turf/helpers';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates a grid of triangular polygons.
|
|
6
6
|
*
|
|
7
7
|
* @name triangleGrid
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {number} cellSide dimension of each cell
|
|
8
|
+
* @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order
|
|
9
|
+
* @param {number} cellSide dimension of each grid cell. Two triangles are created in each cell.
|
|
10
10
|
* @param {Object} [options={}] Optional parameters
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Units} [options.units='kilometers'] used in calculating cellSide. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}
|
|
12
12
|
* @param {Feature<Polygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
|
|
13
13
|
* @param {Object} [options.properties={}] passed to each point of the grid
|
|
14
14
|
* @returns {FeatureCollection<Polygon>} grid of polygons
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { GeoJsonProperties, BBox, Feature, Polygon, FeatureCollection } from 'ge
|
|
|
2
2
|
import { Units } from '@turf/helpers';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates a grid of triangular polygons.
|
|
6
6
|
*
|
|
7
7
|
* @name triangleGrid
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {number} cellSide dimension of each cell
|
|
8
|
+
* @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order
|
|
9
|
+
* @param {number} cellSide dimension of each grid cell. Two triangles are created in each cell.
|
|
10
10
|
* @param {Object} [options={}] Optional parameters
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Units} [options.units='kilometers'] used in calculating cellSide. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}
|
|
12
12
|
* @param {Feature<Polygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
|
|
13
13
|
* @param {Object} [options.properties={}] passed to each point of the grid
|
|
14
14
|
* @returns {FeatureCollection<Polygon>} grid of polygons
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import { distance } from "@turf/distance";
|
|
6
3
|
import { intersect } from "@turf/intersect";
|
|
@@ -129,7 +126,6 @@ function triangleGrid(bbox, cellSide, options = {}) {
|
|
|
129
126
|
}
|
|
130
127
|
return featureCollection(results);
|
|
131
128
|
}
|
|
132
|
-
__name(triangleGrid, "triangleGrid");
|
|
133
129
|
var turf_triangle_grid_default = triangleGrid;
|
|
134
130
|
export {
|
|
135
131
|
turf_triangle_grid_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n BBox,\n Feature,\n Polygon,\n FeatureCollection,\n GeoJsonProperties,\n} from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { intersect } from \"@turf/intersect\";\nimport { polygon, featureCollection, Units } from \"@turf/helpers\";\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n BBox,\n Feature,\n Polygon,\n FeatureCollection,\n GeoJsonProperties,\n} from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { intersect } from \"@turf/intersect\";\nimport { polygon, featureCollection, Units } from \"@turf/helpers\";\n\n/**\n * Creates a grid of triangular polygons.\n *\n * @name triangleGrid\n * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order\n * @param {number} cellSide dimension of each grid cell. Two triangles are created in each cell.\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] used in calculating cellSide. Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}\n * @param {Feature<Polygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} grid of polygons\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var triangleGrid = turf.triangleGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [triangleGrid];\n */\nfunction triangleGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon>;\n } = {}\n): FeatureCollection<Polygon, P> {\n // Containers\n var results: Feature<Polygon, P>[] = [];\n\n // Input Validation is being handled by Typescript\n\n // if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');\n // if (!isNumber(cellSide)) throw new Error('cellSide is invalid');\n // if (!bbox) throw new Error('bbox is required');\n // if (!Array.isArray(bbox)) throw new Error('bbox must be array');\n // if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');\n // if (mask && ['Polygon', 'MultiPolygon'].indexOf(getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');\n\n // Main\n var xFraction =\n cellSide / distance([bbox[0], bbox[1]], [bbox[2], bbox[1]], options);\n var cellWidth = xFraction * (bbox[2] - bbox[0]);\n var yFraction =\n cellSide / distance([bbox[0], bbox[1]], [bbox[0], bbox[3]], options);\n var cellHeight = yFraction * (bbox[3] - bbox[1]);\n\n var xi = 0;\n var currentX = bbox[0];\n while (currentX <= bbox[2]) {\n var yi = 0;\n var currentY = bbox[1];\n while (currentY <= bbox[3]) {\n var cellTriangle1 = null;\n var cellTriangle2 = null;\n\n if (xi % 2 === 0 && yi % 2 === 0) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY + cellHeight],\n ],\n ],\n options.properties\n );\n } else if (xi % 2 === 0 && yi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n } else if (yi % 2 === 0 && xi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n } else if (yi % 2 === 1 && xi % 2 === 1) {\n cellTriangle1 = polygon(\n [\n [\n [currentX, currentY],\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY],\n ],\n ],\n options.properties\n );\n cellTriangle2 = polygon(\n [\n [\n [currentX, currentY + cellHeight],\n [currentX + cellWidth, currentY + cellHeight],\n [currentX + cellWidth, currentY],\n [currentX, currentY + cellHeight],\n ],\n ],\n options.properties\n );\n }\n if (options.mask) {\n if (intersect(featureCollection([options.mask, cellTriangle1!])))\n results.push(cellTriangle1!);\n if (intersect(featureCollection([options.mask, cellTriangle2!])))\n results.push(cellTriangle2!);\n } else {\n results.push(cellTriangle1!);\n results.push(cellTriangle2!);\n }\n\n currentY += cellHeight;\n yi++;\n }\n xi++;\n currentX += cellWidth;\n }\n return featureCollection(results);\n}\n\nexport { triangleGrid };\nexport default triangleGrid;\n"],"mappings":";AAOA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,yBAAgC;AAuBlD,SAAS,aACP,MACA,UACA,UAII,CAAC,GAC0B;AAE/B,MAAI,UAAiC,CAAC;AAYtC,MAAI,YACF,WAAW,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,OAAO;AACrE,MAAI,YAAY,aAAa,KAAK,CAAC,IAAI,KAAK,CAAC;AAC7C,MAAI,YACF,WAAW,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,OAAO;AACrE,MAAI,aAAa,aAAa,KAAK,CAAC,IAAI,KAAK,CAAC;AAE9C,MAAI,KAAK;AACT,MAAI,WAAW,KAAK,CAAC;AACrB,SAAO,YAAY,KAAK,CAAC,GAAG;AAC1B,QAAI,KAAK;AACT,QAAI,WAAW,KAAK,CAAC;AACrB,WAAO,YAAY,KAAK,CAAC,GAAG;AAC1B,UAAI,gBAAgB;AACpB,UAAI,gBAAgB;AAEpB,UAAI,KAAK,MAAM,KAAK,KAAK,MAAM,GAAG;AAChC,wBAAgB;AAAA,UACd;AAAA,YACE;AAAA,cACE,CAAC,UAAU,QA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": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.70+948cdafaf",
|
|
4
4
|
"description": "turf triangle-grid module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@turf/bbox-polygon": "^7.0.
|
|
58
|
-
"@turf/truncate": "^7.0.
|
|
57
|
+
"@turf/bbox-polygon": "^7.1.0-alpha.70+948cdafaf",
|
|
58
|
+
"@turf/truncate": "^7.1.0-alpha.70+948cdafaf",
|
|
59
59
|
"@types/benchmark": "^2.1.5",
|
|
60
60
|
"@types/tape": "^4.2.32",
|
|
61
61
|
"benchmark": "^2.1.4",
|
|
@@ -68,10 +68,11 @@
|
|
|
68
68
|
"write-json-file": "^5.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@turf/distance": "^7.0.
|
|
72
|
-
"@turf/helpers": "^7.0.
|
|
73
|
-
"@turf/intersect": "^7.0.
|
|
71
|
+
"@turf/distance": "^7.1.0-alpha.70+948cdafaf",
|
|
72
|
+
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
|
|
73
|
+
"@turf/intersect": "^7.1.0-alpha.70+948cdafaf",
|
|
74
|
+
"@types/geojson": "^7946.0.10",
|
|
74
75
|
"tslib": "^2.6.2"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
|
|
77
78
|
}
|