@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geoConvertor.js","sourceRoot":"","sources":["../../src/geo/geoConvertor.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"geoConvertor.js","sourceRoot":"","sources":["../../src/geo/geoConvertor.ts"],"names":[],"mappings":";;;AAAA,+DAA4D;AAG5D,mCAAyC;AAEzC;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,SAAiB,EAAE,SAAqB,uBAAU,CAAC,UAAU,EAAS,EAAE;IACnH,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;IACzB,IAAI,MAAM,KAAK,uBAAU,CAAC,UAAU,EAAE;QACpC,GAAG,GAAG,CAAC,GAAG,CAAC;KACZ;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,GAAG,UAAU,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC;IAC9D,+DAA+D;IAC/D,MAAM,KAAK,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,GAAG,GAAG,CAAC;IAElG,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACpB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACpB,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB;AAEF;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,IAAW,EAAE,SAAqB,uBAAU,CAAC,UAAU,EAAU,EAAE;IAC/F,MAAM,MAAM,GAAG,GAAG,CAAC;IACnB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,UAAU,GAAG,MAAM,CAAC;IACzC,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,UAAU,GAAG,MAAM,CAAC;IAEvC,IAAI,MAAM,KAAK,uBAAU,CAAC,UAAU,EAAE;QACpC,GAAG,GAAG,CAAC,GAAG,CAAC;KACZ;IAED,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,GAAG;KACf,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,aAAa,iBAexB"}
|
package/dist/geo/geoHash.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Feature, MultiPolygon, Polygon } from '@turf/turf';
|
|
2
|
-
import { BBox2d } from '@turf/helpers/dist/js/lib/geojson';
|
|
3
|
-
import { ITile } from '../models/interfaces/geo/iTile';
|
|
4
|
-
import { TileOrigin } from '../models/enums/geo/tileOrigin';
|
|
5
|
-
/**
|
|
6
|
-
* converts geohash string to its bbox in wgs84 degrees
|
|
7
|
-
* @param geohash geohash string
|
|
8
|
-
* @returns bbox of the supplied geohash
|
|
9
|
-
*/
|
|
10
|
-
export declare const decodeGeoHash: (geohash: string) => BBox2d;
|
|
11
|
-
/**
|
|
12
|
-
* generates optimized geohash iterator for given polygon and target zoom level
|
|
13
|
-
* @param polygon polygon to cover with geohashes
|
|
14
|
-
* @param maxTileZoom target zoom level
|
|
15
|
-
* @returns generator that yields the matching geohashes
|
|
16
|
-
*/
|
|
17
|
-
export declare const createGeoHashGenerator: (polygon: Polygon | Feature<Polygon | MultiPolygon>, maxTileZoom?: number) => Generator<string>;
|
|
18
|
-
/**
|
|
19
|
-
* generate all tiles in supplied polygon
|
|
20
|
-
* @param polygon polygon to cover with tiles
|
|
21
|
-
* @param tileZoom target tiles zoom level
|
|
22
|
-
* @param origin target tiles grid origin location (default ll)
|
|
23
|
-
*/
|
|
24
|
-
export declare function tileGenerator(polygon: Polygon | Feature<Polygon | MultiPolygon>, tileZoom: number, origin?: TileOrigin): AsyncGenerator<ITile>;
|
|
1
|
+
import { Feature, MultiPolygon, Polygon } from '@turf/turf';
|
|
2
|
+
import { BBox2d } from '@turf/helpers/dist/js/lib/geojson';
|
|
3
|
+
import { ITile } from '../models/interfaces/geo/iTile';
|
|
4
|
+
import { TileOrigin } from '../models/enums/geo/tileOrigin';
|
|
5
|
+
/**
|
|
6
|
+
* converts geohash string to its bbox in wgs84 degrees
|
|
7
|
+
* @param geohash geohash string
|
|
8
|
+
* @returns bbox of the supplied geohash
|
|
9
|
+
*/
|
|
10
|
+
export declare const decodeGeoHash: (geohash: string) => BBox2d;
|
|
11
|
+
/**
|
|
12
|
+
* generates optimized geohash iterator for given polygon and target zoom level
|
|
13
|
+
* @param polygon polygon to cover with geohashes
|
|
14
|
+
* @param maxTileZoom target zoom level
|
|
15
|
+
* @returns generator that yields the matching geohashes
|
|
16
|
+
*/
|
|
17
|
+
export declare const createGeoHashGenerator: (polygon: Polygon | Feature<Polygon | MultiPolygon>, maxTileZoom?: number) => Generator<string>;
|
|
18
|
+
/**
|
|
19
|
+
* generate all tiles in supplied polygon
|
|
20
|
+
* @param polygon polygon to cover with tiles
|
|
21
|
+
* @param tileZoom target tiles zoom level
|
|
22
|
+
* @param origin target tiles grid origin location (default ll)
|
|
23
|
+
*/
|
|
24
|
+
export declare function tileGenerator(polygon: Polygon | Feature<Polygon | MultiPolygon>, tileZoom: number, origin?: TileOrigin): AsyncGenerator<ITile>;
|
|
25
25
|
//# sourceMappingURL=geoHash.d.ts.map
|
|
File without changes
|
package/dist/geo/geoHash.js
CHANGED
|
@@ -1,275 +1,135 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_b.label = 6;
|
|
136
|
-
case 6:
|
|
137
|
-
hashes_1_1 = hashes_1.next();
|
|
138
|
-
return [3 /*break*/, 2];
|
|
139
|
-
case 7: return [3 /*break*/, 10];
|
|
140
|
-
case 8:
|
|
141
|
-
e_1_1 = _b.sent();
|
|
142
|
-
e_1 = { error: e_1_1 };
|
|
143
|
-
return [3 /*break*/, 10];
|
|
144
|
-
case 9:
|
|
145
|
-
try {
|
|
146
|
-
if (hashes_1_1 && !hashes_1_1.done && (_a = hashes_1.return)) _a.call(hashes_1);
|
|
147
|
-
}
|
|
148
|
-
finally { if (e_1) throw e_1.error; }
|
|
149
|
-
return [7 /*endfinally*/];
|
|
150
|
-
case 10: return [2 /*return*/];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* converts geohash string to its bbox in wgs84 degrees
|
|
156
|
-
* @param geohash geohash string
|
|
157
|
-
* @returns bbox of the supplied geohash
|
|
158
|
-
*/
|
|
159
|
-
var decodeGeoHash = function (geohash) {
|
|
160
|
-
var bboxFromGeohash = ngeohash.decode_bbox(geohash);
|
|
161
|
-
// ngeohash.decode_bbox gives a lat-lon array. we change it to lon-lat so @turf can use it.
|
|
162
|
-
var lonLatBbox = [bboxFromGeohash[1], bboxFromGeohash[0], bboxFromGeohash[3], bboxFromGeohash[2]];
|
|
163
|
-
return lonLatBbox;
|
|
164
|
-
};
|
|
165
|
-
exports.decodeGeoHash = decodeGeoHash;
|
|
166
|
-
/**
|
|
167
|
-
* generates optimized geohash iterator for given polygon and target zoom level
|
|
168
|
-
* @param polygon polygon to cover with geohashes
|
|
169
|
-
* @param maxTileZoom target zoom level
|
|
170
|
-
* @returns generator that yields the matching geohashes
|
|
171
|
-
*/
|
|
172
|
-
var createGeoHashGenerator = function (polygon, maxTileZoom) {
|
|
173
|
-
if (maxTileZoom === void 0) { maxTileZoom = MAX_STANDARD_ZOOM; }
|
|
174
|
-
var bbox = (0, turf_1.bbox)(polygon);
|
|
175
|
-
bbox = (0, bboxUtils_1.snapBBoxToTileGrid)(bbox, maxTileZoom);
|
|
176
|
-
//at this precision ea geo hash is a tile or smaller
|
|
177
|
-
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
178
|
-
var zoomPrecision = Math.floor((2 / 5) * (maxTileZoom + 1));
|
|
179
|
-
var precisionMod = maxTileZoom % 5;
|
|
180
|
-
if (precisionMod > 0 && precisionMod <= 3) {
|
|
181
|
-
zoomPrecision++;
|
|
182
|
-
}
|
|
183
|
-
else if (precisionMod > 3) {
|
|
184
|
-
zoomPrecision += 2;
|
|
185
|
-
}
|
|
186
|
-
/* eslint-enable @typescript-eslint/no-magic-numbers */
|
|
187
|
-
return geoHash(1, zoomPrecision, polygon, bbox);
|
|
188
|
-
};
|
|
189
|
-
exports.createGeoHashGenerator = createGeoHashGenerator;
|
|
190
|
-
/**
|
|
191
|
-
* generate all tiles in supplied polygon
|
|
192
|
-
* @param polygon polygon to cover with tiles
|
|
193
|
-
* @param tileZoom target tiles zoom level
|
|
194
|
-
* @param origin target tiles grid origin location (default ll)
|
|
195
|
-
*/
|
|
196
|
-
function tileGenerator(polygon, tileZoom, origin) {
|
|
197
|
-
if (origin === void 0) { origin = tileOrigin_1.TileOrigin.LOWER_LEFT; }
|
|
198
|
-
return __asyncGenerator(this, arguments, function tileGenerator_1() {
|
|
199
|
-
var hashGen, hashGen_1, hashGen_1_1, hash, bbox, minTile, maxTile, minX, maxX, minY, maxY, x, y, e_2_1;
|
|
200
|
-
var e_2, _a;
|
|
201
|
-
return __generator(this, function (_b) {
|
|
202
|
-
switch (_b.label) {
|
|
203
|
-
case 0:
|
|
204
|
-
hashGen = (0, exports.createGeoHashGenerator)(polygon, tileZoom);
|
|
205
|
-
_b.label = 1;
|
|
206
|
-
case 1:
|
|
207
|
-
_b.trys.push([1, 13, 14, 19]);
|
|
208
|
-
hashGen_1 = __asyncValues(hashGen);
|
|
209
|
-
_b.label = 2;
|
|
210
|
-
case 2: return [4 /*yield*/, __await(hashGen_1.next())];
|
|
211
|
-
case 3:
|
|
212
|
-
if (!(hashGen_1_1 = _b.sent(), !hashGen_1_1.done)) return [3 /*break*/, 12];
|
|
213
|
-
hash = hashGen_1_1.value;
|
|
214
|
-
bbox = (0, exports.decodeGeoHash)(hash);
|
|
215
|
-
minTile = (0, geoConvertor_1.degreesToTile)({
|
|
216
|
-
longitude: bbox[0],
|
|
217
|
-
latitude: bbox[1],
|
|
218
|
-
}, tileZoom, origin);
|
|
219
|
-
maxTile = (0, geoConvertor_1.degreesToTile)({
|
|
220
|
-
longitude: bbox[2],
|
|
221
|
-
latitude: bbox[3],
|
|
222
|
-
}, tileZoom, origin);
|
|
223
|
-
minX = Math.min(minTile.x, maxTile.x);
|
|
224
|
-
maxX = minTile.x + maxTile.x - minX;
|
|
225
|
-
minY = Math.min(minTile.y, maxTile.y);
|
|
226
|
-
maxY = minTile.y + maxTile.y - minY;
|
|
227
|
-
x = minX;
|
|
228
|
-
_b.label = 4;
|
|
229
|
-
case 4:
|
|
230
|
-
if (!(x < maxX)) return [3 /*break*/, 11];
|
|
231
|
-
y = minY;
|
|
232
|
-
_b.label = 5;
|
|
233
|
-
case 5:
|
|
234
|
-
if (!(y < maxY)) return [3 /*break*/, 10];
|
|
235
|
-
return [4 /*yield*/, __await(Promise.resolve({
|
|
236
|
-
x: x,
|
|
237
|
-
y: y,
|
|
238
|
-
zoom: tileZoom,
|
|
239
|
-
}))];
|
|
240
|
-
case 6: return [4 /*yield*/, __await.apply(void 0, [_b.sent()])];
|
|
241
|
-
case 7: return [4 /*yield*/, _b.sent()];
|
|
242
|
-
case 8:
|
|
243
|
-
_b.sent();
|
|
244
|
-
_b.label = 9;
|
|
245
|
-
case 9:
|
|
246
|
-
y++;
|
|
247
|
-
return [3 /*break*/, 5];
|
|
248
|
-
case 10:
|
|
249
|
-
x++;
|
|
250
|
-
return [3 /*break*/, 4];
|
|
251
|
-
case 11: return [3 /*break*/, 2];
|
|
252
|
-
case 12: return [3 /*break*/, 19];
|
|
253
|
-
case 13:
|
|
254
|
-
e_2_1 = _b.sent();
|
|
255
|
-
e_2 = { error: e_2_1 };
|
|
256
|
-
return [3 /*break*/, 19];
|
|
257
|
-
case 14:
|
|
258
|
-
_b.trys.push([14, , 17, 18]);
|
|
259
|
-
if (!(hashGen_1_1 && !hashGen_1_1.done && (_a = hashGen_1.return))) return [3 /*break*/, 16];
|
|
260
|
-
return [4 /*yield*/, __await(_a.call(hashGen_1))];
|
|
261
|
-
case 15:
|
|
262
|
-
_b.sent();
|
|
263
|
-
_b.label = 16;
|
|
264
|
-
case 16: return [3 /*break*/, 18];
|
|
265
|
-
case 17:
|
|
266
|
-
if (e_2) throw e_2.error;
|
|
267
|
-
return [7 /*endfinally*/];
|
|
268
|
-
case 18: return [7 /*endfinally*/];
|
|
269
|
-
case 19: return [2 /*return*/];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
exports.tileGenerator = tileGenerator;
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.tileGenerator = exports.createGeoHashGenerator = exports.decodeGeoHash = void 0;
|
|
27
|
+
const turf_1 = require("@turf/turf");
|
|
28
|
+
const ngeohash = __importStar(require("ngeohash"));
|
|
29
|
+
const tileOrigin_1 = require("../models/enums/geo/tileOrigin");
|
|
30
|
+
const geoConvertor_1 = require("./geoConvertor");
|
|
31
|
+
const bboxUtils_1 = require("./bboxUtils");
|
|
32
|
+
const MAX_STANDARD_ZOOM = 21;
|
|
33
|
+
const bboxIntersection = (bbox1, bbox2) => {
|
|
34
|
+
const minLon = Math.max(bbox1[0], bbox2[0]);
|
|
35
|
+
const minLat = Math.max(bbox1[1], bbox2[1]);
|
|
36
|
+
const maxLon = Math.min(bbox1[2], bbox2[2]);
|
|
37
|
+
const maxLat = Math.min(bbox1[3], bbox2[3]);
|
|
38
|
+
return [minLon, minLat, maxLon, maxLat];
|
|
39
|
+
};
|
|
40
|
+
const isSubHash = (hash, parent) => {
|
|
41
|
+
return hash.startsWith(parent);
|
|
42
|
+
};
|
|
43
|
+
function* geoHash(precision, maxPrecision, polygon, bbox, parentHash = '') {
|
|
44
|
+
// ngeohash bbox is a lat-lon array. we change turf bbox to it so it can be used.
|
|
45
|
+
const hashes = ngeohash.bboxes(bbox[1], bbox[0], bbox[3], bbox[2], precision);
|
|
46
|
+
if (hashes.length > 0) {
|
|
47
|
+
for (const hash of hashes) {
|
|
48
|
+
const hashBbox = (0, exports.decodeGeoHash)(hash);
|
|
49
|
+
const hashPoly = (0, turf_1.bboxPolygon)(hashBbox);
|
|
50
|
+
const intersection = (0, turf_1.intersect)(polygon, hashPoly);
|
|
51
|
+
if (intersection === null || !isSubHash(hash, parentHash)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const intArea = (0, turf_1.area)(intersection);
|
|
55
|
+
const hashArea = (0, turf_1.area)(hashPoly);
|
|
56
|
+
if (intArea == hashArea || precision == maxPrecision) {
|
|
57
|
+
yield hash;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const subBbox = bboxIntersection(hashBbox, bbox);
|
|
61
|
+
yield* geoHash(precision + 1, maxPrecision, polygon, subBbox, hash);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* converts geohash string to its bbox in wgs84 degrees
|
|
68
|
+
* @param geohash geohash string
|
|
69
|
+
* @returns bbox of the supplied geohash
|
|
70
|
+
*/
|
|
71
|
+
const decodeGeoHash = (geohash) => {
|
|
72
|
+
const bboxFromGeohash = ngeohash.decode_bbox(geohash);
|
|
73
|
+
// ngeohash.decode_bbox gives a lat-lon array. we change it to lon-lat so @turf can use it.
|
|
74
|
+
const lonLatBbox = [bboxFromGeohash[1], bboxFromGeohash[0], bboxFromGeohash[3], bboxFromGeohash[2]];
|
|
75
|
+
return lonLatBbox;
|
|
76
|
+
};
|
|
77
|
+
exports.decodeGeoHash = decodeGeoHash;
|
|
78
|
+
/**
|
|
79
|
+
* generates optimized geohash iterator for given polygon and target zoom level
|
|
80
|
+
* @param polygon polygon to cover with geohashes
|
|
81
|
+
* @param maxTileZoom target zoom level
|
|
82
|
+
* @returns generator that yields the matching geohashes
|
|
83
|
+
*/
|
|
84
|
+
const createGeoHashGenerator = (polygon, maxTileZoom = MAX_STANDARD_ZOOM) => {
|
|
85
|
+
let bbox = (0, turf_1.bbox)(polygon);
|
|
86
|
+
bbox = (0, bboxUtils_1.snapBBoxToTileGrid)(bbox, maxTileZoom);
|
|
87
|
+
//at this precision ea geo hash is a tile or smaller
|
|
88
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
89
|
+
let zoomPrecision = Math.floor((2 / 5) * (maxTileZoom + 1));
|
|
90
|
+
const precisionMod = maxTileZoom % 5;
|
|
91
|
+
if (precisionMod > 0 && precisionMod <= 3) {
|
|
92
|
+
zoomPrecision++;
|
|
93
|
+
}
|
|
94
|
+
else if (precisionMod > 3) {
|
|
95
|
+
zoomPrecision += 2;
|
|
96
|
+
}
|
|
97
|
+
/* eslint-enable @typescript-eslint/no-magic-numbers */
|
|
98
|
+
return geoHash(1, zoomPrecision, polygon, bbox);
|
|
99
|
+
};
|
|
100
|
+
exports.createGeoHashGenerator = createGeoHashGenerator;
|
|
101
|
+
/**
|
|
102
|
+
* generate all tiles in supplied polygon
|
|
103
|
+
* @param polygon polygon to cover with tiles
|
|
104
|
+
* @param tileZoom target tiles zoom level
|
|
105
|
+
* @param origin target tiles grid origin location (default ll)
|
|
106
|
+
*/
|
|
107
|
+
async function* tileGenerator(polygon, tileZoom, origin = tileOrigin_1.TileOrigin.LOWER_LEFT) {
|
|
108
|
+
const hashGen = (0, exports.createGeoHashGenerator)(polygon, tileZoom);
|
|
109
|
+
for await (const hash of hashGen) {
|
|
110
|
+
const bbox = (0, exports.decodeGeoHash)(hash);
|
|
111
|
+
const minTile = (0, geoConvertor_1.degreesToTile)({
|
|
112
|
+
longitude: bbox[0],
|
|
113
|
+
latitude: bbox[1],
|
|
114
|
+
}, tileZoom, origin);
|
|
115
|
+
const maxTile = (0, geoConvertor_1.degreesToTile)({
|
|
116
|
+
longitude: bbox[2],
|
|
117
|
+
latitude: bbox[3],
|
|
118
|
+
}, tileZoom, origin);
|
|
119
|
+
const minX = Math.min(minTile.x, maxTile.x);
|
|
120
|
+
const maxX = minTile.x + maxTile.x - minX;
|
|
121
|
+
const minY = Math.min(minTile.y, maxTile.y);
|
|
122
|
+
const maxY = minTile.y + maxTile.y - minY;
|
|
123
|
+
for (let x = minX; x < maxX; x++) {
|
|
124
|
+
for (let y = minY; y < maxY; y++) {
|
|
125
|
+
yield await Promise.resolve({
|
|
126
|
+
x,
|
|
127
|
+
y,
|
|
128
|
+
zoom: tileZoom,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.tileGenerator = tileGenerator;
|
|
275
135
|
//# sourceMappingURL=geoHash.js.map
|
package/dist/geo/geoHash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geoHash.js","sourceRoot":"","sources":["../../src/geo/geoHash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geoHash.js","sourceRoot":"","sources":["../../src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,IAAI,CAAC,CAAC,CAAC;YAClB,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;SAClB,EACD,QAAQ,EACR,MAAM,CACP,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;QAE1C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;QAC1C,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAChC,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;gBAChC,MAAM,MAAM,OAAO,CAAC,OAAO,CAAC;oBAC1B,CAAC;oBACD,CAAC;oBACD,IAAI,EAAE,QAAQ;iBACf,CAAC,CAAC;aACJ;SACF;KACF;AACH,CAAC;AAvCD,sCAuCC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Feature, FeatureCollection, MultiPolygon, Polygon } from '@turf/turf';
|
|
2
|
-
/**
|
|
3
|
-
* tuft intersect supported footprint types
|
|
4
|
-
*/
|
|
5
|
-
declare type Footprint = Polygon | MultiPolygon | Feature<Polygon | MultiPolygon>;
|
|
6
|
-
/**
|
|
7
|
-
* return the intersection footprint of all specified footprints or null when there is no intersection
|
|
8
|
-
* @param footprints footprint list to intersect
|
|
9
|
-
* @returns intersection footprint or null
|
|
10
|
-
*/
|
|
11
|
-
declare const multiIntersect: (footprints: Footprint[]) => Footprint | null;
|
|
12
|
-
/**
|
|
13
|
-
* indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
|
|
14
|
-
* @param fc1 first featureCollection to compare equal
|
|
15
|
-
* @param fc2 second featureCollection to compare equal
|
|
16
|
-
* @returns true if same featureCollection, false if not
|
|
17
|
-
*/
|
|
18
|
-
declare const featureCollectionBooleanEqual: (fc1: FeatureCollection, fc2: FeatureCollection) => boolean;
|
|
19
|
-
export { multiIntersect, featureCollectionBooleanEqual, Footprint };
|
|
1
|
+
import { Feature, FeatureCollection, MultiPolygon, Polygon } from '@turf/turf';
|
|
2
|
+
/**
|
|
3
|
+
* tuft intersect supported footprint types
|
|
4
|
+
*/
|
|
5
|
+
declare type Footprint = Polygon | MultiPolygon | Feature<Polygon | MultiPolygon>;
|
|
6
|
+
/**
|
|
7
|
+
* return the intersection footprint of all specified footprints or null when there is no intersection
|
|
8
|
+
* @param footprints footprint list to intersect
|
|
9
|
+
* @returns intersection footprint or null
|
|
10
|
+
*/
|
|
11
|
+
declare const multiIntersect: (footprints: Footprint[]) => Footprint | null;
|
|
12
|
+
/**
|
|
13
|
+
* indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
|
|
14
|
+
* @param fc1 first featureCollection to compare equal
|
|
15
|
+
* @param fc2 second featureCollection to compare equal
|
|
16
|
+
* @returns true if same featureCollection, false if not
|
|
17
|
+
*/
|
|
18
|
+
declare const featureCollectionBooleanEqual: (fc1: FeatureCollection, fc2: FeatureCollection) => boolean;
|
|
19
|
+
export { multiIntersect, featureCollectionBooleanEqual, Footprint };
|
|
20
20
|
//# sourceMappingURL=geoIntersection.d.ts.map
|
|
File without changes
|