@map-colonies/mc-utils 3.1.0 → 3.3.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.js +17 -17
- package/dist/arrays/subGroups.d.ts +8 -8
- package/dist/arrays/subGroups.js +33 -33
- package/dist/communication/http/httpClient.d.ts +29 -29
- package/dist/communication/http/httpClient.d.ts.map +1 -1
- package/dist/communication/http/httpClient.js +353 -317
- package/dist/communication/http/httpClient.js.map +1 -1
- package/dist/communication/http/index.d.ts +1 -1
- package/dist/communication/http/index.js +17 -17
- package/dist/communication/index.d.ts +1 -1
- package/dist/communication/index.js +17 -17
- package/dist/dateTime/getUTCDate.d.ts +1 -1
- package/dist/dateTime/getUTCDate.js +10 -10
- package/dist/dateTime/index.d.ts +1 -1
- package/dist/dateTime/index.js +17 -17
- package/dist/geo/bboxUtils.d.ts +23 -23
- package/dist/geo/bboxUtils.js +89 -89
- package/dist/geo/geoConvertor.d.ts +18 -18
- package/dist/geo/geoConvertor.js +49 -49
- package/dist/geo/geoHash.d.ts +24 -24
- package/dist/geo/geoHash.js +134 -134
- package/dist/geo/geoIntersection.d.ts +19 -19
- package/dist/geo/geoIntersection.js +70 -70
- package/dist/geo/index.d.ts +8 -8
- package/dist/geo/index.js +24 -24
- package/dist/geo/tileBatcher.d.ts +8 -8
- package/dist/geo/tileBatcher.js +97 -97
- package/dist/geo/tileRanger.d.ts +46 -46
- package/dist/geo/tileRanger.js +232 -232
- package/dist/geo/tiles.d.ts +82 -82
- package/dist/geo/tiles.js +219 -219
- package/dist/geo/tilesGenerator.d.ts +2 -2
- package/dist/geo/tilesGenerator.js +17 -17
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -22
- package/dist/models/enums/gdal/dataType.d.ts +16 -16
- package/dist/models/enums/gdal/dataType.js +20 -20
- package/dist/models/enums/gdal/index.d.ts +2 -2
- package/dist/models/enums/gdal/index.js +18 -18
- package/dist/models/enums/gdal/resamplingMethod.d.ts +16 -16
- package/dist/models/enums/gdal/resamplingMethod.js +20 -20
- package/dist/models/enums/geo/index.d.ts +1 -1
- package/dist/models/enums/geo/index.js +17 -17
- package/dist/models/enums/geo/tileOrigin.d.ts +7 -7
- package/dist/models/enums/geo/tileOrigin.js +11 -11
- package/dist/models/enums/index.d.ts +2 -2
- package/dist/models/enums/index.js +18 -18
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +18 -18
- package/dist/models/interfaces/geo/iPoint.d.ts +7 -7
- package/dist/models/interfaces/geo/iPoint.js +2 -2
- package/dist/models/interfaces/geo/iTile.d.ts +15 -15
- package/dist/models/interfaces/geo/iTile.js +2 -2
- package/dist/models/interfaces/geo/index.d.ts +2 -2
- package/dist/models/interfaces/geo/index.js +18 -18
- package/dist/models/interfaces/index.d.ts +1 -1
- package/dist/models/interfaces/index.js +17 -17
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +17 -17
- package/dist/utils/timeout.d.ts +4 -4
- package/dist/utils/timeout.js +22 -22
- package/package.json +79 -79
package/dist/geo/geoHash.js
CHANGED
|
@@ -1,135 +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
|
-
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;
|
|
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;
|
|
135
135
|
//# sourceMappingURL=geoHash.js.map
|
|
@@ -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
|
|
@@ -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
|
-
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;
|
|
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
|
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.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
|
|
@@ -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
|