@map-colonies/mc-utils 3.0.0 → 3.1.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 +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 +33 -138
- package/dist/arrays/subGroups.js.map +1 -1
- 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 +317 -434
- 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 -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 +1 -1
- 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 +1 -1
- package/dist/geo/geoConvertor.d.ts +18 -18
- package/dist/geo/geoConvertor.d.ts.map +0 -0
- package/dist/geo/geoConvertor.js +49 -51
- package/dist/geo/geoConvertor.js.map +1 -1
- package/dist/geo/geoHash.d.ts +24 -24
- package/dist/geo/geoHash.d.ts.map +0 -0
- package/dist/geo/geoHash.js +134 -274
- 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 +1 -1
- 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 +97 -193
- 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 +232 -383
- package/dist/geo/tileRanger.js.map +1 -1
- package/dist/geo/tiles.d.ts +82 -82
- package/dist/geo/tiles.d.ts.map +0 -0
- package/dist/geo/tiles.js +219 -246
- 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 +17 -111
- package/dist/geo/tilesGenerator.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -21
- 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 -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/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 +4 -1
- package/dist/utils/timeout.d.ts.map +1 -1
- package/dist/utils/timeout.js +22 -47
- package/dist/utils/timeout.js.map +1 -1
- package/package.json +79 -79
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.featureCollectionBooleanEqual = exports.multiIntersect = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// compare features
|
|
11
|
-
// https://lodash.com/docs/4.17.15#find
|
|
12
|
-
if (!lodash_1.default.isEqual(objectValue.length, otherValue.length)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
for (
|
|
16
|
-
|
|
17
|
-
if (isFeatureContained === undefined) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (
|
|
22
|
-
|
|
23
|
-
if (isFeatureContained === undefined) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// compare type
|
|
31
|
-
if (!lodash_1.default.isEqual(objectValue.type, otherValue.type)) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
// compare features
|
|
35
|
-
|
|
36
|
-
return isFeaturesEqual;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* return the intersection footprint of all specified footprints or null when there is no intersection
|
|
40
|
-
* @param footprints footprint list to intersect
|
|
41
|
-
* @returns intersection footprint or null
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
if (footprints.length === 0) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
else if (footprints.length === 1) {
|
|
48
|
-
return footprints[0];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (
|
|
52
|
-
|
|
53
|
-
if (curIntersection === null) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
intersection = curIntersection;
|
|
57
|
-
}
|
|
58
|
-
return intersection;
|
|
59
|
-
};
|
|
60
|
-
exports.multiIntersect = multiIntersect;
|
|
61
|
-
/**
|
|
62
|
-
* indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
|
|
63
|
-
* @param fc1 first featureCollection to compare equal
|
|
64
|
-
* @param fc2 second featureCollection to compare equal
|
|
65
|
-
* @returns true if same featureCollection, false if not
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
return lodash_1.default.isEqualWith(fc1, fc2, featureCollectionCustomized);
|
|
69
|
-
};
|
|
70
|
-
exports.featureCollectionBooleanEqual = featureCollectionBooleanEqual;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.featureCollectionBooleanEqual = exports.multiIntersect = void 0;
|
|
7
|
+
const turf_1 = require("@turf/turf");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const featuresCustomizer = (objectValue, otherValue) => {
|
|
10
|
+
// compare features
|
|
11
|
+
// https://lodash.com/docs/4.17.15#find
|
|
12
|
+
if (!lodash_1.default.isEqual(objectValue.length, otherValue.length)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
for (let i = 0; i < objectValue.length; i++) {
|
|
16
|
+
const isFeatureContained = lodash_1.default.find(otherValue, objectValue[i]);
|
|
17
|
+
if (isFeatureContained === undefined) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (let i = 0; i < otherValue.length; i++) {
|
|
22
|
+
const isFeatureContained = lodash_1.default.find(objectValue, otherValue[i]);
|
|
23
|
+
if (isFeatureContained === undefined) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const featureCollectionCustomized = (objectValue, otherValue) => {
|
|
30
|
+
// compare type
|
|
31
|
+
if (!lodash_1.default.isEqual(objectValue.type, otherValue.type)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// compare features
|
|
35
|
+
const isFeaturesEqual = lodash_1.default.isEqualWith(objectValue.features, otherValue.features, featuresCustomizer);
|
|
36
|
+
return isFeaturesEqual;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* return the intersection footprint of all specified footprints or null when there is no intersection
|
|
40
|
+
* @param footprints footprint list to intersect
|
|
41
|
+
* @returns intersection footprint or null
|
|
42
|
+
*/
|
|
43
|
+
const multiIntersect = (footprints) => {
|
|
44
|
+
if (footprints.length === 0) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
else if (footprints.length === 1) {
|
|
48
|
+
return footprints[0];
|
|
49
|
+
}
|
|
50
|
+
let intersection = footprints[0];
|
|
51
|
+
for (let i = 1; i < footprints.length; i++) {
|
|
52
|
+
const curIntersection = (0, turf_1.intersect)(intersection, footprints[i]);
|
|
53
|
+
if (curIntersection === null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
intersection = curIntersection;
|
|
57
|
+
}
|
|
58
|
+
return intersection;
|
|
59
|
+
};
|
|
60
|
+
exports.multiIntersect = multiIntersect;
|
|
61
|
+
/**
|
|
62
|
+
* indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
|
|
63
|
+
* @param fc1 first featureCollection to compare equal
|
|
64
|
+
* @param fc2 second featureCollection to compare equal
|
|
65
|
+
* @returns true if same featureCollection, false if not
|
|
66
|
+
*/
|
|
67
|
+
const featureCollectionBooleanEqual = (fc1, fc2) => {
|
|
68
|
+
return lodash_1.default.isEqualWith(fc1, fc2, featureCollectionCustomized);
|
|
69
|
+
};
|
|
70
|
+
exports.featureCollectionBooleanEqual = featureCollectionBooleanEqual;
|
|
71
71
|
//# sourceMappingURL=geoIntersection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geoIntersection.js","sourceRoot":"","sources":["../../src/geo/geoIntersection.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"geoIntersection.js","sourceRoot":"","sources":["../../src/geo/geoIntersection.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA0F;AAC1F,oDAAuB;AAOvB,MAAM,kBAAkB,GAAG,CAAC,WAAsB,EAAE,UAAqB,EAAW,EAAE;IACpF,mBAAmB;IACnB,uCAAuC;IAEvC,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE;QACrD,OAAO,KAAK,CAAC;KACd;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,gBAAC,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAI,kBAAkB,KAAK,SAAS,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;KACF;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,kBAAkB,GAAG,gBAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAI,kBAAkB,KAAK,SAAS,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,WAA8B,EAAE,UAA6B,EAAW,EAAE;IAC7G,eAAe;IACf,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;QACjD,OAAO,KAAK,CAAC;KACd;IACD,mBAAmB;IACnB,MAAM,eAAe,GAAG,gBAAC,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACrG,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,UAAuB,EAAoB,EAAE;IACnE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;KACtB;IACD,IAAI,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,eAAe,GAAG,IAAA,gBAAS,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,OAAO,IAAI,CAAC;SACb;QACD,YAAY,GAAG,eAAe,CAAC;KAChC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAYO,wCAAc;AAVvB;;;;;GAKG;AACH,MAAM,6BAA6B,GAAG,CAAC,GAAsB,EAAE,GAAsB,EAAW,EAAE;IAChG,OAAO,gBAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,2BAA2B,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEuB,sEAA6B"}
|
package/dist/geo/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './bboxUtils';
|
|
2
|
-
export * from './geoConvertor';
|
|
3
|
-
export * from './geoHash';
|
|
4
|
-
export * from './geoIntersection';
|
|
5
|
-
export * from './tileBatcher';
|
|
6
|
-
export * from './tileRanger';
|
|
7
|
-
export * from './tiles';
|
|
8
|
-
export * from './tilesGenerator';
|
|
1
|
+
export * from './bboxUtils';
|
|
2
|
+
export * from './geoConvertor';
|
|
3
|
+
export * from './geoHash';
|
|
4
|
+
export * from './geoIntersection';
|
|
5
|
+
export * from './tileBatcher';
|
|
6
|
+
export * from './tileRanger';
|
|
7
|
+
export * from './tiles';
|
|
8
|
+
export * from './tilesGenerator';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/geo/index.d.ts.map
CHANGED
|
File without changes
|
package/dist/geo/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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("./bboxUtils"), exports);
|
|
18
|
-
__exportStar(require("./geoConvertor"), exports);
|
|
19
|
-
__exportStar(require("./geoHash"), exports);
|
|
20
|
-
__exportStar(require("./geoIntersection"), exports);
|
|
21
|
-
__exportStar(require("./tileBatcher"), exports);
|
|
22
|
-
__exportStar(require("./tileRanger"), exports);
|
|
23
|
-
__exportStar(require("./tiles"), exports);
|
|
24
|
-
__exportStar(require("./tilesGenerator"), exports);
|
|
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("./bboxUtils"), exports);
|
|
18
|
+
__exportStar(require("./geoConvertor"), exports);
|
|
19
|
+
__exportStar(require("./geoHash"), exports);
|
|
20
|
+
__exportStar(require("./geoIntersection"), exports);
|
|
21
|
+
__exportStar(require("./tileBatcher"), exports);
|
|
22
|
+
__exportStar(require("./tileRanger"), exports);
|
|
23
|
+
__exportStar(require("./tiles"), exports);
|
|
24
|
+
__exportStar(require("./tilesGenerator"), exports);
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/dist/geo/index.js.map
CHANGED
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ITileRange } from '../models/interfaces/geo/iTile';
|
|
2
|
-
/**
|
|
3
|
-
* split collection of tile ranges to batches based on tile count
|
|
4
|
-
* @param batchSize amount of tile per batch
|
|
5
|
-
* @param ranges iterable collection of tile ranges
|
|
6
|
-
*/
|
|
7
|
-
declare function tileBatchGenerator(batchSize: number, ranges: AsyncGenerator<ITileRange>): AsyncGenerator<ITileRange[]>;
|
|
8
|
-
export { tileBatchGenerator };
|
|
1
|
+
import { ITileRange } from '../models/interfaces/geo/iTile';
|
|
2
|
+
/**
|
|
3
|
+
* split collection of tile ranges to batches based on tile count
|
|
4
|
+
* @param batchSize amount of tile per batch
|
|
5
|
+
* @param ranges iterable collection of tile ranges
|
|
6
|
+
*/
|
|
7
|
+
declare function tileBatchGenerator(batchSize: number, ranges: AsyncGenerator<ITileRange>): AsyncGenerator<ITileRange[]>;
|
|
8
|
+
export { tileBatchGenerator };
|
|
9
9
|
//# sourceMappingURL=tileBatcher.d.ts.map
|
|
File without changes
|
package/dist/geo/tileBatcher.js
CHANGED
|
@@ -1,194 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
range
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
reminderX =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
reminderX += requiredForFullBatch;
|
|
99
|
-
targetRanges = [];
|
|
100
|
-
requiredForFullBatch = batchSize;
|
|
101
|
-
return [3 /*break*/, 4];
|
|
102
|
-
case 8:
|
|
103
|
-
targetRanges.push({
|
|
104
|
-
minX: reminderX,
|
|
105
|
-
maxX: reminderX + remaining,
|
|
106
|
-
minY: range.minY,
|
|
107
|
-
maxY: range.minY + 1,
|
|
108
|
-
zoom: range.zoom,
|
|
109
|
-
});
|
|
110
|
-
range.minY++;
|
|
111
|
-
reminderX += remaining;
|
|
112
|
-
requiredForFullBatch -= remaining;
|
|
113
|
-
dy--;
|
|
114
|
-
_b.label = 9;
|
|
115
|
-
case 9:
|
|
116
|
-
requiredLines = Math.floor(requiredForFullBatch / dx);
|
|
117
|
-
yRange = Math.min(requiredLines, dy);
|
|
118
|
-
if (yRange > 0) {
|
|
119
|
-
targetRanges.push({
|
|
120
|
-
minX: range.minX,
|
|
121
|
-
maxX: range.maxX,
|
|
122
|
-
minY: range.minY,
|
|
123
|
-
maxY: range.minY + yRange,
|
|
124
|
-
zoom: range.zoom,
|
|
125
|
-
});
|
|
126
|
-
range.minY += yRange;
|
|
127
|
-
dy -= yRange;
|
|
128
|
-
requiredForFullBatch -= yRange * dx;
|
|
129
|
-
}
|
|
130
|
-
//add partial lines beginning
|
|
131
|
-
if (requiredForFullBatch > 0 && range.minY < range.maxY) {
|
|
132
|
-
endX = Math.min(range.minX + requiredForFullBatch, range.maxX);
|
|
133
|
-
targetRanges.push({
|
|
134
|
-
minX: range.minX,
|
|
135
|
-
maxX: endX,
|
|
136
|
-
minY: range.minY,
|
|
137
|
-
maxY: range.minY + 1,
|
|
138
|
-
zoom: range.zoom,
|
|
139
|
-
});
|
|
140
|
-
requiredForFullBatch -= endX - range.minX;
|
|
141
|
-
if (endX < range.maxX) {
|
|
142
|
-
reminderX = endX;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
range.minY++;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!(requiredForFullBatch === 0)) return [3 /*break*/, 13];
|
|
149
|
-
return [4 /*yield*/, __await(Promise.resolve(targetRanges))];
|
|
150
|
-
case 10: return [4 /*yield*/, __await.apply(void 0, [_b.sent()])];
|
|
151
|
-
case 11: return [4 /*yield*/, _b.sent()];
|
|
152
|
-
case 12:
|
|
153
|
-
_b.sent();
|
|
154
|
-
targetRanges = [];
|
|
155
|
-
requiredForFullBatch = batchSize;
|
|
156
|
-
_b.label = 13;
|
|
157
|
-
case 13: return [3 /*break*/, 4];
|
|
158
|
-
case 14: return [4 /*yield*/, __await((0, timeout_1.timeout)(0))];
|
|
159
|
-
case 15:
|
|
160
|
-
_b.sent(); // TODO: * This is a hot fix to keep work async and handle concurrency requests while handling the task batch merging, remove this when moving to the new utils package ! *
|
|
161
|
-
_b.label = 16;
|
|
162
|
-
case 16: return [3 /*break*/, 2];
|
|
163
|
-
case 17: return [3 /*break*/, 24];
|
|
164
|
-
case 18:
|
|
165
|
-
e_1_1 = _b.sent();
|
|
166
|
-
e_1 = { error: e_1_1 };
|
|
167
|
-
return [3 /*break*/, 24];
|
|
168
|
-
case 19:
|
|
169
|
-
_b.trys.push([19, , 22, 23]);
|
|
170
|
-
if (!(ranges_1_1 && !ranges_1_1.done && (_a = ranges_1.return))) return [3 /*break*/, 21];
|
|
171
|
-
return [4 /*yield*/, __await(_a.call(ranges_1))];
|
|
172
|
-
case 20:
|
|
173
|
-
_b.sent();
|
|
174
|
-
_b.label = 21;
|
|
175
|
-
case 21: return [3 /*break*/, 23];
|
|
176
|
-
case 22:
|
|
177
|
-
if (e_1) throw e_1.error;
|
|
178
|
-
return [7 /*endfinally*/];
|
|
179
|
-
case 23: return [7 /*endfinally*/];
|
|
180
|
-
case 24:
|
|
181
|
-
if (!(targetRanges.length > 0)) return [3 /*break*/, 28];
|
|
182
|
-
return [4 /*yield*/, __await(Promise.resolve(targetRanges))];
|
|
183
|
-
case 25: return [4 /*yield*/, __await.apply(void 0, [_b.sent()])];
|
|
184
|
-
case 26: return [4 /*yield*/, _b.sent()];
|
|
185
|
-
case 27:
|
|
186
|
-
_b.sent();
|
|
187
|
-
_b.label = 28;
|
|
188
|
-
case 28: return [2 /*return*/];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
exports.tileBatchGenerator = tileBatchGenerator;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tileBatchGenerator = void 0;
|
|
4
|
+
const timeout_1 = require("../utils/timeout");
|
|
5
|
+
/**
|
|
6
|
+
* split collection of tile ranges to batches based on tile count
|
|
7
|
+
* @param batchSize amount of tile per batch
|
|
8
|
+
* @param ranges iterable collection of tile ranges
|
|
9
|
+
*/
|
|
10
|
+
async function* tileBatchGenerator(batchSize, ranges) {
|
|
11
|
+
let targetRanges = [];
|
|
12
|
+
let requiredForFullBatch = batchSize;
|
|
13
|
+
for await (const range of ranges) {
|
|
14
|
+
const dx = range.maxX - range.minX;
|
|
15
|
+
let dy = range.maxY - range.minY;
|
|
16
|
+
if (dx === 0 || dy === 0) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
let reminderX = range.maxX;
|
|
20
|
+
while (range.minY < range.maxY) {
|
|
21
|
+
//remaining tiles in batch row row
|
|
22
|
+
if (reminderX < range.maxX) {
|
|
23
|
+
const remaining = range.maxX - reminderX;
|
|
24
|
+
if (remaining > requiredForFullBatch) {
|
|
25
|
+
targetRanges.push({
|
|
26
|
+
minX: reminderX,
|
|
27
|
+
maxX: reminderX + requiredForFullBatch,
|
|
28
|
+
minY: range.minY,
|
|
29
|
+
maxY: range.minY + 1,
|
|
30
|
+
zoom: range.zoom,
|
|
31
|
+
});
|
|
32
|
+
yield await Promise.resolve(targetRanges);
|
|
33
|
+
reminderX += requiredForFullBatch;
|
|
34
|
+
targetRanges = [];
|
|
35
|
+
requiredForFullBatch = batchSize;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
targetRanges.push({
|
|
40
|
+
minX: reminderX,
|
|
41
|
+
maxX: reminderX + remaining,
|
|
42
|
+
minY: range.minY,
|
|
43
|
+
maxY: range.minY + 1,
|
|
44
|
+
zoom: range.zoom,
|
|
45
|
+
});
|
|
46
|
+
range.minY++;
|
|
47
|
+
reminderX += remaining;
|
|
48
|
+
requiredForFullBatch -= remaining;
|
|
49
|
+
dy--;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//add max full lines
|
|
53
|
+
const requiredLines = Math.floor(requiredForFullBatch / dx);
|
|
54
|
+
const yRange = Math.min(requiredLines, dy);
|
|
55
|
+
if (yRange > 0) {
|
|
56
|
+
targetRanges.push({
|
|
57
|
+
minX: range.minX,
|
|
58
|
+
maxX: range.maxX,
|
|
59
|
+
minY: range.minY,
|
|
60
|
+
maxY: range.minY + yRange,
|
|
61
|
+
zoom: range.zoom,
|
|
62
|
+
});
|
|
63
|
+
range.minY += yRange;
|
|
64
|
+
dy -= yRange;
|
|
65
|
+
requiredForFullBatch -= yRange * dx;
|
|
66
|
+
}
|
|
67
|
+
//add partial lines beginning
|
|
68
|
+
if (requiredForFullBatch > 0 && range.minY < range.maxY) {
|
|
69
|
+
const endX = Math.min(range.minX + requiredForFullBatch, range.maxX);
|
|
70
|
+
targetRanges.push({
|
|
71
|
+
minX: range.minX,
|
|
72
|
+
maxX: endX,
|
|
73
|
+
minY: range.minY,
|
|
74
|
+
maxY: range.minY + 1,
|
|
75
|
+
zoom: range.zoom,
|
|
76
|
+
});
|
|
77
|
+
requiredForFullBatch -= endX - range.minX;
|
|
78
|
+
if (endX < range.maxX) {
|
|
79
|
+
reminderX = endX;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
range.minY++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (requiredForFullBatch === 0) {
|
|
86
|
+
yield await Promise.resolve(targetRanges);
|
|
87
|
+
targetRanges = [];
|
|
88
|
+
requiredForFullBatch = batchSize;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await (0, timeout_1.timeout)(0); // TODO: * This is a hot fix to keep work async and handle concurrency requests while handling the task batch merging, remove this when moving to the new utils package ! *
|
|
92
|
+
}
|
|
93
|
+
if (targetRanges.length > 0) {
|
|
94
|
+
yield await Promise.resolve(targetRanges);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.tileBatchGenerator = tileBatchGenerator;
|
|
194
98
|
//# sourceMappingURL=tileBatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileBatcher.js","sourceRoot":"","sources":["../../src/geo/tileBatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tileBatcher.js","sourceRoot":"","sources":["../../src/geo/tileBatcher.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAE3C;;;;GAIG;AACH,KAAK,SAAS,CAAC,CAAC,kBAAkB,CAAC,SAAiB,EAAE,MAAkC;IACtF,IAAI,YAAY,GAAiB,EAAE,CAAC;IACpC,IAAI,oBAAoB,GAAG,SAAS,CAAC;IACrC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;QAChC,MAAM,EAAE,GAAG,KAAK,CAAC,IAA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