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