@map-colonies/mc-utils 3.0.0 → 3.2.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 +0 -0
- package/dist/arrays/index.d.ts +0 -0
- package/dist/arrays/index.d.ts.map +0 -0
- package/dist/arrays/index.js +0 -0
- package/dist/arrays/index.js.map +0 -0
- package/dist/arrays/subGroups.d.ts +0 -0
- package/dist/arrays/subGroups.d.ts.map +0 -0
- package/dist/arrays/subGroups.js +20 -125
- package/dist/arrays/subGroups.js.map +1 -1
- package/dist/communication/http/httpClient.d.ts +0 -0
- package/dist/communication/http/httpClient.d.ts.map +1 -1
- package/dist/communication/http/httpClient.js +206 -311
- package/dist/communication/http/httpClient.js.map +1 -1
- package/dist/communication/http/index.d.ts +0 -0
- package/dist/communication/http/index.d.ts.map +0 -0
- package/dist/communication/http/index.js +0 -0
- package/dist/communication/http/index.js.map +0 -0
- package/dist/communication/index.d.ts +0 -0
- package/dist/communication/index.d.ts.map +0 -0
- package/dist/communication/index.js +0 -0
- package/dist/communication/index.js.map +0 -0
- package/dist/dateTime/getUTCDate.d.ts +0 -0
- package/dist/dateTime/getUTCDate.d.ts.map +0 -0
- package/dist/dateTime/getUTCDate.js +4 -4
- package/dist/dateTime/getUTCDate.js.map +1 -1
- package/dist/dateTime/index.d.ts +0 -0
- package/dist/dateTime/index.d.ts.map +0 -0
- package/dist/dateTime/index.js +0 -0
- package/dist/dateTime/index.js.map +0 -0
- package/dist/geo/bboxUtils.d.ts +0 -0
- package/dist/geo/bboxUtils.d.ts.map +0 -0
- package/dist/geo/bboxUtils.js +24 -24
- package/dist/geo/bboxUtils.js.map +1 -1
- package/dist/geo/geoConvertor.d.ts +0 -0
- package/dist/geo/geoConvertor.d.ts.map +0 -0
- package/dist/geo/geoConvertor.js +13 -15
- package/dist/geo/geoConvertor.js.map +1 -1
- package/dist/geo/geoHash.d.ts +0 -0
- package/dist/geo/geoHash.d.ts.map +0 -0
- package/dist/geo/geoHash.js +65 -205
- package/dist/geo/geoHash.js.map +1 -1
- package/dist/geo/geoIntersection.d.ts +0 -0
- package/dist/geo/geoIntersection.d.ts.map +0 -0
- package/dist/geo/geoIntersection.js +14 -14
- package/dist/geo/geoIntersection.js.map +1 -1
- package/dist/geo/index.d.ts +0 -0
- package/dist/geo/index.d.ts.map +0 -0
- package/dist/geo/index.js +0 -0
- package/dist/geo/index.js.map +0 -0
- package/dist/geo/tileBatcher.d.ts +0 -0
- package/dist/geo/tileBatcher.d.ts.map +0 -0
- package/dist/geo/tileBatcher.js +65 -161
- package/dist/geo/tileBatcher.js.map +1 -1
- package/dist/geo/tileRanger.d.ts +0 -0
- package/dist/geo/tileRanger.d.ts.map +0 -0
- package/dist/geo/tileRanger.js +165 -316
- package/dist/geo/tileRanger.js.map +1 -1
- package/dist/geo/tiles.d.ts +0 -0
- package/dist/geo/tiles.d.ts.map +0 -0
- package/dist/geo/tiles.js +29 -56
- package/dist/geo/tiles.js.map +1 -1
- package/dist/geo/tilesGenerator.d.ts +0 -0
- package/dist/geo/tilesGenerator.d.ts.map +0 -0
- package/dist/geo/tilesGenerator.js +11 -105
- package/dist/geo/tilesGenerator.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/enums/gdal/dataType.d.ts +0 -0
- package/dist/models/enums/gdal/dataType.d.ts.map +0 -0
- package/dist/models/enums/gdal/dataType.js +0 -0
- package/dist/models/enums/gdal/dataType.js.map +0 -0
- package/dist/models/enums/gdal/index.d.ts +0 -0
- package/dist/models/enums/gdal/index.d.ts.map +0 -0
- package/dist/models/enums/gdal/index.js +0 -0
- package/dist/models/enums/gdal/index.js.map +0 -0
- package/dist/models/enums/gdal/resamplingMethod.d.ts +0 -0
- package/dist/models/enums/gdal/resamplingMethod.d.ts.map +0 -0
- package/dist/models/enums/gdal/resamplingMethod.js +0 -0
- package/dist/models/enums/gdal/resamplingMethod.js.map +0 -0
- package/dist/models/enums/geo/index.d.ts +0 -0
- package/dist/models/enums/geo/index.d.ts.map +0 -0
- package/dist/models/enums/geo/index.js +0 -0
- package/dist/models/enums/geo/index.js.map +0 -0
- package/dist/models/enums/geo/tileOrigin.d.ts +0 -0
- package/dist/models/enums/geo/tileOrigin.d.ts.map +0 -0
- package/dist/models/enums/geo/tileOrigin.js +0 -0
- package/dist/models/enums/geo/tileOrigin.js.map +0 -0
- package/dist/models/enums/index.d.ts +0 -0
- package/dist/models/enums/index.d.ts.map +0 -0
- package/dist/models/enums/index.js +0 -0
- package/dist/models/enums/index.js.map +0 -0
- package/dist/models/index.d.ts +0 -0
- package/dist/models/index.d.ts.map +0 -0
- package/dist/models/index.js +0 -0
- package/dist/models/index.js.map +0 -0
- package/dist/models/interfaces/geo/iPoint.d.ts +0 -0
- package/dist/models/interfaces/geo/iPoint.d.ts.map +0 -0
- package/dist/models/interfaces/geo/iPoint.js +0 -0
- package/dist/models/interfaces/geo/iPoint.js.map +0 -0
- package/dist/models/interfaces/geo/iTile.d.ts +0 -0
- package/dist/models/interfaces/geo/iTile.d.ts.map +0 -0
- package/dist/models/interfaces/geo/iTile.js +0 -0
- package/dist/models/interfaces/geo/iTile.js.map +0 -0
- package/dist/models/interfaces/geo/index.d.ts +0 -0
- package/dist/models/interfaces/geo/index.d.ts.map +0 -0
- package/dist/models/interfaces/geo/index.js +0 -0
- package/dist/models/interfaces/geo/index.js.map +0 -0
- package/dist/models/interfaces/index.d.ts +0 -0
- package/dist/models/interfaces/index.d.ts.map +0 -0
- package/dist/models/interfaces/index.js +0 -0
- package/dist/models/interfaces/index.js.map +0 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/timeout.d.ts +3 -0
- package/dist/utils/timeout.d.ts.map +1 -1
- package/dist/utils/timeout.js +18 -43
- package/dist/utils/timeout.js.map +1 -1
- package/package.json +2 -2
package/dist/geo/tiles.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.featureCollectionToTilesCount = exports.featureToTilesCount = exports.tileRangeToTilesCount = exports.tileToBbox = exports.degreesPerPixelToZoomLevel = exports.zoomLevelToResolutionMeter = exports.zoomLevelToResolutionDeg = exports.flipYAxis = exports.degreesPerPixel = exports.degreesPerTile = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const turf_1 = require("@turf/turf");
|
|
5
|
+
const bboxUtils_1 = require("./bboxUtils");
|
|
6
|
+
const geoConvertor_1 = require("./geoConvertor");
|
|
7
|
+
const zoomToResolutionDegMapper = {
|
|
19
8
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
20
9
|
0: 0.703125,
|
|
21
10
|
1: 0.3515625,
|
|
@@ -42,7 +31,7 @@ var zoomToResolutionDegMapper = {
|
|
|
42
31
|
22: 0.000000167638063430786,
|
|
43
32
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
44
33
|
};
|
|
45
|
-
|
|
34
|
+
const zoomToResolutionMeterMapper = {
|
|
46
35
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
47
36
|
0: 78271.52,
|
|
48
37
|
1: 39135.76,
|
|
@@ -75,7 +64,7 @@ var zoomToResolutionMeterMapper = {
|
|
|
75
64
|
* @returns tile size (resolution) in degrees
|
|
76
65
|
*/
|
|
77
66
|
function degreesPerTile(zoomLevel) {
|
|
78
|
-
|
|
67
|
+
const latRange = 180;
|
|
79
68
|
return latRange / (1 << zoomLevel);
|
|
80
69
|
}
|
|
81
70
|
exports.degreesPerTile = degreesPerTile;
|
|
@@ -85,8 +74,8 @@ exports.degreesPerTile = degreesPerTile;
|
|
|
85
74
|
* @returns pixel size (resolution) in degrees
|
|
86
75
|
*/
|
|
87
76
|
function degreesPerPixel(zoomLevel) {
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
const tileSize = 256;
|
|
78
|
+
const tileRes = degreesPerTile(zoomLevel);
|
|
90
79
|
return tileRes / tileSize;
|
|
91
80
|
}
|
|
92
81
|
exports.degreesPerPixel = degreesPerPixel;
|
|
@@ -96,7 +85,7 @@ exports.degreesPerPixel = degreesPerPixel;
|
|
|
96
85
|
* @returns converted tile
|
|
97
86
|
*/
|
|
98
87
|
function flipYAxis(tile) {
|
|
99
|
-
|
|
88
|
+
const yTiles = 1 << tile.zoom;
|
|
100
89
|
return {
|
|
101
90
|
x: tile.x,
|
|
102
91
|
y: yTiles - tile.y - 1,
|
|
@@ -128,11 +117,11 @@ exports.zoomLevelToResolutionMeter = zoomLevelToResolutionMeter;
|
|
|
128
117
|
* @returns zoom level for given pixel size
|
|
129
118
|
*/
|
|
130
119
|
function degreesPerPixelToZoomLevel(resolution) {
|
|
131
|
-
|
|
120
|
+
const MIN_ZOOM_LEVEL = 0;
|
|
132
121
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
133
|
-
|
|
122
|
+
const zoomLevel = Math.floor(Math.log2(180 / (resolution * 256)));
|
|
134
123
|
if (zoomLevel < MIN_ZOOM_LEVEL) {
|
|
135
|
-
throw new Error(
|
|
124
|
+
throw new Error(`Invalid zoom level ${zoomLevel} for resolution ${resolution}`);
|
|
136
125
|
}
|
|
137
126
|
return zoomLevel;
|
|
138
127
|
}
|
|
@@ -143,8 +132,8 @@ exports.degreesPerPixelToZoomLevel = degreesPerPixelToZoomLevel;
|
|
|
143
132
|
* @returns
|
|
144
133
|
*/
|
|
145
134
|
function tileToBbox(tile) {
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
const minPoint = (0, geoConvertor_1.tileToDegrees)(tile);
|
|
136
|
+
const tileSize = degreesPerTile(tile.zoom);
|
|
148
137
|
return [minPoint.longitude, minPoint.latitude, minPoint.longitude + tileSize, minPoint.latitude + tileSize];
|
|
149
138
|
}
|
|
150
139
|
exports.tileToBbox = tileToBbox;
|
|
@@ -170,33 +159,30 @@ exports.tileRangeToTilesCount = tileRangeToTilesCount;
|
|
|
170
159
|
* @param defaultMinZoom optional - default is 0 - if minResolutionDeg property was provided, the param will be ignored
|
|
171
160
|
* @returns tile count included on provided feature and zooms ranges
|
|
172
161
|
*/
|
|
173
|
-
function featureToTilesCount(feature, defaultMaxZoom, defaultMinZoom) {
|
|
174
|
-
|
|
175
|
-
if (defaultMaxZoom === void 0) { defaultMaxZoom = 22; }
|
|
176
|
-
if (defaultMinZoom === void 0) { defaultMinZoom = 0; }
|
|
177
|
-
var tilesTotalAmount = 0;
|
|
162
|
+
function featureToTilesCount(feature, defaultMaxZoom = 22, defaultMinZoom = 0) {
|
|
163
|
+
let tilesTotalAmount = 0;
|
|
178
164
|
if (defaultMaxZoom > 22 || defaultMinZoom < 0) {
|
|
179
|
-
throw new RangeError(
|
|
165
|
+
throw new RangeError(`Un supported zoom levels values, min-max zoom should be [0-22] but actual [${defaultMinZoom}:${defaultMaxZoom}]`);
|
|
180
166
|
}
|
|
181
167
|
if (defaultMinZoom > defaultMaxZoom) {
|
|
182
|
-
throw new RangeError(
|
|
168
|
+
throw new RangeError(`Illegal - defaultMinZoom[${defaultMinZoom}] is larger than defaultMaxZoom[${defaultMaxZoom}]`);
|
|
183
169
|
}
|
|
184
170
|
try {
|
|
185
|
-
|
|
171
|
+
const targetMaxZoom = feature.properties?.maxResolutionDeg !== undefined && typeof feature.properties.maxResolutionDeg === 'number'
|
|
186
172
|
? degreesPerPixelToZoomLevel(feature.properties.maxResolutionDeg)
|
|
187
173
|
: defaultMaxZoom;
|
|
188
|
-
|
|
174
|
+
const targetMinZoom = feature.properties?.minResolutionDeg !== undefined && typeof feature.properties.minResolutionDeg === 'number'
|
|
189
175
|
? degreesPerPixelToZoomLevel(feature.properties.minResolutionDeg)
|
|
190
176
|
: defaultMinZoom;
|
|
191
|
-
|
|
192
|
-
for (
|
|
193
|
-
|
|
177
|
+
const sanitized = (0, bboxUtils_1.snapBBoxToTileGrid)((0, turf_1.bbox)(feature.geometry), targetMaxZoom);
|
|
178
|
+
for (let i = targetMinZoom; i <= targetMaxZoom; i++) {
|
|
179
|
+
const zoomTilesBatch = (0, bboxUtils_1.bboxToTileRange)(sanitized, i);
|
|
194
180
|
tilesTotalAmount += tileRangeToTilesCount(zoomTilesBatch);
|
|
195
181
|
}
|
|
196
182
|
return tilesTotalAmount;
|
|
197
183
|
}
|
|
198
184
|
catch (error) {
|
|
199
|
-
|
|
185
|
+
const message = `Error occurred while trying to calculate tiles amount - encodeFootprint error: ${JSON.stringify(error)}`;
|
|
200
186
|
throw new Error(message);
|
|
201
187
|
}
|
|
202
188
|
}
|
|
@@ -217,29 +203,16 @@ exports.featureToTilesCount = featureToTilesCount;
|
|
|
217
203
|
* @param defaultMinZoom optional - default is 0 - if minResolutionDeg property was provided, the param will be ignored
|
|
218
204
|
* @returns tile count included on provided feature and zooms ranges
|
|
219
205
|
*/
|
|
220
|
-
function featureCollectionToTilesCount(fc, defaultMaxZoom, defaultMinZoom) {
|
|
221
|
-
|
|
222
|
-
if (defaultMaxZoom === void 0) { defaultMaxZoom = 22; }
|
|
223
|
-
if (defaultMinZoom === void 0) { defaultMinZoom = 0; }
|
|
224
|
-
var tilesTotalAmount = 0;
|
|
206
|
+
function featureCollectionToTilesCount(fc, defaultMaxZoom = 22, defaultMinZoom = 0) {
|
|
207
|
+
let tilesTotalAmount = 0;
|
|
225
208
|
try {
|
|
226
|
-
|
|
227
|
-
|
|
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; }
|
|
209
|
+
for (const feature of fc.features) {
|
|
210
|
+
tilesTotalAmount += featureToTilesCount(feature, defaultMaxZoom, defaultMinZoom);
|
|
238
211
|
}
|
|
239
212
|
return tilesTotalAmount;
|
|
240
213
|
}
|
|
241
214
|
catch (error) {
|
|
242
|
-
|
|
215
|
+
const message = `Error occurred while trying to calculate tiles amount - encodeFootprint error: ${JSON.stringify(error)}`;
|
|
243
216
|
throw new Error(message);
|
|
244
217
|
}
|
|
245
218
|
}
|
package/dist/geo/tiles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../src/geo/tiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tiles.js","sourceRoot":"","sources":["../../src/geo/tiles.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF,2CAAkE;AAClE,iDAA+C;AAE/C,MAAM,yBAAyB,GAA2B;IACxD,yDAAyD;IACzD,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,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AI,EAAC,OAAO,CAAC,QAAQ,CAAW,EAAE,aAAa,CAAC,CAAC;QAEtF,KAAK,IAAI,CAAC,GAAG,aAAa,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,EAAE,EAAE;YACnD,MAAM,cAAc,GAAG,IAAA,2BAAe,EAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACrD,gBAAgB,IAAI,qBAAqB,CAAC,cAAc,CAAC,CAAC;SAC3D;QAED,OAAO,gBAAgB,CAAC;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,kFAAkF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1H,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KAC1B;AACH,CAAC;AA/BD,kDA+BC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,6BAA6B,CAAC,EAAqB,EAAE,cAAc,GAAG,EAAE,EAAE,cAAc,GAAG,CAAC;IAC1G,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,IAAI;QACF,KAAK,MAAM,OAAO,IAAI,EAAE,CAAC,QAAQ,EAAE;YACjC,gBAAgB,IAAI,mBAAmB,CAAC,OAA0C,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;SACrH;QACD,OAAO,gBAAgB,CAAC;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,kFAAkF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1H,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KAC1B;AACH,CAAC;AAXD,sEAWC"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,112 +1,18 @@
|
|
|
1
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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
30
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
31
|
-
var m = o[Symbol.asyncIterator], i;
|
|
32
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
33
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
34
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
35
|
-
};
|
|
36
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
37
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
38
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
39
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
40
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
41
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
42
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
43
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
44
|
-
function fulfill(value) { resume("next", value); }
|
|
45
|
-
function reject(value) { resume("throw", value); }
|
|
46
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
47
|
-
};
|
|
48
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
3
|
exports.tilesGenerator = void 0;
|
|
50
|
-
function tilesGenerator(rangeGen) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_b.label = 1;
|
|
60
|
-
case 1: return [4 /*yield*/, __await(rangeGen_1.next())];
|
|
61
|
-
case 2:
|
|
62
|
-
if (!(rangeGen_1_1 = _b.sent(), !rangeGen_1_1.done)) return [3 /*break*/, 11];
|
|
63
|
-
range = rangeGen_1_1.value;
|
|
64
|
-
x = range.minX;
|
|
65
|
-
_b.label = 3;
|
|
66
|
-
case 3:
|
|
67
|
-
if (!(x < range.maxX)) return [3 /*break*/, 10];
|
|
68
|
-
y = range.minY;
|
|
69
|
-
_b.label = 4;
|
|
70
|
-
case 4:
|
|
71
|
-
if (!(y < range.maxY)) return [3 /*break*/, 9];
|
|
72
|
-
return [4 /*yield*/, __await(Promise.resolve({
|
|
73
|
-
x: x,
|
|
74
|
-
y: y,
|
|
75
|
-
zoom: range.zoom,
|
|
76
|
-
}))];
|
|
77
|
-
case 5: return [4 /*yield*/, __await.apply(void 0, [_b.sent()])];
|
|
78
|
-
case 6: return [4 /*yield*/, _b.sent()];
|
|
79
|
-
case 7:
|
|
80
|
-
_b.sent();
|
|
81
|
-
_b.label = 8;
|
|
82
|
-
case 8:
|
|
83
|
-
y++;
|
|
84
|
-
return [3 /*break*/, 4];
|
|
85
|
-
case 9:
|
|
86
|
-
x++;
|
|
87
|
-
return [3 /*break*/, 3];
|
|
88
|
-
case 10: return [3 /*break*/, 1];
|
|
89
|
-
case 11: return [3 /*break*/, 18];
|
|
90
|
-
case 12:
|
|
91
|
-
e_1_1 = _b.sent();
|
|
92
|
-
e_1 = { error: e_1_1 };
|
|
93
|
-
return [3 /*break*/, 18];
|
|
94
|
-
case 13:
|
|
95
|
-
_b.trys.push([13, , 16, 17]);
|
|
96
|
-
if (!(rangeGen_1_1 && !rangeGen_1_1.done && (_a = rangeGen_1.return))) return [3 /*break*/, 15];
|
|
97
|
-
return [4 /*yield*/, __await(_a.call(rangeGen_1))];
|
|
98
|
-
case 14:
|
|
99
|
-
_b.sent();
|
|
100
|
-
_b.label = 15;
|
|
101
|
-
case 15: return [3 /*break*/, 17];
|
|
102
|
-
case 16:
|
|
103
|
-
if (e_1) throw e_1.error;
|
|
104
|
-
return [7 /*endfinally*/];
|
|
105
|
-
case 17: return [7 /*endfinally*/];
|
|
106
|
-
case 18: return [2 /*return*/];
|
|
4
|
+
async function* tilesGenerator(rangeGen) {
|
|
5
|
+
for await (const range of rangeGen) {
|
|
6
|
+
for (let x = range.minX; x < range.maxX; x++) {
|
|
7
|
+
for (let y = range.minY; y < range.maxY; y++) {
|
|
8
|
+
yield await Promise.resolve({
|
|
9
|
+
x,
|
|
10
|
+
y,
|
|
11
|
+
zoom: range.zoom,
|
|
12
|
+
});
|
|
107
13
|
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
110
16
|
}
|
|
111
17
|
exports.tilesGenerator = tilesGenerator;
|
|
112
18
|
//# sourceMappingURL=tilesGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilesGenerator.js","sourceRoot":"","sources":["../../src/geo/tilesGenerator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tilesGenerator.js","sourceRoot":"","sources":["../../src/geo/tilesGenerator.ts"],"names":[],"mappings":";;;AAEO,KAAK,SAAS,CAAC,CAAC,cAAc,CAAC,QAAmC;IACvE,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,EAAE;QAClC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YAC5C,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;gBAC5C,MAAM,MAAM,OAAO,CAAC,OAAO,CAAC;oBAC1B,CAAC;oBACD,CAAC;oBACD,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,CAAC;aACJ;SACF;KACF;AACH,CAAC;AAZD,wCAYC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./communication"), exports);
|
|
|
19
19
|
__exportStar(require("./dateTime"), exports);
|
|
20
20
|
__exportStar(require("./geo"), exports);
|
|
21
21
|
__exportStar(require("./arrays"), exports);
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/models/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/models/index.js
CHANGED
|
File without changes
|
package/dist/models/index.js.map
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./timeout"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
package/dist/utils/timeout.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../src/utils/timeout.ts"],"names":[],"mappings":"AAAA,wBAAsB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD"}
|
|
1
|
+
{"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../src/utils/timeout.ts"],"names":[],"mappings":"AAAA,wBAAsB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;AAED,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAE1C,eAAO,MAAM,sBAAsB,iBAAwB,MAAM,oCAWhE,CAAC"}
|
package/dist/utils/timeout.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.timeout = void 0;
|
|
40
|
-
function timeout(ms) {
|
|
41
|
-
return
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
|
|
44
|
-
});
|
|
45
|
-
});
|
|
3
|
+
exports.racePromiseWithTimeout = exports.TimeoutError = exports.timeout = void 0;
|
|
4
|
+
async function timeout(ms) {
|
|
5
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
46
6
|
}
|
|
47
7
|
exports.timeout = timeout;
|
|
8
|
+
class TimeoutError extends Error {
|
|
9
|
+
}
|
|
10
|
+
exports.TimeoutError = TimeoutError;
|
|
11
|
+
const racePromiseWithTimeout = async (msTimeout, promise) => {
|
|
12
|
+
// Create a promise that rejects in <ms> milliseconds
|
|
13
|
+
const timeout = new Promise((_, reject) => {
|
|
14
|
+
const id = setTimeout(() => {
|
|
15
|
+
clearTimeout(id);
|
|
16
|
+
reject(new TimeoutError(`Timed out in + ${msTimeout} + ms.`));
|
|
17
|
+
}, msTimeout);
|
|
18
|
+
});
|
|
19
|
+
// Returns a race between our timeout and the passed in promise
|
|
20
|
+
return Promise.race([promise, timeout]);
|
|
21
|
+
};
|
|
22
|
+
exports.racePromiseWithTimeout = racePromiseWithTimeout;
|
|
48
23
|
//# sourceMappingURL=timeout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/utils/timeout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/utils/timeout.ts"],"names":[],"mappings":";;;AAAO,KAAK,UAAU,OAAO,CAAC,EAAU;IACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,0BAEC;AAED,MAAa,YAAa,SAAQ,KAAK;CAAG;AAA1C,oCAA0C;AAEnC,MAAM,sBAAsB,GAAG,KAAK,EAAK,SAAiB,EAAE,OAAmB,EAAc,EAAE;IACpG,qDAAqD;IACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,YAAY,CAAC,EAAE,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,YAAY,CAAC,kBAAkB,SAAS,QAAQ,CAAC,CAAC,CAAC;QAChE,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@map-colonies/mc-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "This is template for map colonies typescript packages",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"ngeohash": "^0.6.3"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@map-colonies/error-types": "^1.
|
|
76
|
+
"@map-colonies/error-types": "^1.2.0",
|
|
77
77
|
"@map-colonies/js-logger": "^1.0.1"
|
|
78
78
|
}
|
|
79
79
|
}
|