@turf/triangle-grid 6.4.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 +10 -9
- package/dist/es/index.js +4 -5
- package/dist/js/index.d.ts +4 -3
- package/dist/js/index.js +7 -10
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
Takes a bounding box and a cell depth and returns a set of triangular [polygons][1] in a grid.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `options.units` **[string][5]** used in calculating cellSide, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
15
|
-
- `options.mask` **[Feature][6]<[Polygon][7]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
|
|
16
|
-
- `options.properties` **[Object][4]** passed to each point of the grid (optional, default `{}`)
|
|
11
|
+
* `bbox` **[Array][2]<[number][3]>** extent in \[minX, minY, maxX, maxY] order
|
|
12
|
+
* `cellSide` **[number][3]** dimension of each cell
|
|
13
|
+
* `options` **[Object][4]** Optional parameters (optional, default `{}`)
|
|
17
14
|
|
|
18
|
-
**
|
|
15
|
+
* `options.units` **[string][5]** used in calculating cellSide, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
16
|
+
* `options.mask` **[Feature][6]<[Polygon][7]>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
|
|
17
|
+
* `options.properties` **[Object][4]** passed to each point of the grid (optional, default `{}`)
|
|
18
|
+
|
|
19
|
+
### Examples
|
|
19
20
|
|
|
20
21
|
```javascript
|
|
21
22
|
var bbox = [-95, 30 ,-85, 40];
|
|
@@ -28,7 +29,7 @@ var triangleGrid = turf.triangleGrid(bbox, cellSide, options);
|
|
|
28
29
|
var addToMap = [triangleGrid];
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
Returns **[FeatureCollection][8]
|
|
32
|
+
Returns **[FeatureCollection][8]<[Polygon][7]>** grid of polygons
|
|
32
33
|
|
|
33
34
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
34
35
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import distance from "@turf/distance";
|
|
2
2
|
import intersect from "@turf/intersect";
|
|
3
|
-
import { polygon, featureCollection
|
|
3
|
+
import { polygon, featureCollection } from "@turf/helpers";
|
|
4
4
|
/**
|
|
5
5
|
* Takes a bounding box and a cell depth and returns a set of triangular {@link Polygon|polygons} in a grid.
|
|
6
6
|
*
|
|
@@ -22,8 +22,7 @@ import { polygon, featureCollection, } from "@turf/helpers";
|
|
|
22
22
|
* //addToMap
|
|
23
23
|
* var addToMap = [triangleGrid];
|
|
24
24
|
*/
|
|
25
|
-
function triangleGrid(bbox, cellSide, options) {
|
|
26
|
-
if (options === void 0) { options = {}; }
|
|
25
|
+
function triangleGrid(bbox, cellSide, options = {}) {
|
|
27
26
|
// Containers
|
|
28
27
|
var results = [];
|
|
29
28
|
// Input Validation is being handled by Typescript
|
|
@@ -119,9 +118,9 @@ function triangleGrid(bbox, cellSide, options) {
|
|
|
119
118
|
], options.properties);
|
|
120
119
|
}
|
|
121
120
|
if (options.mask) {
|
|
122
|
-
if (intersect(options.mask, cellTriangle1))
|
|
121
|
+
if (intersect(featureCollection([options.mask, cellTriangle1])))
|
|
123
122
|
results.push(cellTriangle1);
|
|
124
|
-
if (intersect(options.mask, cellTriangle2))
|
|
123
|
+
if (intersect(featureCollection([options.mask, cellTriangle2])))
|
|
125
124
|
results.push(cellTriangle2);
|
|
126
125
|
}
|
|
127
126
|
else {
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BBox, Feature, Polygon, FeatureCollection, GeoJsonProperties } from "geojson";
|
|
2
|
+
import { Units } from "@turf/helpers";
|
|
2
3
|
/**
|
|
3
4
|
* Takes a bounding box and a cell depth and returns a set of triangular {@link Polygon|polygons} in a grid.
|
|
4
5
|
*
|
|
@@ -20,9 +21,9 @@ import { Units, BBox, Feature, Polygon, FeatureCollection, Properties } from "@t
|
|
|
20
21
|
* //addToMap
|
|
21
22
|
* var addToMap = [triangleGrid];
|
|
22
23
|
*/
|
|
23
|
-
declare function triangleGrid<P =
|
|
24
|
+
declare function triangleGrid<P = GeoJsonProperties>(bbox: BBox, cellSide: number, options?: {
|
|
24
25
|
units?: Units;
|
|
25
26
|
properties?: P;
|
|
26
|
-
mask?: Feature<Polygon
|
|
27
|
+
mask?: Feature<Polygon>;
|
|
27
28
|
}): FeatureCollection<Polygon, P>;
|
|
28
29
|
export default triangleGrid;
|
package/dist/js/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
|
|
5
|
+
const intersect_1 = tslib_1.__importDefault(require("@turf/intersect"));
|
|
6
|
+
const helpers_1 = require("@turf/helpers");
|
|
9
7
|
/**
|
|
10
8
|
* Takes a bounding box and a cell depth and returns a set of triangular {@link Polygon|polygons} in a grid.
|
|
11
9
|
*
|
|
@@ -27,8 +25,7 @@ var helpers_1 = require("@turf/helpers");
|
|
|
27
25
|
* //addToMap
|
|
28
26
|
* var addToMap = [triangleGrid];
|
|
29
27
|
*/
|
|
30
|
-
function triangleGrid(bbox, cellSide, options) {
|
|
31
|
-
if (options === void 0) { options = {}; }
|
|
28
|
+
function triangleGrid(bbox, cellSide, options = {}) {
|
|
32
29
|
// Containers
|
|
33
30
|
var results = [];
|
|
34
31
|
// Input Validation is being handled by Typescript
|
|
@@ -124,9 +121,9 @@ function triangleGrid(bbox, cellSide, options) {
|
|
|
124
121
|
], options.properties);
|
|
125
122
|
}
|
|
126
123
|
if (options.mask) {
|
|
127
|
-
if (intersect_1.default(options.mask, cellTriangle1))
|
|
124
|
+
if (intersect_1.default(helpers_1.featureCollection([options.mask, cellTriangle1])))
|
|
128
125
|
results.push(cellTriangle1);
|
|
129
|
-
if (intersect_1.default(options.mask, cellTriangle2))
|
|
126
|
+
if (intersect_1.default(helpers_1.featureCollection([options.mask, cellTriangle2])))
|
|
130
127
|
results.push(cellTriangle2);
|
|
131
128
|
}
|
|
132
129
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/triangle-grid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf triangle-grid module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git://github.com/Turfjs/turf.git"
|
|
14
14
|
},
|
|
15
|
+
"funding": "https://opencollective.com/turf",
|
|
15
16
|
"publishConfig": {
|
|
16
17
|
"access": "public"
|
|
17
18
|
},
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
"docs": "node ../../scripts/generate-readmes",
|
|
46
47
|
"test": "npm-run-all test:*",
|
|
47
48
|
"test:tape": "ts-node -r esm test.js",
|
|
48
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
49
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@turf/bbox-polygon": "^
|
|
52
|
-
"@turf/truncate": "^
|
|
52
|
+
"@turf/bbox-polygon": "^7.0.0-alpha.0",
|
|
53
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
53
54
|
"@types/tape": "*",
|
|
54
55
|
"benchmark": "*",
|
|
55
56
|
"load-json-file": "*",
|
|
@@ -61,9 +62,10 @@
|
|
|
61
62
|
"write-json-file": "*"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@turf/distance": "^
|
|
65
|
-
"@turf/helpers": "^
|
|
66
|
-
"@turf/intersect": "^
|
|
65
|
+
"@turf/distance": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/intersect": "^7.0.0-alpha.0",
|
|
68
|
+
"tslib": "^2.3.0"
|
|
67
69
|
},
|
|
68
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
69
71
|
}
|