@map-colonies/mc-utils 2.0.0 → 2.0.2
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 -17
- package/dist/arrays/index.js.map +0 -0
- 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 -29
- package/dist/communication/http/httpClient.d.ts.map +0 -0
- package/dist/communication/http/httpClient.js +434 -434
- package/dist/communication/http/httpClient.js.map +0 -0
- 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 -17
- package/dist/communication/http/index.js.map +0 -0
- package/dist/communication/index.d.ts +1 -1
- package/dist/communication/index.d.ts.map +0 -0
- package/dist/communication/index.js +17 -17
- package/dist/communication/index.js.map +0 -0
- 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 -17
- package/dist/dateTime/index.js.map +0 -0
- 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 +0 -0
- package/dist/geo/geoHash.js +246 -246
- package/dist/geo/geoHash.js.map +0 -0
- 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 -24
- package/dist/geo/index.js.map +0 -0
- package/dist/geo/tileBatcher.d.ts +8 -8
- package/dist/geo/tileBatcher.d.ts.map +0 -0
- package/dist/geo/tileBatcher.js +167 -167
- package/dist/geo/tileBatcher.js.map +0 -0
- 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 +0 -0
- package/dist/geo/tiles.js +246 -246
- package/dist/geo/tiles.js.map +0 -0
- 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 -21
- package/dist/index.js.map +0 -0
- 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 -18
- package/dist/models/enums/gdal/index.js.map +0 -0
- 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 -17
- package/dist/models/enums/geo/index.js.map +0 -0
- 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 -18
- package/dist/models/enums/index.js.map +0 -0
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +0 -0
- package/dist/models/index.js +18 -18
- package/dist/models/index.js.map +0 -0
- 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 -18
- package/dist/models/interfaces/geo/index.js.map +0 -0
- 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 -17
- package/dist/models/interfaces/index.js.map +0 -0
- package/package.json +79 -79
package/dist/geo/tileRanger.js
CHANGED
|
@@ -1,328 +1,328 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
-
function step(op) {
|
|
7
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
-
while (_) try {
|
|
9
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
-
switch (op[0]) {
|
|
12
|
-
case 0: case 1: t = op; break;
|
|
13
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
-
default:
|
|
17
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
-
if (t[2]) _.ops.pop();
|
|
22
|
-
_.trys.pop(); continue;
|
|
23
|
-
}
|
|
24
|
-
op = body.call(thisArg, _);
|
|
25
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var __values = (this && this.__values) || function(o) {
|
|
30
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
31
|
-
if (m) return m.call(o);
|
|
32
|
-
if (o && typeof o.length === "number") return {
|
|
33
|
-
next: function () {
|
|
34
|
-
if (o && i >= o.length) o = void 0;
|
|
35
|
-
return { value: o && o[i++], done: !o };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.TileRanger = void 0;
|
|
42
|
-
var turf_1 = require("@turf/turf");
|
|
43
|
-
var bboxUtils_1 = require("./bboxUtils");
|
|
44
|
-
var tiles_1 = require("./tiles");
|
|
45
|
-
var tilesGenerator_1 = require("./tilesGenerator");
|
|
46
|
-
var TileIntersectionState;
|
|
47
|
-
(function (TileIntersectionState) {
|
|
48
|
-
TileIntersectionState["FULL"] = "full";
|
|
49
|
-
TileIntersectionState["PARTIAL"] = "partial";
|
|
50
|
-
TileIntersectionState["NONE"] = "none";
|
|
51
|
-
})(TileIntersectionState || (TileIntersectionState = {}));
|
|
52
|
-
/**
|
|
53
|
-
* class for generating and decoding tile hashes
|
|
54
|
-
*/
|
|
55
|
-
var TileRanger = /** @class */ (function () {
|
|
56
|
-
function TileRanger() {
|
|
57
|
-
this.tileFootprintIntersection = function (tile, intersectionParams) {
|
|
58
|
-
var tileBbox = (0, tiles_1.tileToBbox)(tile);
|
|
59
|
-
var tilePoly = (0, turf_1.bboxPolygon)(tileBbox);
|
|
60
|
-
var intersection = (0, turf_1.intersect)(intersectionParams.footprint, tilePoly);
|
|
61
|
-
if (intersection === null) {
|
|
62
|
-
return TileIntersectionState.NONE;
|
|
63
|
-
}
|
|
64
|
-
// stop condition
|
|
65
|
-
if (tile.zoom === intersectionParams.maxZoom) {
|
|
66
|
-
return TileIntersectionState.FULL;
|
|
67
|
-
}
|
|
68
|
-
var intArea = (0, turf_1.area)(intersection);
|
|
69
|
-
var hashArea = (0, turf_1.area)(tilePoly);
|
|
70
|
-
if (intArea == hashArea) {
|
|
71
|
-
return TileIntersectionState.FULL;
|
|
72
|
-
}
|
|
73
|
-
return TileIntersectionState.PARTIAL;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* converts tile to tile range of specified zoom level
|
|
78
|
-
* @param tile
|
|
79
|
-
* @param zoom target tile range zoom
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
TileRanger.prototype.tileToRange = function (tile, zoom) {
|
|
83
|
-
var minX, minY, maxX, maxY;
|
|
84
|
-
minX = tile.x;
|
|
85
|
-
maxX = tile.x + 1;
|
|
86
|
-
minY = tile.y;
|
|
87
|
-
maxY = tile.y + 1;
|
|
88
|
-
if (tile.zoom < zoom) {
|
|
89
|
-
var dz = zoom - tile.zoom;
|
|
90
|
-
minX = minX << dz;
|
|
91
|
-
maxX = maxX << dz;
|
|
92
|
-
minY = minY << dz;
|
|
93
|
-
maxY = maxY << dz;
|
|
94
|
-
}
|
|
95
|
-
else if (tile.zoom > zoom) {
|
|
96
|
-
var dz = tile.zoom - zoom;
|
|
97
|
-
minX = minX >> dz;
|
|
98
|
-
minY = minY >> dz;
|
|
99
|
-
maxX = minX + 1;
|
|
100
|
-
maxY = minY + 1;
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
minX: minX,
|
|
104
|
-
minY: minY,
|
|
105
|
-
maxX: maxX,
|
|
106
|
-
maxY: maxY,
|
|
107
|
-
zoom: zoom,
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* generate tile hashes
|
|
112
|
-
* @param footprint footprint to cover with generated tile hashes
|
|
113
|
-
* @param zoom max hash zoom
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
TileRanger.prototype.encodeFootprint = function (footprint, zoom, verbose) {
|
|
117
|
-
var bbox, tileRange, intersectionParams;
|
|
118
|
-
if (verbose === void 0) { verbose = false; }
|
|
119
|
-
return __generator(this, function (_a) {
|
|
120
|
-
switch (_a.label) {
|
|
121
|
-
case 0:
|
|
122
|
-
////////////////////////////////
|
|
123
|
-
/// Step 1: check if the footprint is identical to its bbox
|
|
124
|
-
////////////////////////////////
|
|
125
|
-
if (verbose) {
|
|
126
|
-
console.log('encode footprint');
|
|
127
|
-
}
|
|
128
|
-
bbox = (0, turf_1.bbox)(footprint);
|
|
129
|
-
if (!this.isBbox(footprint)) return [3 /*break*/, 2];
|
|
130
|
-
tileRange = (0, bboxUtils_1.bboxToTileRange)(bbox, zoom);
|
|
131
|
-
if (verbose) {
|
|
132
|
-
console.log("footprint is identical to its bbox - return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
133
|
-
}
|
|
134
|
-
return [4 /*yield*/, tileRange];
|
|
135
|
-
case 1:
|
|
136
|
-
_a.sent();
|
|
137
|
-
return [3 /*break*/, 4];
|
|
138
|
-
case 2:
|
|
139
|
-
intersectionParams = {
|
|
140
|
-
footprint: footprint,
|
|
141
|
-
maxZoom: zoom,
|
|
142
|
-
};
|
|
143
|
-
if (verbose) {
|
|
144
|
-
console.log('footprint is different from its bbox - generateRanges');
|
|
145
|
-
}
|
|
146
|
-
return [5 /*yield**/, __values(this.generateRanges(bbox, zoom, intersectionParams, this.tileFootprintIntersection, verbose))];
|
|
147
|
-
case 3:
|
|
148
|
-
_a.sent();
|
|
149
|
-
_a.label = 4;
|
|
150
|
-
case 4: return [2 /*return*/];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
TileRanger.prototype.generateTiles = function (area, zoom) {
|
|
155
|
-
var gen;
|
|
156
|
-
if (Array.isArray(area)) {
|
|
157
|
-
gen = [(0, bboxUtils_1.bboxToTileRange)(area, zoom)];
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
gen = this.encodeFootprint(area, zoom);
|
|
161
|
-
}
|
|
162
|
-
return (0, tilesGenerator_1.tilesGenerator)(gen);
|
|
163
|
-
};
|
|
164
|
-
TileRanger.prototype.generateRanges = function (bbox, zoom, intersectionTarget, intersectionFunction, verbose) {
|
|
165
|
-
var boundingRange, bboxString, dx, dy, minXZoom, minYZoom, minZoom, minimalRange, x, y, tile, intersection, tileRange;
|
|
166
|
-
if (verbose === void 0) { verbose = false; }
|
|
167
|
-
return __generator(this, function (_a) {
|
|
168
|
-
switch (_a.label) {
|
|
169
|
-
case 0:
|
|
170
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
171
|
-
/// Step 3: Convert the bbox to tile range of the requested zoom
|
|
172
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
173
|
-
if (verbose) {
|
|
174
|
-
console.log('Convert the bbox to tile range of the requested zoom');
|
|
175
|
-
}
|
|
176
|
-
boundingRange = (0, bboxUtils_1.bboxToTileRange)(bbox, zoom);
|
|
177
|
-
if (verbose) {
|
|
178
|
-
bboxString = "BBOX[0]: ".concat(bbox[0], ", BBOX[1]: ").concat(bbox[1], ", BBOX[2]: ").concat(bbox[2], ", BBOX[3]: ").concat(bbox[3]);
|
|
179
|
-
console.log("".concat(bboxString, ", Zoom: ").concat(zoom, ", bounding range: minX: ").concat(boundingRange.minX, ", maxX: ").concat(boundingRange.maxX, ", minY: ").concat(boundingRange.minY, ", maxY: ").concat(boundingRange.maxY));
|
|
180
|
-
}
|
|
181
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
182
|
-
/// Step 4: Use range size to calculate zoom level where the target area is smaller then 1 tile
|
|
183
|
-
/// (use zoom zero in-case there is no such zoom, for example in global bbox).
|
|
184
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
185
|
-
// find minimal zoom where the the area can be converted by area the size of single tile to skip levels that can't have full hashes
|
|
186
|
-
if (verbose) {
|
|
187
|
-
console.log("find minimal zoom where the the area can be converted by area the size of single tile to skip levels that can't have full hashes");
|
|
188
|
-
}
|
|
189
|
-
dx = boundingRange.maxX - boundingRange.minX;
|
|
190
|
-
dy = boundingRange.maxY - boundingRange.minY;
|
|
191
|
-
minXZoom = Math.max(Math.floor(Math.log2(1 << (zoom + 1)) / dx) - 1, 0);
|
|
192
|
-
minYZoom = Math.max(Math.floor(Math.log2(1 << zoom) / dy), 0);
|
|
193
|
-
minZoom = Math.min(minXZoom, minYZoom);
|
|
194
|
-
if (verbose) {
|
|
195
|
-
console.log("MinZoom: ".concat(minZoom));
|
|
196
|
-
}
|
|
197
|
-
minimalRange = (0, bboxUtils_1.bboxToTileRange)(bbox, minZoom);
|
|
198
|
-
x = minimalRange.minX;
|
|
199
|
-
_a.label = 1;
|
|
200
|
-
case 1:
|
|
201
|
-
if (!(x < minimalRange.maxX)) return [3 /*break*/, 8];
|
|
202
|
-
y = minimalRange.minY;
|
|
203
|
-
_a.label = 2;
|
|
204
|
-
case 2:
|
|
205
|
-
if (!(y < minimalRange.maxY)) return [3 /*break*/, 7];
|
|
206
|
-
tile = { x: x, y: y, zoom: minimalRange.zoom };
|
|
207
|
-
intersection = intersectionFunction(tile, intersectionTarget);
|
|
208
|
-
if (verbose) {
|
|
209
|
-
console.log("Tile X: ".concat(tile.x, ", Y: ").concat(tile.y, " zoom ").concat(tile.zoom, ", intersection: ").concat(intersection));
|
|
210
|
-
}
|
|
211
|
-
if (!(intersection === TileIntersectionState.FULL)) return [3 /*break*/, 4];
|
|
212
|
-
tileRange = this.tileToRange(tile, zoom);
|
|
213
|
-
if (verbose) {
|
|
214
|
-
console.log("return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
215
|
-
}
|
|
216
|
-
return [4 /*yield*/, tileRange];
|
|
217
|
-
case 3:
|
|
218
|
-
_a.sent();
|
|
219
|
-
return [3 /*break*/, 6];
|
|
220
|
-
case 4:
|
|
221
|
-
if (!(intersection === TileIntersectionState.PARTIAL)) return [3 /*break*/, 6];
|
|
222
|
-
/// if it partly covered:
|
|
223
|
-
// calculate the sub tiles contained in the current tile (in the next zoom level)
|
|
224
|
-
// for every sub tile recursively run step 6
|
|
225
|
-
//optimize partial base hashes
|
|
226
|
-
return [5 /*yield**/, __values(this.optimizeHash(tile, zoom, intersectionTarget, intersectionFunction, verbose))];
|
|
227
|
-
case 5:
|
|
228
|
-
/// if it partly covered:
|
|
229
|
-
// calculate the sub tiles contained in the current tile (in the next zoom level)
|
|
230
|
-
// for every sub tile recursively run step 6
|
|
231
|
-
//optimize partial base hashes
|
|
232
|
-
_a.sent();
|
|
233
|
-
_a.label = 6;
|
|
234
|
-
case 6:
|
|
235
|
-
y++;
|
|
236
|
-
return [3 /*break*/, 2];
|
|
237
|
-
case 7:
|
|
238
|
-
x++;
|
|
239
|
-
return [3 /*break*/, 1];
|
|
240
|
-
case 8: return [2 /*return*/];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* generate tile
|
|
246
|
-
* @param tile tile to get all intersecting tiles from
|
|
247
|
-
* @param targetZoom target tiles zoom level
|
|
248
|
-
* @param intersectionTarget original zoom level and footprint to intersect
|
|
249
|
-
* @param intersectionFunction the intersection function to be called
|
|
250
|
-
*/
|
|
251
|
-
TileRanger.prototype.optimizeHash = function (tile, targetZoom, intersectionTarget, intersectionFunction, verbose) {
|
|
252
|
-
var tiles, tiles_2, tiles_2_1, subTile, intersection, tileRange, e_1_1;
|
|
253
|
-
var e_1, _a;
|
|
254
|
-
if (verbose === void 0) { verbose = false; }
|
|
255
|
-
return __generator(this, function (_b) {
|
|
256
|
-
switch (_b.label) {
|
|
257
|
-
case 0:
|
|
258
|
-
/// generate from a tile the next zoom level tiles that compose the tile
|
|
259
|
-
if (verbose) {
|
|
260
|
-
console.log("optimizeHash: Tile X: ".concat(tile.x, ", Y: ").concat(tile.y, " zoom ").concat(tile.zoom, ", intersectionTarget ").concat(intersectionTarget.maxZoom, ", - generate from a tile the next zoom level tiles that compose the tile"));
|
|
261
|
-
}
|
|
262
|
-
tiles = this.generateSubTiles(tile);
|
|
263
|
-
_b.label = 1;
|
|
264
|
-
case 1:
|
|
265
|
-
_b.trys.push([1, 8, 9, 10]);
|
|
266
|
-
tiles_2 = __values(tiles), tiles_2_1 = tiles_2.next();
|
|
267
|
-
_b.label = 2;
|
|
268
|
-
case 2:
|
|
269
|
-
if (!!tiles_2_1.done) return [3 /*break*/, 7];
|
|
270
|
-
subTile = tiles_2_1.value;
|
|
271
|
-
intersection = intersectionFunction(subTile, intersectionTarget);
|
|
272
|
-
if (verbose) {
|
|
273
|
-
console.log("Tile X: ".concat(subTile.x, ", Y: ").concat(subTile.y, " zoom ").concat(subTile.zoom, ", intersection: ").concat(intersection));
|
|
274
|
-
}
|
|
275
|
-
if (!(intersection === TileIntersectionState.FULL)) return [3 /*break*/, 4];
|
|
276
|
-
tileRange = this.tileToRange(subTile, targetZoom);
|
|
277
|
-
if (verbose) {
|
|
278
|
-
console.log("return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
279
|
-
}
|
|
280
|
-
return [4 /*yield*/, tileRange];
|
|
281
|
-
case 3:
|
|
282
|
-
_b.sent();
|
|
283
|
-
return [3 /*break*/, 6];
|
|
284
|
-
case 4:
|
|
285
|
-
if (!(intersection === TileIntersectionState.PARTIAL)) return [3 /*break*/, 6];
|
|
286
|
-
/// if it partly covered:
|
|
287
|
-
// calculate the sub tiles contained in the current tile (in the next zoom level) - recursive
|
|
288
|
-
return [5 /*yield**/, __values(this.optimizeHash(subTile, targetZoom, intersectionTarget, intersectionFunction, verbose))];
|
|
289
|
-
case 5:
|
|
290
|
-
/// if it partly covered:
|
|
291
|
-
// calculate the sub tiles contained in the current tile (in the next zoom level) - recursive
|
|
292
|
-
_b.sent();
|
|
293
|
-
_b.label = 6;
|
|
294
|
-
case 6:
|
|
295
|
-
tiles_2_1 = tiles_2.next();
|
|
296
|
-
return [3 /*break*/, 2];
|
|
297
|
-
case 7: return [3 /*break*/, 10];
|
|
298
|
-
case 8:
|
|
299
|
-
e_1_1 = _b.sent();
|
|
300
|
-
e_1 = { error: e_1_1 };
|
|
301
|
-
return [3 /*break*/, 10];
|
|
302
|
-
case 9:
|
|
303
|
-
try {
|
|
304
|
-
if (tiles_2_1 && !tiles_2_1.done && (_a = tiles_2.return)) _a.call(tiles_2);
|
|
305
|
-
}
|
|
306
|
-
finally { if (e_1) throw e_1.error; }
|
|
307
|
-
return [7 /*endfinally*/];
|
|
308
|
-
case 10: return [2 /*return*/];
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
TileRanger.prototype.generateSubTiles = function (tile) {
|
|
313
|
-
var tile0 = { x: tile.x << 1, y: tile.y << 1, zoom: tile.zoom + 1 };
|
|
314
|
-
var tile1 = { x: tile0.x + 1, y: tile0.y, zoom: tile0.zoom };
|
|
315
|
-
var tile2 = { x: tile0.x, y: tile0.y + 1, zoom: tile0.zoom };
|
|
316
|
-
var tile3 = { x: tile0.x + 1, y: tile0.y + 1, zoom: tile0.zoom };
|
|
317
|
-
var tiles = [tile0, tile1, tile2, tile3];
|
|
318
|
-
return tiles;
|
|
319
|
-
};
|
|
320
|
-
TileRanger.prototype.isBbox = function (footprint) {
|
|
321
|
-
var bbox = (0, turf_1.bbox)(footprint);
|
|
322
|
-
var bboxPoly = (0, turf_1.bboxPolygon)(bbox);
|
|
323
|
-
return (0, turf_1.booleanEqual)(footprint, bboxPoly);
|
|
324
|
-
};
|
|
325
|
-
return TileRanger;
|
|
326
|
-
}());
|
|
327
|
-
exports.TileRanger = TileRanger;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
+
function step(op) {
|
|
7
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
+
while (_) try {
|
|
9
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
+
switch (op[0]) {
|
|
12
|
+
case 0: case 1: t = op; break;
|
|
13
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
+
default:
|
|
17
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
+
if (t[2]) _.ops.pop();
|
|
22
|
+
_.trys.pop(); continue;
|
|
23
|
+
}
|
|
24
|
+
op = body.call(thisArg, _);
|
|
25
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var __values = (this && this.__values) || function(o) {
|
|
30
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
31
|
+
if (m) return m.call(o);
|
|
32
|
+
if (o && typeof o.length === "number") return {
|
|
33
|
+
next: function () {
|
|
34
|
+
if (o && i >= o.length) o = void 0;
|
|
35
|
+
return { value: o && o[i++], done: !o };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.TileRanger = void 0;
|
|
42
|
+
var turf_1 = require("@turf/turf");
|
|
43
|
+
var bboxUtils_1 = require("./bboxUtils");
|
|
44
|
+
var tiles_1 = require("./tiles");
|
|
45
|
+
var tilesGenerator_1 = require("./tilesGenerator");
|
|
46
|
+
var TileIntersectionState;
|
|
47
|
+
(function (TileIntersectionState) {
|
|
48
|
+
TileIntersectionState["FULL"] = "full";
|
|
49
|
+
TileIntersectionState["PARTIAL"] = "partial";
|
|
50
|
+
TileIntersectionState["NONE"] = "none";
|
|
51
|
+
})(TileIntersectionState || (TileIntersectionState = {}));
|
|
52
|
+
/**
|
|
53
|
+
* class for generating and decoding tile hashes
|
|
54
|
+
*/
|
|
55
|
+
var TileRanger = /** @class */ (function () {
|
|
56
|
+
function TileRanger() {
|
|
57
|
+
this.tileFootprintIntersection = function (tile, intersectionParams) {
|
|
58
|
+
var tileBbox = (0, tiles_1.tileToBbox)(tile);
|
|
59
|
+
var tilePoly = (0, turf_1.bboxPolygon)(tileBbox);
|
|
60
|
+
var intersection = (0, turf_1.intersect)(intersectionParams.footprint, tilePoly);
|
|
61
|
+
if (intersection === null) {
|
|
62
|
+
return TileIntersectionState.NONE;
|
|
63
|
+
}
|
|
64
|
+
// stop condition
|
|
65
|
+
if (tile.zoom === intersectionParams.maxZoom) {
|
|
66
|
+
return TileIntersectionState.FULL;
|
|
67
|
+
}
|
|
68
|
+
var intArea = (0, turf_1.area)(intersection);
|
|
69
|
+
var hashArea = (0, turf_1.area)(tilePoly);
|
|
70
|
+
if (intArea == hashArea) {
|
|
71
|
+
return TileIntersectionState.FULL;
|
|
72
|
+
}
|
|
73
|
+
return TileIntersectionState.PARTIAL;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* converts tile to tile range of specified zoom level
|
|
78
|
+
* @param tile
|
|
79
|
+
* @param zoom target tile range zoom
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
TileRanger.prototype.tileToRange = function (tile, zoom) {
|
|
83
|
+
var minX, minY, maxX, maxY;
|
|
84
|
+
minX = tile.x;
|
|
85
|
+
maxX = tile.x + 1;
|
|
86
|
+
minY = tile.y;
|
|
87
|
+
maxY = tile.y + 1;
|
|
88
|
+
if (tile.zoom < zoom) {
|
|
89
|
+
var dz = zoom - tile.zoom;
|
|
90
|
+
minX = minX << dz;
|
|
91
|
+
maxX = maxX << dz;
|
|
92
|
+
minY = minY << dz;
|
|
93
|
+
maxY = maxY << dz;
|
|
94
|
+
}
|
|
95
|
+
else if (tile.zoom > zoom) {
|
|
96
|
+
var dz = tile.zoom - zoom;
|
|
97
|
+
minX = minX >> dz;
|
|
98
|
+
minY = minY >> dz;
|
|
99
|
+
maxX = minX + 1;
|
|
100
|
+
maxY = minY + 1;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
minX: minX,
|
|
104
|
+
minY: minY,
|
|
105
|
+
maxX: maxX,
|
|
106
|
+
maxY: maxY,
|
|
107
|
+
zoom: zoom,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* generate tile hashes
|
|
112
|
+
* @param footprint footprint to cover with generated tile hashes
|
|
113
|
+
* @param zoom max hash zoom
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
TileRanger.prototype.encodeFootprint = function (footprint, zoom, verbose) {
|
|
117
|
+
var bbox, tileRange, intersectionParams;
|
|
118
|
+
if (verbose === void 0) { verbose = false; }
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
////////////////////////////////
|
|
123
|
+
/// Step 1: check if the footprint is identical to its bbox
|
|
124
|
+
////////////////////////////////
|
|
125
|
+
if (verbose) {
|
|
126
|
+
console.log('encode footprint');
|
|
127
|
+
}
|
|
128
|
+
bbox = (0, turf_1.bbox)(footprint);
|
|
129
|
+
if (!this.isBbox(footprint)) return [3 /*break*/, 2];
|
|
130
|
+
tileRange = (0, bboxUtils_1.bboxToTileRange)(bbox, zoom);
|
|
131
|
+
if (verbose) {
|
|
132
|
+
console.log("footprint is identical to its bbox - return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
133
|
+
}
|
|
134
|
+
return [4 /*yield*/, tileRange];
|
|
135
|
+
case 1:
|
|
136
|
+
_a.sent();
|
|
137
|
+
return [3 /*break*/, 4];
|
|
138
|
+
case 2:
|
|
139
|
+
intersectionParams = {
|
|
140
|
+
footprint: footprint,
|
|
141
|
+
maxZoom: zoom,
|
|
142
|
+
};
|
|
143
|
+
if (verbose) {
|
|
144
|
+
console.log('footprint is different from its bbox - generateRanges');
|
|
145
|
+
}
|
|
146
|
+
return [5 /*yield**/, __values(this.generateRanges(bbox, zoom, intersectionParams, this.tileFootprintIntersection, verbose))];
|
|
147
|
+
case 3:
|
|
148
|
+
_a.sent();
|
|
149
|
+
_a.label = 4;
|
|
150
|
+
case 4: return [2 /*return*/];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
TileRanger.prototype.generateTiles = function (area, zoom) {
|
|
155
|
+
var gen;
|
|
156
|
+
if (Array.isArray(area)) {
|
|
157
|
+
gen = [(0, bboxUtils_1.bboxToTileRange)(area, zoom)];
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
gen = this.encodeFootprint(area, zoom);
|
|
161
|
+
}
|
|
162
|
+
return (0, tilesGenerator_1.tilesGenerator)(gen);
|
|
163
|
+
};
|
|
164
|
+
TileRanger.prototype.generateRanges = function (bbox, zoom, intersectionTarget, intersectionFunction, verbose) {
|
|
165
|
+
var boundingRange, bboxString, dx, dy, minXZoom, minYZoom, minZoom, minimalRange, x, y, tile, intersection, tileRange;
|
|
166
|
+
if (verbose === void 0) { verbose = false; }
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0:
|
|
170
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
171
|
+
/// Step 3: Convert the bbox to tile range of the requested zoom
|
|
172
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
173
|
+
if (verbose) {
|
|
174
|
+
console.log('Convert the bbox to tile range of the requested zoom');
|
|
175
|
+
}
|
|
176
|
+
boundingRange = (0, bboxUtils_1.bboxToTileRange)(bbox, zoom);
|
|
177
|
+
if (verbose) {
|
|
178
|
+
bboxString = "BBOX[0]: ".concat(bbox[0], ", BBOX[1]: ").concat(bbox[1], ", BBOX[2]: ").concat(bbox[2], ", BBOX[3]: ").concat(bbox[3]);
|
|
179
|
+
console.log("".concat(bboxString, ", Zoom: ").concat(zoom, ", bounding range: minX: ").concat(boundingRange.minX, ", maxX: ").concat(boundingRange.maxX, ", minY: ").concat(boundingRange.minY, ", maxY: ").concat(boundingRange.maxY));
|
|
180
|
+
}
|
|
181
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
182
|
+
/// Step 4: Use range size to calculate zoom level where the target area is smaller then 1 tile
|
|
183
|
+
/// (use zoom zero in-case there is no such zoom, for example in global bbox).
|
|
184
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
185
|
+
// find minimal zoom where the the area can be converted by area the size of single tile to skip levels that can't have full hashes
|
|
186
|
+
if (verbose) {
|
|
187
|
+
console.log("find minimal zoom where the the area can be converted by area the size of single tile to skip levels that can't have full hashes");
|
|
188
|
+
}
|
|
189
|
+
dx = boundingRange.maxX - boundingRange.minX;
|
|
190
|
+
dy = boundingRange.maxY - boundingRange.minY;
|
|
191
|
+
minXZoom = Math.max(Math.floor(Math.log2(1 << (zoom + 1)) / dx) - 1, 0);
|
|
192
|
+
minYZoom = Math.max(Math.floor(Math.log2(1 << zoom) / dy), 0);
|
|
193
|
+
minZoom = Math.min(minXZoom, minYZoom);
|
|
194
|
+
if (verbose) {
|
|
195
|
+
console.log("MinZoom: ".concat(minZoom));
|
|
196
|
+
}
|
|
197
|
+
minimalRange = (0, bboxUtils_1.bboxToTileRange)(bbox, minZoom);
|
|
198
|
+
x = minimalRange.minX;
|
|
199
|
+
_a.label = 1;
|
|
200
|
+
case 1:
|
|
201
|
+
if (!(x < minimalRange.maxX)) return [3 /*break*/, 8];
|
|
202
|
+
y = minimalRange.minY;
|
|
203
|
+
_a.label = 2;
|
|
204
|
+
case 2:
|
|
205
|
+
if (!(y < minimalRange.maxY)) return [3 /*break*/, 7];
|
|
206
|
+
tile = { x: x, y: y, zoom: minimalRange.zoom };
|
|
207
|
+
intersection = intersectionFunction(tile, intersectionTarget);
|
|
208
|
+
if (verbose) {
|
|
209
|
+
console.log("Tile X: ".concat(tile.x, ", Y: ").concat(tile.y, " zoom ").concat(tile.zoom, ", intersection: ").concat(intersection));
|
|
210
|
+
}
|
|
211
|
+
if (!(intersection === TileIntersectionState.FULL)) return [3 /*break*/, 4];
|
|
212
|
+
tileRange = this.tileToRange(tile, zoom);
|
|
213
|
+
if (verbose) {
|
|
214
|
+
console.log("return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
215
|
+
}
|
|
216
|
+
return [4 /*yield*/, tileRange];
|
|
217
|
+
case 3:
|
|
218
|
+
_a.sent();
|
|
219
|
+
return [3 /*break*/, 6];
|
|
220
|
+
case 4:
|
|
221
|
+
if (!(intersection === TileIntersectionState.PARTIAL)) return [3 /*break*/, 6];
|
|
222
|
+
/// if it partly covered:
|
|
223
|
+
// calculate the sub tiles contained in the current tile (in the next zoom level)
|
|
224
|
+
// for every sub tile recursively run step 6
|
|
225
|
+
//optimize partial base hashes
|
|
226
|
+
return [5 /*yield**/, __values(this.optimizeHash(tile, zoom, intersectionTarget, intersectionFunction, verbose))];
|
|
227
|
+
case 5:
|
|
228
|
+
/// if it partly covered:
|
|
229
|
+
// calculate the sub tiles contained in the current tile (in the next zoom level)
|
|
230
|
+
// for every sub tile recursively run step 6
|
|
231
|
+
//optimize partial base hashes
|
|
232
|
+
_a.sent();
|
|
233
|
+
_a.label = 6;
|
|
234
|
+
case 6:
|
|
235
|
+
y++;
|
|
236
|
+
return [3 /*break*/, 2];
|
|
237
|
+
case 7:
|
|
238
|
+
x++;
|
|
239
|
+
return [3 /*break*/, 1];
|
|
240
|
+
case 8: return [2 /*return*/];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* generate tile
|
|
246
|
+
* @param tile tile to get all intersecting tiles from
|
|
247
|
+
* @param targetZoom target tiles zoom level
|
|
248
|
+
* @param intersectionTarget original zoom level and footprint to intersect
|
|
249
|
+
* @param intersectionFunction the intersection function to be called
|
|
250
|
+
*/
|
|
251
|
+
TileRanger.prototype.optimizeHash = function (tile, targetZoom, intersectionTarget, intersectionFunction, verbose) {
|
|
252
|
+
var tiles, tiles_2, tiles_2_1, subTile, intersection, tileRange, e_1_1;
|
|
253
|
+
var e_1, _a;
|
|
254
|
+
if (verbose === void 0) { verbose = false; }
|
|
255
|
+
return __generator(this, function (_b) {
|
|
256
|
+
switch (_b.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
/// generate from a tile the next zoom level tiles that compose the tile
|
|
259
|
+
if (verbose) {
|
|
260
|
+
console.log("optimizeHash: Tile X: ".concat(tile.x, ", Y: ").concat(tile.y, " zoom ").concat(tile.zoom, ", intersectionTarget ").concat(intersectionTarget.maxZoom, ", - generate from a tile the next zoom level tiles that compose the tile"));
|
|
261
|
+
}
|
|
262
|
+
tiles = this.generateSubTiles(tile);
|
|
263
|
+
_b.label = 1;
|
|
264
|
+
case 1:
|
|
265
|
+
_b.trys.push([1, 8, 9, 10]);
|
|
266
|
+
tiles_2 = __values(tiles), tiles_2_1 = tiles_2.next();
|
|
267
|
+
_b.label = 2;
|
|
268
|
+
case 2:
|
|
269
|
+
if (!!tiles_2_1.done) return [3 /*break*/, 7];
|
|
270
|
+
subTile = tiles_2_1.value;
|
|
271
|
+
intersection = intersectionFunction(subTile, intersectionTarget);
|
|
272
|
+
if (verbose) {
|
|
273
|
+
console.log("Tile X: ".concat(subTile.x, ", Y: ").concat(subTile.y, " zoom ").concat(subTile.zoom, ", intersection: ").concat(intersection));
|
|
274
|
+
}
|
|
275
|
+
if (!(intersection === TileIntersectionState.FULL)) return [3 /*break*/, 4];
|
|
276
|
+
tileRange = this.tileToRange(subTile, targetZoom);
|
|
277
|
+
if (verbose) {
|
|
278
|
+
console.log("return BBOX tile range zoom: ".concat(tileRange.zoom, " : X ").concat(tileRange.minX, " - ").concat(tileRange.maxX, " : Y ").concat(tileRange.minY, " - ").concat(tileRange.maxY));
|
|
279
|
+
}
|
|
280
|
+
return [4 /*yield*/, tileRange];
|
|
281
|
+
case 3:
|
|
282
|
+
_b.sent();
|
|
283
|
+
return [3 /*break*/, 6];
|
|
284
|
+
case 4:
|
|
285
|
+
if (!(intersection === TileIntersectionState.PARTIAL)) return [3 /*break*/, 6];
|
|
286
|
+
/// if it partly covered:
|
|
287
|
+
// calculate the sub tiles contained in the current tile (in the next zoom level) - recursive
|
|
288
|
+
return [5 /*yield**/, __values(this.optimizeHash(subTile, targetZoom, intersectionTarget, intersectionFunction, verbose))];
|
|
289
|
+
case 5:
|
|
290
|
+
/// if it partly covered:
|
|
291
|
+
// calculate the sub tiles contained in the current tile (in the next zoom level) - recursive
|
|
292
|
+
_b.sent();
|
|
293
|
+
_b.label = 6;
|
|
294
|
+
case 6:
|
|
295
|
+
tiles_2_1 = tiles_2.next();
|
|
296
|
+
return [3 /*break*/, 2];
|
|
297
|
+
case 7: return [3 /*break*/, 10];
|
|
298
|
+
case 8:
|
|
299
|
+
e_1_1 = _b.sent();
|
|
300
|
+
e_1 = { error: e_1_1 };
|
|
301
|
+
return [3 /*break*/, 10];
|
|
302
|
+
case 9:
|
|
303
|
+
try {
|
|
304
|
+
if (tiles_2_1 && !tiles_2_1.done && (_a = tiles_2.return)) _a.call(tiles_2);
|
|
305
|
+
}
|
|
306
|
+
finally { if (e_1) throw e_1.error; }
|
|
307
|
+
return [7 /*endfinally*/];
|
|
308
|
+
case 10: return [2 /*return*/];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
TileRanger.prototype.generateSubTiles = function (tile) {
|
|
313
|
+
var tile0 = { x: tile.x << 1, y: tile.y << 1, zoom: tile.zoom + 1 };
|
|
314
|
+
var tile1 = { x: tile0.x + 1, y: tile0.y, zoom: tile0.zoom };
|
|
315
|
+
var tile2 = { x: tile0.x, y: tile0.y + 1, zoom: tile0.zoom };
|
|
316
|
+
var tile3 = { x: tile0.x + 1, y: tile0.y + 1, zoom: tile0.zoom };
|
|
317
|
+
var tiles = [tile0, tile1, tile2, tile3];
|
|
318
|
+
return tiles;
|
|
319
|
+
};
|
|
320
|
+
TileRanger.prototype.isBbox = function (footprint) {
|
|
321
|
+
var bbox = (0, turf_1.bbox)(footprint);
|
|
322
|
+
var bboxPoly = (0, turf_1.bboxPolygon)(bbox);
|
|
323
|
+
return (0, turf_1.booleanEqual)(footprint, bboxPoly);
|
|
324
|
+
};
|
|
325
|
+
return TileRanger;
|
|
326
|
+
}());
|
|
327
|
+
exports.TileRanger = TileRanger;
|
|
328
328
|
//# sourceMappingURL=tileRanger.js.map
|