@map-colonies/mc-utils 1.9.0 → 2.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 +67 -67
- package/dist/arrays/index.d.ts +1 -1
- package/dist/arrays/index.d.ts.map +0 -0
- package/dist/arrays/index.js +17 -13
- package/dist/arrays/index.js.map +1 -1
- package/dist/arrays/subGroups.d.ts +8 -8
- package/dist/arrays/subGroups.d.ts.map +0 -0
- package/dist/arrays/subGroups.js +138 -138
- package/dist/arrays/subGroups.js.map +0 -0
- package/dist/communication/http/httpClient.d.ts +29 -28
- package/dist/communication/http/httpClient.d.ts.map +1 -1
- package/dist/communication/http/httpClient.js +434 -429
- package/dist/communication/http/httpClient.js.map +1 -1
- package/dist/communication/http/index.d.ts +1 -1
- package/dist/communication/http/index.d.ts.map +0 -0
- package/dist/communication/http/index.js +17 -13
- package/dist/communication/http/index.js.map +1 -1
- package/dist/communication/index.d.ts +1 -1
- package/dist/communication/index.d.ts.map +0 -0
- package/dist/communication/index.js +17 -13
- package/dist/communication/index.js.map +1 -1
- package/dist/dateTime/getUTCDate.d.ts +1 -1
- package/dist/dateTime/getUTCDate.d.ts.map +0 -0
- package/dist/dateTime/getUTCDate.js +10 -10
- package/dist/dateTime/getUTCDate.js.map +0 -0
- package/dist/dateTime/index.d.ts +1 -1
- package/dist/dateTime/index.d.ts.map +0 -0
- package/dist/dateTime/index.js +17 -13
- package/dist/dateTime/index.js.map +1 -1
- package/dist/geo/bboxUtils.d.ts +23 -23
- package/dist/geo/bboxUtils.d.ts.map +0 -0
- package/dist/geo/bboxUtils.js +89 -89
- package/dist/geo/bboxUtils.js.map +0 -0
- package/dist/geo/geoConvertor.d.ts +18 -18
- package/dist/geo/geoConvertor.d.ts.map +0 -0
- package/dist/geo/geoConvertor.js +51 -51
- package/dist/geo/geoConvertor.js.map +0 -0
- package/dist/geo/geoHash.d.ts +24 -24
- package/dist/geo/geoHash.d.ts.map +1 -1
- package/dist/geo/geoHash.js +274 -242
- package/dist/geo/geoHash.js.map +1 -1
- package/dist/geo/geoIntersection.d.ts +19 -19
- package/dist/geo/geoIntersection.d.ts.map +0 -0
- package/dist/geo/geoIntersection.js +70 -70
- package/dist/geo/geoIntersection.js.map +0 -0
- package/dist/geo/index.d.ts +8 -8
- package/dist/geo/index.d.ts.map +0 -0
- package/dist/geo/index.js +24 -20
- package/dist/geo/index.js.map +1 -1
- package/dist/geo/tileBatcher.d.ts +8 -8
- package/dist/geo/tileBatcher.d.ts.map +1 -1
- package/dist/geo/tileBatcher.js +188 -167
- package/dist/geo/tileBatcher.js.map +1 -1
- package/dist/geo/tileRanger.d.ts +46 -46
- package/dist/geo/tileRanger.d.ts.map +0 -0
- package/dist/geo/tileRanger.js +327 -327
- package/dist/geo/tileRanger.js.map +0 -0
- package/dist/geo/tiles.d.ts +82 -82
- package/dist/geo/tiles.d.ts.map +1 -1
- package/dist/geo/tiles.js +246 -238
- package/dist/geo/tiles.js.map +1 -1
- package/dist/geo/tilesGenerator.d.ts +2 -2
- package/dist/geo/tilesGenerator.d.ts.map +0 -0
- package/dist/geo/tilesGenerator.js +94 -94
- package/dist/geo/tilesGenerator.js.map +0 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/models/enums/gdal/dataType.d.ts +16 -16
- package/dist/models/enums/gdal/dataType.d.ts.map +0 -0
- package/dist/models/enums/gdal/dataType.js +20 -20
- package/dist/models/enums/gdal/dataType.js.map +0 -0
- package/dist/models/enums/gdal/index.d.ts +2 -2
- package/dist/models/enums/gdal/index.d.ts.map +0 -0
- package/dist/models/enums/gdal/index.js +18 -14
- package/dist/models/enums/gdal/index.js.map +1 -1
- package/dist/models/enums/gdal/resamplingMethod.d.ts +16 -16
- package/dist/models/enums/gdal/resamplingMethod.d.ts.map +0 -0
- package/dist/models/enums/gdal/resamplingMethod.js +20 -20
- package/dist/models/enums/gdal/resamplingMethod.js.map +0 -0
- package/dist/models/enums/geo/index.d.ts +1 -1
- package/dist/models/enums/geo/index.d.ts.map +0 -0
- package/dist/models/enums/geo/index.js +17 -13
- package/dist/models/enums/geo/index.js.map +1 -1
- package/dist/models/enums/geo/tileOrigin.d.ts +7 -7
- package/dist/models/enums/geo/tileOrigin.d.ts.map +0 -0
- package/dist/models/enums/geo/tileOrigin.js +11 -11
- package/dist/models/enums/geo/tileOrigin.js.map +0 -0
- package/dist/models/enums/index.d.ts +2 -2
- package/dist/models/enums/index.d.ts.map +0 -0
- package/dist/models/enums/index.js +18 -14
- package/dist/models/enums/index.js.map +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +0 -0
- package/dist/models/index.js +18 -14
- package/dist/models/index.js.map +1 -1
- package/dist/models/interfaces/geo/iPoint.d.ts +7 -7
- package/dist/models/interfaces/geo/iPoint.d.ts.map +0 -0
- package/dist/models/interfaces/geo/iPoint.js +2 -2
- package/dist/models/interfaces/geo/iPoint.js.map +0 -0
- package/dist/models/interfaces/geo/iTile.d.ts +15 -15
- package/dist/models/interfaces/geo/iTile.d.ts.map +0 -0
- package/dist/models/interfaces/geo/iTile.js +2 -2
- package/dist/models/interfaces/geo/iTile.js.map +0 -0
- package/dist/models/interfaces/geo/index.d.ts +2 -2
- package/dist/models/interfaces/geo/index.d.ts.map +0 -0
- package/dist/models/interfaces/geo/index.js +18 -14
- package/dist/models/interfaces/geo/index.js.map +1 -1
- package/dist/models/interfaces/index.d.ts +1 -1
- package/dist/models/interfaces/index.d.ts.map +0 -0
- package/dist/models/interfaces/index.js +17 -13
- package/dist/models/interfaces/index.js.map +1 -1
- package/package.json +79 -79
package/dist/geo/tiles.js
CHANGED
|
@@ -1,239 +1,247 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.featureCollectionToTilesCount = exports.featureToTilesCount = exports.tileRangeToTilesCount = exports.tileToBbox = exports.degreesPerPixelToZoomLevel = exports.zoomLevelToResolutionMeter = exports.zoomLevelToResolutionDeg = exports.flipYAxis = exports.degreesPerPixel = exports.degreesPerTile = void 0;
|
|
15
|
-
var turf_1 = require("@turf/turf");
|
|
16
|
-
var bboxUtils_1 = require("./bboxUtils");
|
|
17
|
-
var geoConvertor_1 = require("./geoConvertor");
|
|
18
|
-
var zoomToResolutionDegMapper = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* @param
|
|
210
|
-
*
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.featureCollectionToTilesCount = exports.featureToTilesCount = exports.tileRangeToTilesCount = exports.tileToBbox = exports.degreesPerPixelToZoomLevel = exports.zoomLevelToResolutionMeter = exports.zoomLevelToResolutionDeg = exports.flipYAxis = exports.degreesPerPixel = exports.degreesPerTile = void 0;
|
|
15
|
+
var turf_1 = require("@turf/turf");
|
|
16
|
+
var bboxUtils_1 = require("./bboxUtils");
|
|
17
|
+
var geoConvertor_1 = require("./geoConvertor");
|
|
18
|
+
var zoomToResolutionDegMapper = {
|
|
19
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
20
|
+
0: 0.703125,
|
|
21
|
+
1: 0.3515625,
|
|
22
|
+
2: 0.17578125,
|
|
23
|
+
3: 0.087890625,
|
|
24
|
+
4: 0.0439453125,
|
|
25
|
+
5: 0.02197265625,
|
|
26
|
+
6: 0.010986328125,
|
|
27
|
+
7: 0.0054931640625,
|
|
28
|
+
8: 0.00274658203125,
|
|
29
|
+
9: 0.001373291015625,
|
|
30
|
+
10: 0.0006866455078125,
|
|
31
|
+
11: 0.00034332275390625,
|
|
32
|
+
12: 0.000171661376953125,
|
|
33
|
+
13: 0.0000858306884765625,
|
|
34
|
+
14: 0.0000429153442382812,
|
|
35
|
+
15: 0.0000214576721191406,
|
|
36
|
+
16: 0.0000107288360595703,
|
|
37
|
+
17: 0.00000536441802978516,
|
|
38
|
+
18: 0.00000268220901489258,
|
|
39
|
+
19: 0.00000134110450744629,
|
|
40
|
+
20: 0.000000670552253723145,
|
|
41
|
+
21: 0.000000335276126861572,
|
|
42
|
+
22: 0.000000167638063430786,
|
|
43
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
44
|
+
};
|
|
45
|
+
var zoomToResolutionMeterMapper = {
|
|
46
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
47
|
+
0: 78271.52,
|
|
48
|
+
1: 39135.76,
|
|
49
|
+
2: 19567.88,
|
|
50
|
+
3: 9783.94,
|
|
51
|
+
4: 4891.97,
|
|
52
|
+
5: 2445.98,
|
|
53
|
+
6: 1222.99,
|
|
54
|
+
7: 611.5,
|
|
55
|
+
8: 305.75,
|
|
56
|
+
9: 152.87,
|
|
57
|
+
10: 76.44,
|
|
58
|
+
11: 38.22,
|
|
59
|
+
12: 19.11,
|
|
60
|
+
13: 9.55,
|
|
61
|
+
14: 4.78,
|
|
62
|
+
15: 2.39,
|
|
63
|
+
16: 1.19,
|
|
64
|
+
17: 0.6,
|
|
65
|
+
18: 0.3,
|
|
66
|
+
19: 0.15,
|
|
67
|
+
20: 0.075,
|
|
68
|
+
21: 0.037,
|
|
69
|
+
22: 0.0185,
|
|
70
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* calculates tile size (resolution) in degrees
|
|
74
|
+
* @param zoomLevel zoom level of returned tile size
|
|
75
|
+
* @returns tile size (resolution) in degrees
|
|
76
|
+
*/
|
|
77
|
+
function degreesPerTile(zoomLevel) {
|
|
78
|
+
var latRange = 180;
|
|
79
|
+
return latRange / (1 << zoomLevel);
|
|
80
|
+
}
|
|
81
|
+
exports.degreesPerTile = degreesPerTile;
|
|
82
|
+
/**
|
|
83
|
+
* returns pixel size (resolution) in degrees
|
|
84
|
+
* @param zoomLevel tile zoom level of returned tile pixel size
|
|
85
|
+
* @returns pixel size (resolution) in degrees
|
|
86
|
+
*/
|
|
87
|
+
function degreesPerPixel(zoomLevel) {
|
|
88
|
+
var tileSize = 256;
|
|
89
|
+
var tileRes = degreesPerTile(zoomLevel);
|
|
90
|
+
return tileRes / tileSize;
|
|
91
|
+
}
|
|
92
|
+
exports.degreesPerPixel = degreesPerPixel;
|
|
93
|
+
/**
|
|
94
|
+
* coverts tile coordinates between ll and ul
|
|
95
|
+
* @param tile source tile
|
|
96
|
+
* @returns converted tile
|
|
97
|
+
*/
|
|
98
|
+
function flipYAxis(tile) {
|
|
99
|
+
var yTiles = 1 << tile.zoom;
|
|
100
|
+
return {
|
|
101
|
+
x: tile.x,
|
|
102
|
+
y: yTiles - tile.y - 1,
|
|
103
|
+
zoom: tile.zoom,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
exports.flipYAxis = flipYAxis;
|
|
107
|
+
/**
|
|
108
|
+
* converts zoom level (integer) to matching resolution degree value
|
|
109
|
+
* @param zoom zoom level in range of 0-22
|
|
110
|
+
* @returns resolution represented in degrees, or undefined if zoom level is out of range
|
|
111
|
+
*/
|
|
112
|
+
function zoomLevelToResolutionDeg(zoom) {
|
|
113
|
+
return zoomToResolutionDegMapper[zoom];
|
|
114
|
+
}
|
|
115
|
+
exports.zoomLevelToResolutionDeg = zoomLevelToResolutionDeg;
|
|
116
|
+
/**
|
|
117
|
+
* converts zoom level (integer) to matching resolution meter value
|
|
118
|
+
* @param zoom zoom level in range of 0-22
|
|
119
|
+
* @returns resolution represented in Meters, or undefined if zoom level is out of range
|
|
120
|
+
*/
|
|
121
|
+
function zoomLevelToResolutionMeter(zoom) {
|
|
122
|
+
return zoomToResolutionMeterMapper[zoom];
|
|
123
|
+
}
|
|
124
|
+
exports.zoomLevelToResolutionMeter = zoomLevelToResolutionMeter;
|
|
125
|
+
/**
|
|
126
|
+
* converts pixel size (resolution) in degrees to matching zoom level (rounded down)
|
|
127
|
+
* @param resolution pixel size (resolution) in degrees
|
|
128
|
+
* @returns zoom level for given pixel size
|
|
129
|
+
*/
|
|
130
|
+
function degreesPerPixelToZoomLevel(resolution) {
|
|
131
|
+
var MIN_ZOOM_LEVEL = 0;
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
133
|
+
var zoomLevel = Math.floor(Math.log2(180 / (resolution * 256)));
|
|
134
|
+
if (zoomLevel < MIN_ZOOM_LEVEL) {
|
|
135
|
+
throw new Error("Invalid zoom level ".concat(zoomLevel, " for resolution ").concat(resolution));
|
|
136
|
+
}
|
|
137
|
+
return zoomLevel;
|
|
138
|
+
}
|
|
139
|
+
exports.degreesPerPixelToZoomLevel = degreesPerPixelToZoomLevel;
|
|
140
|
+
/**
|
|
141
|
+
* returns bbox of given tile
|
|
142
|
+
* @param tile
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
function tileToBbox(tile) {
|
|
146
|
+
var minPoint = (0, geoConvertor_1.tileToDegrees)(tile);
|
|
147
|
+
var tileSize = degreesPerTile(tile.zoom);
|
|
148
|
+
return [minPoint.longitude, minPoint.latitude, minPoint.longitude + tileSize, minPoint.latitude + tileSize];
|
|
149
|
+
}
|
|
150
|
+
exports.tileToBbox = tileToBbox;
|
|
151
|
+
/**
|
|
152
|
+
* returns the batch area
|
|
153
|
+
* @param ITileRange
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
function tileRangeToTilesCount(batch) {
|
|
157
|
+
return (batch.maxX - batch.minX) * (batch.maxY - batch.minY);
|
|
158
|
+
}
|
|
159
|
+
exports.tileRangeToTilesCount = tileRangeToTilesCount;
|
|
160
|
+
/**
|
|
161
|
+
* returns tiles amount of given feature and zoom ranges - based on 2:1 tile scheme
|
|
162
|
+
* use the bboxToTileRange method and provide sanitized bbox coverage of tiles
|
|
163
|
+
* @param feature
|
|
164
|
+
* If feature's properties include attributes of "maxResolutionDeg" and "minResolutionDeg" or just one of them -
|
|
165
|
+
* It will be converted to maxZoom and minZoom instead of default params to calculate
|
|
166
|
+
* minResolutionDeg >= 0.703125
|
|
167
|
+
* maxResolutionDeg <= 0.000000167638063430786
|
|
168
|
+
* @param layerFootprint - referenced layer geometry to snap on the bbox
|
|
169
|
+
* @param defaultMaxZoom optional - default is 22 - if maxResolutionDeg property was provided, the param will be ignored
|
|
170
|
+
* @param defaultMinZoom optional - default is 0 - if minResolutionDeg property was provided, the param will be ignored
|
|
171
|
+
* @returns tile count included on provided feature and zooms ranges
|
|
172
|
+
*/
|
|
173
|
+
function featureToTilesCount(feature, defaultMaxZoom, defaultMinZoom) {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
if (defaultMaxZoom === void 0) { defaultMaxZoom = 22; }
|
|
176
|
+
if (defaultMinZoom === void 0) { defaultMinZoom = 0; }
|
|
177
|
+
var tilesTotalAmount = 0;
|
|
178
|
+
if (defaultMaxZoom > 22 || defaultMinZoom < 0) {
|
|
179
|
+
throw new RangeError("Un supported zoom levels values, min-max zoom should be [0-22] but actual [".concat(defaultMinZoom, ":").concat(defaultMaxZoom, "]"));
|
|
180
|
+
}
|
|
181
|
+
if (defaultMinZoom > defaultMaxZoom) {
|
|
182
|
+
throw new RangeError("Illegal - defaultMinZoom[".concat(defaultMinZoom, "] is larger than defaultMaxZoom[").concat(defaultMaxZoom, "]"));
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
var targetMaxZoom = ((_a = feature.properties) === null || _a === void 0 ? void 0 : _a.maxResolutionDeg) !== undefined && typeof feature.properties.maxResolutionDeg === 'number'
|
|
186
|
+
? degreesPerPixelToZoomLevel(feature.properties.maxResolutionDeg)
|
|
187
|
+
: defaultMaxZoom;
|
|
188
|
+
var targetMinZoom = ((_b = feature.properties) === null || _b === void 0 ? void 0 : _b.minResolutionDeg) !== undefined && typeof feature.properties.minResolutionDeg === 'number'
|
|
189
|
+
? degreesPerPixelToZoomLevel(feature.properties.minResolutionDeg)
|
|
190
|
+
: defaultMinZoom;
|
|
191
|
+
var sanitized = (0, bboxUtils_1.snapBBoxToTileGrid)((0, turf_1.bbox)(feature.geometry), targetMaxZoom);
|
|
192
|
+
for (var i = targetMinZoom; i <= targetMaxZoom; i++) {
|
|
193
|
+
var zoomTilesBatch = (0, bboxUtils_1.bboxToTileRange)(sanitized, i);
|
|
194
|
+
tilesTotalAmount += tileRangeToTilesCount(zoomTilesBatch);
|
|
195
|
+
}
|
|
196
|
+
return tilesTotalAmount;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
var message = "Error occurred while trying to calculate tiles amount - encodeFootprint error: ".concat(JSON.stringify(error));
|
|
200
|
+
throw new Error(message);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.featureToTilesCount = featureToTilesCount;
|
|
204
|
+
/**
|
|
205
|
+
* returns tiles amount of given featureCollection [each feature may include maxResolutionDeg and minResolutionDeg
|
|
206
|
+
* if no resolutions in property will calculate all features with optional argument]
|
|
207
|
+
* based on 2:1 tile scheme
|
|
208
|
+
* use the bboxToTileRange method and provide sanitized bbox coverage of tiles
|
|
209
|
+
* @param fc - FeatureCollection
|
|
210
|
+
* foreach feature in featuresCollection features array:
|
|
211
|
+
* If feature's properties include attributes of "maxResolutionDeg" and "minResolutionDeg" or just one of them -
|
|
212
|
+
* It will be converted to maxZoom and minZoom instead of default params to calculate
|
|
213
|
+
* minResolutionDeg >= 0.703125
|
|
214
|
+
* maxResolutionDeg <= 0.000000167638063430786
|
|
215
|
+
* for current feature in the array
|
|
216
|
+
* @param defaultMaxZoom optional - default is 22 - if maxResolutionDeg property was provided, the param will be ignored
|
|
217
|
+
* @param defaultMinZoom optional - default is 0 - if minResolutionDeg property was provided, the param will be ignored
|
|
218
|
+
* @returns tile count included on provided feature and zooms ranges
|
|
219
|
+
*/
|
|
220
|
+
function featureCollectionToTilesCount(fc, defaultMaxZoom, defaultMinZoom) {
|
|
221
|
+
var e_1, _a;
|
|
222
|
+
if (defaultMaxZoom === void 0) { defaultMaxZoom = 22; }
|
|
223
|
+
if (defaultMinZoom === void 0) { defaultMinZoom = 0; }
|
|
224
|
+
var tilesTotalAmount = 0;
|
|
225
|
+
try {
|
|
226
|
+
try {
|
|
227
|
+
for (var _b = __values(fc.features), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
228
|
+
var feature = _c.value;
|
|
229
|
+
tilesTotalAmount += featureToTilesCount(feature, defaultMaxZoom, defaultMinZoom);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
233
|
+
finally {
|
|
234
|
+
try {
|
|
235
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
236
|
+
}
|
|
237
|
+
finally { if (e_1) throw e_1.error; }
|
|
238
|
+
}
|
|
239
|
+
return tilesTotalAmount;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
var message = "Error occurred while trying to calculate tiles amount - encodeFootprint error: ".concat(JSON.stringify(error));
|
|
243
|
+
throw new Error(message);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.featureCollectionToTilesCount = featureCollectionToTilesCount;
|
|
239
247
|
//# sourceMappingURL=tiles.js.map
|
package/dist/geo/tiles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../src/geo/tiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,mCAAqF;AAErF,yCAAkE;AAClE,+CAA+C;AAE/C,IAAM,yBAAyB,GAA2B;IACxD,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,cAAc;IACjB,CAAC,EAAE,eAAe;IAClB,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,iBAAiB;IACpB,EAAE,EAAE,kBAAkB;IACtB,EAAE,EAAE,mBAAmB;IACvB,EAAE,EAAE,oBAAoB;IACxB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,uBAAuB;
|
|
1
|
+
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../src/geo/tiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,mCAAqF;AAErF,yCAAkE;AAClE,+CAA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AmB,CAAC,OAA0C,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;aACrH;;;;;;;;;QACD,OAAO,gBAAgB,CAAC;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,IAAM,OAAO,GAAG,yFAAkF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAE,CAAC;QAC1H,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KAC1B;AACH,CAAC;AAXD,sEAWC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ITile, ITileRange } from '../models/interfaces/geo/iTile';
|
|
2
|
-
export declare function tilesGenerator(rangeGen: Iterable<ITileRange>): Generator<ITile>;
|
|
1
|
+
import { ITile, ITileRange } from '../models/interfaces/geo/iTile';
|
|
2
|
+
export declare function tilesGenerator(rangeGen: Iterable<ITileRange>): Generator<ITile>;
|
|
3
3
|
//# sourceMappingURL=tilesGenerator.d.ts.map
|
|
File without changes
|