@loaders.gl/ogc 5.0.0-beta.1 → 5.0.0-beta.2
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 +4 -2
- package/dist/{wms/gml-loader.cjs → gml-loader.cjs} +2748 -3796
- package/dist/gml-loader.cjs.map +6 -0
- package/dist/gml-loader.d.ts +2 -0
- package/dist/gml-loader.d.ts.map +1 -0
- package/dist/gml-loader.js +2 -0
- package/dist/gml-loader.js.map +1 -0
- package/dist/index.cjs +333 -4376
- package/dist/index.cjs.map +3 -3
- package/dist/stac/index.cjs +19 -1041
- package/dist/stac/index.cjs.map +3 -3
- package/dist/stac/stac-source-loader-types.js +3 -3
- package/dist/stac/stac-source-loader-types.js.map +1 -1
- package/dist/{stac/stac-source.cjs → stac-source.cjs} +212 -779
- package/dist/stac-source.cjs.map +6 -0
- package/dist/stac-source.d.ts +2 -0
- package/dist/stac-source.d.ts.map +1 -0
- package/dist/stac-source.js +2 -0
- package/dist/stac-source.js.map +1 -0
- package/dist/wms/bundled.cjs +2552 -3514
- package/dist/wms/bundled.cjs.map +3 -3
- package/dist/wms/csw-capabilities-loader-with-parser.d.ts +1 -1
- package/dist/wms/csw-capabilities-loader-with-parser.d.ts.map +1 -1
- package/dist/wms/csw-capabilities-loader.d.ts +1 -1
- package/dist/wms/csw-capabilities-loader.d.ts.map +1 -1
- package/dist/wms/csw-capabilities-loader.js +1 -1
- package/dist/wms/csw-domain-loader-with-parser.d.ts +1 -1
- package/dist/wms/csw-domain-loader-with-parser.d.ts.map +1 -1
- package/dist/wms/csw-domain-loader.d.ts +1 -1
- package/dist/wms/csw-domain-loader.d.ts.map +1 -1
- package/dist/wms/csw-domain-loader.js +1 -1
- package/dist/wms/csw-records-loader-with-parser.d.ts +1 -1
- package/dist/wms/csw-records-loader-with-parser.d.ts.map +1 -1
- package/dist/wms/csw-records-loader.d.ts +1 -1
- package/dist/wms/csw-records-loader.d.ts.map +1 -1
- package/dist/wms/csw-records-loader.js +1 -1
- package/dist/wms/csw-source-loader.js +1 -1
- package/dist/wms/gml-loader-types.js +2 -2
- package/dist/wms/gml-loader-types.js.map +1 -1
- package/dist/wms/index.cjs +3035 -3896
- package/dist/wms/index.cjs.map +3 -3
- package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts.map +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts.map +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts.map +1 -1
- package/dist/wms/lib/parsers/csw/parse-csw-records.js +2 -5
- package/dist/wms/lib/parsers/csw/parse-csw-records.js.map +1 -1
- package/dist/wms/lib/parsers/csw/parse-exception-report.js +2 -2
- package/dist/wms/lib/parsers/csw/parse-exception-report.js.map +1 -1
- package/dist/wms/lib/parsers/wms/parse-wms-error.d.ts.map +1 -1
- package/dist/wms/lib/parsers/wms/parse-wms-error.js +3 -1
- package/dist/wms/lib/parsers/wms/parse-wms-error.js.map +1 -1
- package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts +1 -1
- package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts.map +1 -1
- package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js +1 -1
- package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js.map +1 -1
- package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts +1 -1
- package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts.map +1 -1
- package/dist/wms/lib/parsers/xml/parse-xml-text.js +2 -1
- package/dist/wms/lib/parsers/xml/parse-xml-text.js.map +1 -1
- package/dist/wms/unbundled.cjs +304 -3330
- package/dist/wms/unbundled.cjs.map +3 -3
- package/dist/wms/wcs-source-loader.js +1 -1
- package/dist/wms/wcs-source-loader.js.map +1 -1
- package/dist/wms/wfs-capabilities-loader.js +1 -1
- package/dist/wms/wfs-source-loader.d.ts +2 -2
- package/dist/wms/wfs-source-loader.js +2 -2
- package/dist/wms/wip/wcs-capabilities-loader.js +1 -1
- package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts +1 -1
- package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts.map +1 -1
- package/dist/wms/wip/wmts-capabilities-loader.d.ts +1 -1
- package/dist/wms/wip/wmts-capabilities-loader.d.ts.map +1 -1
- package/dist/wms/wip/wmts-capabilities-loader.js +1 -1
- package/dist/wms/wms-capabilities-loader-with-parser.d.ts +1 -1
- package/dist/wms/wms-capabilities-loader-with-parser.d.ts.map +1 -1
- package/dist/wms/wms-capabilities-loader.d.ts +1 -1
- package/dist/wms/wms-capabilities-loader.d.ts.map +1 -1
- package/dist/wms/wms-capabilities-loader.js +1 -1
- package/dist/wms/wms-error-loader.js +1 -1
- package/dist/wms/wms-source-loader.d.ts +2 -2
- package/dist/wms/wms-source-loader.d.ts.map +1 -1
- package/dist/wms/wms-source-loader.js +3 -3
- package/dist/wms/wms-source-loader.js.map +1 -1
- package/dist/wms/wmts-capabilities-loader.js +1 -1
- package/dist/wms/wmts-capabilities-loader.js.map +1 -1
- package/dist/wms/wmts-source-loader.d.ts +2 -2
- package/dist/wms/wmts-source-loader.d.ts.map +1 -1
- package/dist/wms/wmts-source-loader.js +3 -3
- package/dist/wms/wmts-source-loader.js.map +1 -1
- package/dist/{wms/wmts-capabilities-loader-with-parser.cjs → wmts-capabilities-loader-with-parser.cjs} +218 -179
- package/dist/wmts-capabilities-loader-with-parser.cjs.map +6 -0
- package/dist/wmts-capabilities-loader-with-parser.d.ts +2 -0
- package/dist/wmts-capabilities-loader-with-parser.d.ts.map +1 -0
- package/dist/wmts-capabilities-loader-with-parser.js +3 -0
- package/dist/wmts-capabilities-loader-with-parser.js.map +1 -0
- package/package.json +27 -20
- package/src/gml-loader.ts +1 -0
- package/src/stac/stac-source-loader-types.ts +2 -2
- package/src/stac-source.ts +1 -0
- package/src/wms/csw-capabilities-loader-with-parser.ts +1 -1
- package/src/wms/csw-capabilities-loader.ts +1 -1
- package/src/wms/csw-domain-loader-with-parser.ts +1 -1
- package/src/wms/csw-domain-loader.ts +1 -1
- package/src/wms/csw-records-loader-with-parser.ts +1 -1
- package/src/wms/csw-records-loader.ts +1 -1
- package/src/wms/gml-loader-types.ts +1 -1
- package/src/wms/lib/parsers/csw/parse-csw-capabilities.ts +1 -1
- package/src/wms/lib/parsers/csw/parse-csw-domain.ts +1 -1
- package/src/wms/lib/parsers/csw/parse-csw-records.ts +3 -6
- package/src/wms/lib/parsers/csw/parse-exception-report.ts +2 -2
- package/src/wms/lib/parsers/wms/parse-wms-error.ts +3 -1
- package/src/wms/lib/parsers/wms/parse-wms-layer-description.ts +1 -1
- package/src/wms/lib/parsers/wmts/parse-wmts-capabilities.ts +1 -1
- package/src/wms/lib/parsers/xml/parse-xml-text.ts +3 -2
- package/src/wms/wcs-source-loader.ts +1 -1
- package/src/wms/wfs-source-loader.ts +2 -2
- package/src/wms/wip/wms-feature-info-loader-with-parser.ts +1 -1
- package/src/wms/wip/wms-feature-info-loader.ts +1 -1
- package/src/wms/wip/wms-layer-description-loader-with-parser.ts +1 -1
- package/src/wms/wip/wms-layer-description-loader.ts +1 -1
- package/src/wms/wip/wmts-capabilities-loader-with-parser.ts +1 -1
- package/src/wms/wip/wmts-capabilities-loader.ts +1 -1
- package/src/wms/wms-capabilities-loader-with-parser.ts +1 -1
- package/src/wms/wms-capabilities-loader.ts +1 -1
- package/src/wms/wms-source-loader.ts +5 -13
- package/src/wms/wmts-capabilities-loader.ts +1 -1
- package/src/wms/wmts-source-loader.ts +5 -5
- package/src/wmts-capabilities-loader-with-parser.ts +2 -0
- package/dist/stac/stac-source.cjs.map +0 -6
- package/dist/wms/gml-loader.cjs.map +0 -6
- package/dist/wms/wmts-capabilities-loader-with-parser.cjs.map +0 -6
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __esm = (fn, res, err) => function __init() {
|
|
7
|
-
if (err) throw err[0];
|
|
8
|
-
try {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
throw err = [e], e;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
8
|
var __export = (target, all) => {
|
|
15
9
|
for (var name in all)
|
|
16
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,9 +17,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
17
|
}
|
|
24
18
|
return to;
|
|
25
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
26
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
29
|
|
|
30
|
+
// dist/stac-source.js
|
|
31
|
+
var stac_source_exports = {};
|
|
32
|
+
__export(stac_source_exports, {
|
|
33
|
+
STACSource: () => STACSource,
|
|
34
|
+
STACSourceLoader: () => STACSourceLoaderWithParser,
|
|
35
|
+
STACSourceLoaderWithParser: () => STACSourceLoaderWithParser
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(stac_source_exports);
|
|
38
|
+
|
|
28
39
|
// ../core/src/loader-utils/lib/log-utils/log.ts
|
|
40
|
+
var import_log = require("probe.gl/log");
|
|
41
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
42
|
+
var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
|
|
29
43
|
function createLog() {
|
|
30
44
|
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
31
45
|
globalThis.loaders ||= {};
|
|
@@ -35,26 +49,11 @@ function createLog() {
|
|
|
35
49
|
globalThis.probe.loaders = log2;
|
|
36
50
|
return log2;
|
|
37
51
|
}
|
|
38
|
-
var
|
|
39
|
-
var init_log = __esm({
|
|
40
|
-
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
41
|
-
"use strict";
|
|
42
|
-
import_log = require("probe.gl/log");
|
|
43
|
-
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
44
|
-
version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
|
|
45
|
-
log = createLog();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
52
|
+
var log = createLog();
|
|
48
53
|
|
|
49
54
|
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
50
|
-
var isObject
|
|
51
|
-
var
|
|
52
|
-
"../core/src/loader-utils/lib/javascript-utils/is-type.ts"() {
|
|
53
|
-
"use strict";
|
|
54
|
-
isObject = (value) => value !== null && typeof value === "object";
|
|
55
|
-
isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
55
|
+
var isObject = (value) => value !== null && typeof value === "object";
|
|
56
|
+
var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
58
57
|
|
|
59
58
|
// ../core/src/loader-utils/lib/option-utils/merge-options.ts
|
|
60
59
|
function mergeOptions(baseOptions, newOptions) {
|
|
@@ -78,12 +77,6 @@ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
|
78
77
|
}
|
|
79
78
|
return options;
|
|
80
79
|
}
|
|
81
|
-
var init_merge_options = __esm({
|
|
82
|
-
"../core/src/loader-utils/lib/option-utils/merge-options.ts"() {
|
|
83
|
-
"use strict";
|
|
84
|
-
init_is_type();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
80
|
|
|
88
81
|
// ../core/src/loader-utils/lib/request-utils/authentication.ts
|
|
89
82
|
function resolveCredentials(credentials, authentications = []) {
|
|
@@ -121,13 +114,10 @@ function isAuthentication(credential) {
|
|
|
121
114
|
if (credential.type === "request") return typeof credential.authenticate === "function";
|
|
122
115
|
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
123
116
|
}
|
|
124
|
-
var init_authentication = __esm({
|
|
125
|
-
"../core/src/loader-utils/lib/request-utils/authentication.ts"() {
|
|
126
|
-
"use strict";
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
117
|
|
|
130
118
|
// ../core/src/loader-utils/lib/request-utils/request-credentials.ts
|
|
119
|
+
var AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
120
|
+
var refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
131
121
|
function createAuthenticatedFetch(options) {
|
|
132
122
|
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
133
123
|
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
@@ -353,17 +343,10 @@ function isReplayableRequest(options) {
|
|
|
353
343
|
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
354
344
|
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
355
345
|
}
|
|
356
|
-
var AUTHENTICATED_FETCH, refreshPromises;
|
|
357
|
-
var init_request_credentials = __esm({
|
|
358
|
-
"../core/src/loader-utils/lib/request-utils/request-credentials.ts"() {
|
|
359
|
-
"use strict";
|
|
360
|
-
init_authentication();
|
|
361
|
-
AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
362
|
-
refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
346
|
|
|
366
347
|
// ../core/src/loader-utils/lib/path-utils/file-aliases.ts
|
|
348
|
+
var pathPrefix = "";
|
|
349
|
+
var fileAliases = {};
|
|
367
350
|
function resolvePath(filename) {
|
|
368
351
|
for (const alias in fileAliases) {
|
|
369
352
|
if (filename.startsWith(alias)) {
|
|
@@ -376,16 +359,89 @@ function resolvePath(filename) {
|
|
|
376
359
|
}
|
|
377
360
|
return filename;
|
|
378
361
|
}
|
|
379
|
-
var pathPrefix, fileAliases;
|
|
380
|
-
var init_file_aliases = __esm({
|
|
381
|
-
"../core/src/loader-utils/lib/path-utils/file-aliases.ts"() {
|
|
382
|
-
"use strict";
|
|
383
|
-
pathPrefix = "";
|
|
384
|
-
fileAliases = {};
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
362
|
|
|
388
363
|
// ../core/src/loader-utils/lib/sources/data-source.ts
|
|
364
|
+
var UNAVAILABLE_CORE_API = {
|
|
365
|
+
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
366
|
+
parse: unavailableCoreApiMethod("parse"),
|
|
367
|
+
parseFile: unavailableCoreApiMethod("parseFile"),
|
|
368
|
+
parseSync: unavailableCoreApiMethod("parseSync"),
|
|
369
|
+
parseInBatches: unavailableCoreApiMethod("parseInBatches"),
|
|
370
|
+
load: unavailableCoreApiMethod("load"),
|
|
371
|
+
loadInBatches: unavailableCoreApiMethod("loadInBatches")
|
|
372
|
+
};
|
|
373
|
+
var DataSource = class _DataSource {
|
|
374
|
+
static defaultOptions = {
|
|
375
|
+
core: {
|
|
376
|
+
type: "auto",
|
|
377
|
+
attributions: [],
|
|
378
|
+
loaders: [],
|
|
379
|
+
onError: void 0
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
optionsType;
|
|
383
|
+
options;
|
|
384
|
+
data;
|
|
385
|
+
url;
|
|
386
|
+
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
387
|
+
loadOptions;
|
|
388
|
+
/** A resolved fetch function extracted from the shared core options. */
|
|
389
|
+
fetch;
|
|
390
|
+
/** Shared source-level runtime hooks, when supplied by the source factory. */
|
|
391
|
+
coreApi;
|
|
392
|
+
/** Whether a real CoreAPI instance was injected by the integration layer. */
|
|
393
|
+
hasCoreApi;
|
|
394
|
+
_needsRefresh = true;
|
|
395
|
+
constructor(data, options, defaultOptions, coreApi) {
|
|
396
|
+
this.options = mergeOptions(
|
|
397
|
+
mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
|
|
398
|
+
options
|
|
399
|
+
);
|
|
400
|
+
this.data = data;
|
|
401
|
+
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
402
|
+
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
403
|
+
this.loadOptions = loadOptions;
|
|
404
|
+
const fetch2 = getFetchFunction(loadOptions);
|
|
405
|
+
this.coreApi = coreApi || UNAVAILABLE_CORE_API;
|
|
406
|
+
this.hasCoreApi = Boolean(coreApi);
|
|
407
|
+
this.fetch = fetch2;
|
|
408
|
+
}
|
|
409
|
+
setProps(options) {
|
|
410
|
+
const mergedOptions = mergeOptions(this.options, options);
|
|
411
|
+
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
412
|
+
this.options = mergedOptions;
|
|
413
|
+
this.loadOptions = loadOptions;
|
|
414
|
+
this.fetch = getFetchFunction(loadOptions);
|
|
415
|
+
this.setNeedsRefresh();
|
|
416
|
+
}
|
|
417
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
418
|
+
setNeedsRefresh() {
|
|
419
|
+
this._needsRefresh = true;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Does this data source need refreshing?
|
|
423
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
424
|
+
*/
|
|
425
|
+
getNeedsRefresh(clear = true) {
|
|
426
|
+
const needsRefresh = this._needsRefresh;
|
|
427
|
+
if (clear) {
|
|
428
|
+
this._needsRefresh = false;
|
|
429
|
+
}
|
|
430
|
+
return needsRefresh;
|
|
431
|
+
}
|
|
432
|
+
/** Reports a source-level failure through the configured callback or the shared logger. */
|
|
433
|
+
reportError(error, message) {
|
|
434
|
+
var _a;
|
|
435
|
+
const normalizedError = normalizeError(error, message);
|
|
436
|
+
const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
|
|
437
|
+
if (callback) {
|
|
438
|
+
callback(normalizedError, this);
|
|
439
|
+
} else {
|
|
440
|
+
log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
441
|
+
}
|
|
442
|
+
return normalizedError;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
389
445
|
function getFetchFunction(options) {
|
|
390
446
|
return getAuthenticatedFetch(options);
|
|
391
447
|
}
|
|
@@ -435,643 +491,20 @@ function unavailableCoreApiMethod(methodName) {
|
|
|
435
491
|
);
|
|
436
492
|
};
|
|
437
493
|
}
|
|
438
|
-
var UNAVAILABLE_CORE_API, DataSource;
|
|
439
|
-
var init_data_source = __esm({
|
|
440
|
-
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
441
|
-
"use strict";
|
|
442
|
-
init_merge_options();
|
|
443
|
-
init_file_aliases();
|
|
444
|
-
init_log();
|
|
445
|
-
init_request_credentials();
|
|
446
|
-
init_authentication();
|
|
447
|
-
UNAVAILABLE_CORE_API = {
|
|
448
|
-
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
449
|
-
parse: unavailableCoreApiMethod("parse"),
|
|
450
|
-
parseFile: unavailableCoreApiMethod("parseFile"),
|
|
451
|
-
parseSync: unavailableCoreApiMethod("parseSync"),
|
|
452
|
-
parseInBatches: unavailableCoreApiMethod("parseInBatches"),
|
|
453
|
-
load: unavailableCoreApiMethod("load"),
|
|
454
|
-
loadInBatches: unavailableCoreApiMethod("loadInBatches")
|
|
455
|
-
};
|
|
456
|
-
DataSource = class _DataSource {
|
|
457
|
-
static defaultOptions = {
|
|
458
|
-
core: {
|
|
459
|
-
type: "auto",
|
|
460
|
-
attributions: [],
|
|
461
|
-
loaders: [],
|
|
462
|
-
onError: void 0
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
optionsType;
|
|
466
|
-
options;
|
|
467
|
-
data;
|
|
468
|
-
url;
|
|
469
|
-
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
470
|
-
loadOptions;
|
|
471
|
-
/** A resolved fetch function extracted from the shared core options. */
|
|
472
|
-
fetch;
|
|
473
|
-
/** Shared source-level runtime hooks, when supplied by the source factory. */
|
|
474
|
-
coreApi;
|
|
475
|
-
/** Whether a real CoreAPI instance was injected by the integration layer. */
|
|
476
|
-
hasCoreApi;
|
|
477
|
-
_needsRefresh = true;
|
|
478
|
-
constructor(data, options, defaultOptions, coreApi) {
|
|
479
|
-
this.options = mergeOptions(
|
|
480
|
-
mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
|
|
481
|
-
options
|
|
482
|
-
);
|
|
483
|
-
this.data = data;
|
|
484
|
-
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
485
|
-
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
486
|
-
this.loadOptions = loadOptions;
|
|
487
|
-
const fetch2 = getFetchFunction(loadOptions);
|
|
488
|
-
this.coreApi = coreApi || UNAVAILABLE_CORE_API;
|
|
489
|
-
this.hasCoreApi = Boolean(coreApi);
|
|
490
|
-
this.fetch = fetch2;
|
|
491
|
-
}
|
|
492
|
-
setProps(options) {
|
|
493
|
-
const mergedOptions = mergeOptions(this.options, options);
|
|
494
|
-
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
495
|
-
this.options = mergedOptions;
|
|
496
|
-
this.loadOptions = loadOptions;
|
|
497
|
-
this.fetch = getFetchFunction(loadOptions);
|
|
498
|
-
this.setNeedsRefresh();
|
|
499
|
-
}
|
|
500
|
-
/** Mark this data source as needing a refresh (redraw) */
|
|
501
|
-
setNeedsRefresh() {
|
|
502
|
-
this._needsRefresh = true;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Does this data source need refreshing?
|
|
506
|
-
* @note The specifics of the refresh mechanism depends on type of data source
|
|
507
|
-
*/
|
|
508
|
-
getNeedsRefresh(clear = true) {
|
|
509
|
-
const needsRefresh = this._needsRefresh;
|
|
510
|
-
if (clear) {
|
|
511
|
-
this._needsRefresh = false;
|
|
512
|
-
}
|
|
513
|
-
return needsRefresh;
|
|
514
|
-
}
|
|
515
|
-
/** Reports a source-level failure through the configured callback or the shared logger. */
|
|
516
|
-
reportError(error, message) {
|
|
517
|
-
var _a;
|
|
518
|
-
const normalizedError = normalizeError(error, message);
|
|
519
|
-
const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
|
|
520
|
-
if (callback) {
|
|
521
|
-
callback(normalizedError, this);
|
|
522
|
-
} else {
|
|
523
|
-
log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
524
|
-
}
|
|
525
|
-
return normalizedError;
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
// ../core/src/loader-utils/index.ts
|
|
532
|
-
var init_loader_utils = __esm({
|
|
533
|
-
"../core/src/loader-utils/index.ts"() {
|
|
534
|
-
"use strict";
|
|
535
|
-
init_data_source();
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
// src/stac/stac-source-loader-types.ts
|
|
540
|
-
async function preloadSTACSourceLoader() {
|
|
541
|
-
const { STACSourceLoaderWithParser: STACSourceLoaderWithParser3 } = await Promise.resolve().then(() => (init_stac_source(), stac_source_exports));
|
|
542
|
-
return STACSourceLoaderWithParser3;
|
|
543
|
-
}
|
|
544
|
-
var VERSION2, STACSourceLoader;
|
|
545
|
-
var init_stac_source_loader_types = __esm({
|
|
546
|
-
"src/stac/stac-source-loader-types.ts"() {
|
|
547
|
-
"use strict";
|
|
548
|
-
VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
549
|
-
STACSourceLoader = {
|
|
550
|
-
dataType: null,
|
|
551
|
-
batchType: null,
|
|
552
|
-
name: "STACSourceLoader",
|
|
553
|
-
id: "stac-source",
|
|
554
|
-
module: "ogc",
|
|
555
|
-
version: VERSION2,
|
|
556
|
-
extensions: ["json"],
|
|
557
|
-
mimeTypes: ["application/json", "application/geo+json"],
|
|
558
|
-
type: "stac",
|
|
559
|
-
fromUrl: true,
|
|
560
|
-
fromBlob: false,
|
|
561
|
-
options: {
|
|
562
|
-
stac: {
|
|
563
|
-
maxDepth: 32,
|
|
564
|
-
maxRequests: 1e3
|
|
565
|
-
}
|
|
566
|
-
},
|
|
567
|
-
defaultOptions: {
|
|
568
|
-
stac: {
|
|
569
|
-
maxDepth: 32,
|
|
570
|
-
maxRequests: 1e3
|
|
571
|
-
}
|
|
572
|
-
},
|
|
573
|
-
testURL: (url) => /(?:^|[/_.-])stac(?:[/_.?#-]|$)|\/(?:catalog|collection)\.json(?:$|[?#])/i.test(url),
|
|
574
|
-
preload: preloadSTACSourceLoader,
|
|
575
|
-
createDataSource(_data, _options, _coreApi) {
|
|
576
|
-
throw new Error(
|
|
577
|
-
"STACSourceLoader requires async load() or an explicit @loaders.gl/ogc/stac/stac-source import"
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
// src/stac/stac-source.ts
|
|
585
|
-
var stac_source_exports = {};
|
|
586
|
-
__export(stac_source_exports, {
|
|
587
|
-
STACSource: () => STACSource,
|
|
588
|
-
STACSourceLoader: () => STACSourceLoaderWithParser,
|
|
589
|
-
STACSourceLoaderWithParser: () => STACSourceLoaderWithParser
|
|
590
|
-
});
|
|
591
|
-
function createSearchRequest(link, baseUrl, query) {
|
|
592
|
-
const { signal: _signal, ...body } = query;
|
|
593
|
-
return {
|
|
594
|
-
url: resolveUrl(link.href, baseUrl),
|
|
595
|
-
method: link.method || "POST",
|
|
596
|
-
headers: link.headers,
|
|
597
|
-
body
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
function createNextRequest(link, baseUrl, previousRequest) {
|
|
601
|
-
const linkBody = link.body || {};
|
|
602
|
-
return {
|
|
603
|
-
url: resolveUrl(link.href, baseUrl),
|
|
604
|
-
method: link.method || previousRequest.method,
|
|
605
|
-
headers: { ...previousRequest.headers, ...link.headers },
|
|
606
|
-
body: link.merge ? { ...previousRequest.body, ...linkBody } : link.body
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function getRequestKey(request) {
|
|
610
|
-
return `${request.method} ${request.url} ${JSON.stringify(request.body || {})}`;
|
|
611
|
-
}
|
|
612
|
-
function appendQuery(url, body) {
|
|
613
|
-
const parsedUrl = new URL(url);
|
|
614
|
-
for (const [key, value] of Object.entries(body)) {
|
|
615
|
-
if (value !== void 0) {
|
|
616
|
-
parsedUrl.searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
return parsedUrl.href;
|
|
620
|
-
}
|
|
621
|
-
function resolveUrl(url, baseUrl) {
|
|
622
|
-
return new URL(url, baseUrl).href;
|
|
623
|
-
}
|
|
624
|
-
function findLink(links, relation) {
|
|
625
|
-
return links.find((link) => link.rel === relation);
|
|
626
|
-
}
|
|
627
|
-
function assertResponse(response, url) {
|
|
628
|
-
if (!response.ok) {
|
|
629
|
-
throw new Error(`STAC request failed (${response.status} ${response.statusText}): ${url}`);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
function validateTraversalLimit(name, value) {
|
|
633
|
-
if (!Number.isSafeInteger(value) || value < 1) {
|
|
634
|
-
throw new Error(`STAC ${name} must be a positive integer`);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
function throwIfAborted(signal) {
|
|
638
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
639
|
-
throw signal.reason || new DOMException("The operation was aborted", "AbortError");
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
function waitForPromiseWithSignal(promise, signal) {
|
|
643
|
-
if (!signal) {
|
|
644
|
-
return promise;
|
|
645
|
-
}
|
|
646
|
-
throwIfAborted(signal);
|
|
647
|
-
return new Promise((resolve, reject) => {
|
|
648
|
-
const handleAbort = () => reject(signal.reason || new DOMException("The operation was aborted", "AbortError"));
|
|
649
|
-
signal.addEventListener("abort", handleAbort, { once: true });
|
|
650
|
-
void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", handleAbort));
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
function validateObject(value, url) {
|
|
654
|
-
if (!isRecord(value)) {
|
|
655
|
-
throw new Error(`Invalid STAC JSON document: ${url}`);
|
|
656
|
-
}
|
|
657
|
-
if (value.type === "Catalog" || value.type === "Collection") {
|
|
658
|
-
if (typeof value.id !== "string" || !Array.isArray(value.links)) {
|
|
659
|
-
throw new Error(`Invalid STAC Catalog or Collection: ${url}`);
|
|
660
|
-
}
|
|
661
|
-
return value;
|
|
662
|
-
}
|
|
663
|
-
if (value.type === "Feature") {
|
|
664
|
-
if (typeof value.id !== "string" || !isRecord(value.assets) || !Array.isArray(value.links)) {
|
|
665
|
-
throw new Error(`Invalid STAC Item: ${url}`);
|
|
666
|
-
}
|
|
667
|
-
return value;
|
|
668
|
-
}
|
|
669
|
-
if (value.type === "FeatureCollection") {
|
|
670
|
-
return validateItemCollection(value, url);
|
|
671
|
-
}
|
|
672
|
-
throw new Error(`Unsupported STAC object type at ${url}`);
|
|
673
|
-
}
|
|
674
|
-
function validateItemCollection(value, url) {
|
|
675
|
-
if (!isRecord(value) || value.type !== "FeatureCollection" || !Array.isArray(value.features) || !Array.isArray(value.links)) {
|
|
676
|
-
throw new Error(`Invalid STAC ItemCollection: ${url}`);
|
|
677
|
-
}
|
|
678
|
-
for (const item of value.features) {
|
|
679
|
-
if (!isItem(item)) {
|
|
680
|
-
throw new Error(`Invalid STAC Item in ItemCollection: ${url}`);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return value;
|
|
684
|
-
}
|
|
685
|
-
function validateCollections(value, url) {
|
|
686
|
-
if (!isRecord(value) || !Array.isArray(value.collections) || !Array.isArray(value.links)) {
|
|
687
|
-
throw new Error(`Invalid STAC Collections response: ${url}`);
|
|
688
|
-
}
|
|
689
|
-
if (!value.collections.every(isCollection)) {
|
|
690
|
-
throw new Error(`Invalid Collection in STAC Collections response: ${url}`);
|
|
691
|
-
}
|
|
692
|
-
return value;
|
|
693
|
-
}
|
|
694
|
-
function isCatalog(value) {
|
|
695
|
-
return isRecord(value) && value.type === "Catalog" && Array.isArray(value.links);
|
|
696
|
-
}
|
|
697
|
-
function isCollection(value) {
|
|
698
|
-
return isRecord(value) && value.type === "Collection" && Array.isArray(value.links);
|
|
699
|
-
}
|
|
700
|
-
function isItem(value) {
|
|
701
|
-
return isRecord(value) && value.type === "Feature" && typeof value.id === "string" && isRecord(value.assets) && Array.isArray(value.links);
|
|
702
|
-
}
|
|
703
|
-
function isItemCollection(value) {
|
|
704
|
-
return isRecord(value) && value.type === "FeatureCollection" && Array.isArray(value.features) && Array.isArray(value.links);
|
|
705
|
-
}
|
|
706
|
-
function isRecord(value) {
|
|
707
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
708
|
-
}
|
|
709
|
-
function matchesItem(item, query) {
|
|
710
|
-
if (query.ids && !query.ids.includes(item.id)) {
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
713
|
-
if (query.collections && (!item.collection || !query.collections.includes(item.collection))) {
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
if (query.bbox && item.bbox && !intersectsBoundingBox(query.bbox, item.bbox)) {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
return !query.datetime || intersectsDatetime(query.datetime, item);
|
|
720
|
-
}
|
|
721
|
-
function intersectsBoundingBox(left, right) {
|
|
722
|
-
const leftMaximumX = left.length === 6 ? left[3] : left[2];
|
|
723
|
-
const leftMaximumY = left.length === 6 ? left[4] : left[3];
|
|
724
|
-
const rightMaximumX = right.length === 6 ? right[3] : right[2];
|
|
725
|
-
const rightMaximumY = right.length === 6 ? right[4] : right[3];
|
|
726
|
-
return !(leftMaximumX < right[0] || rightMaximumX < left[0] || leftMaximumY < right[1] || rightMaximumY < left[1]);
|
|
727
|
-
}
|
|
728
|
-
function intersectsDatetime(datetime, item) {
|
|
729
|
-
const queryInterval = parseDatetimeInterval(datetime, true);
|
|
730
|
-
const itemDatetime = item.properties.datetime;
|
|
731
|
-
const itemInterval = typeof itemDatetime === "string" ? parseDatetimeInterval(itemDatetime, false) : parseItemDatetimeInterval(item);
|
|
732
|
-
if (!itemInterval) {
|
|
733
|
-
return true;
|
|
734
|
-
}
|
|
735
|
-
return queryInterval[0] <= itemInterval[1] && itemInterval[0] <= queryInterval[1];
|
|
736
|
-
}
|
|
737
|
-
function parseDatetimeInterval(datetime, throwOnInvalid) {
|
|
738
|
-
const parts = datetime.split("/");
|
|
739
|
-
const start = parts[0] === ".." ? Number.NEGATIVE_INFINITY : Date.parse(parts[0]);
|
|
740
|
-
const endPart = parts.length > 1 ? parts[1] : parts[0];
|
|
741
|
-
const end = endPart === ".." ? Number.POSITIVE_INFINITY : Date.parse(endPart);
|
|
742
|
-
if (parts.length > 2 || Number.isNaN(start) || Number.isNaN(end) || start > end) {
|
|
743
|
-
if (throwOnInvalid) {
|
|
744
|
-
throw new Error(`Invalid STAC datetime: ${datetime}`);
|
|
745
|
-
}
|
|
746
|
-
return [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY];
|
|
747
|
-
}
|
|
748
|
-
return [start, end];
|
|
749
|
-
}
|
|
750
|
-
function parseItemDatetimeInterval(item) {
|
|
751
|
-
const start = item.properties.start_datetime;
|
|
752
|
-
const end = item.properties.end_datetime;
|
|
753
|
-
if (!start || !end) {
|
|
754
|
-
return null;
|
|
755
|
-
}
|
|
756
|
-
return parseDatetimeInterval(`${start}/${end}`, false);
|
|
757
|
-
}
|
|
758
|
-
var DEFAULT_MAX_DEPTH, DEFAULT_MAX_REQUESTS, _preloadSTACSourceLoader, _createMetadataDataSource, STACSourceLoaderBase, STACSourceLoaderWithParser, STACSource;
|
|
759
|
-
var init_stac_source = __esm({
|
|
760
|
-
"src/stac/stac-source.ts"() {
|
|
761
|
-
"use strict";
|
|
762
|
-
init_loader_utils();
|
|
763
|
-
init_stac_source_loader_types();
|
|
764
|
-
DEFAULT_MAX_DEPTH = 32;
|
|
765
|
-
DEFAULT_MAX_REQUESTS = 1e3;
|
|
766
|
-
({
|
|
767
|
-
preload: _preloadSTACSourceLoader,
|
|
768
|
-
createDataSource: _createMetadataDataSource,
|
|
769
|
-
...STACSourceLoaderBase
|
|
770
|
-
} = STACSourceLoader);
|
|
771
|
-
STACSourceLoaderWithParser = {
|
|
772
|
-
...STACSourceLoaderBase,
|
|
773
|
-
createDataSource(data, options, coreApi) {
|
|
774
|
-
if (typeof data !== "string") {
|
|
775
|
-
throw new Error("STACSource requires a catalog URL");
|
|
776
|
-
}
|
|
777
|
-
return new STACSource(data, options, coreApi);
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
STACSource = class extends DataSource {
|
|
781
|
-
/** Features exposed through the protocol-neutral catalog interface. */
|
|
782
|
-
capabilities = Object.freeze({
|
|
783
|
-
search: true,
|
|
784
|
-
pagination: true,
|
|
785
|
-
hierarchy: true,
|
|
786
|
-
spatialFilter: true,
|
|
787
|
-
temporalFilter: true,
|
|
788
|
-
textFilter: false,
|
|
789
|
-
cql2Filter: false,
|
|
790
|
-
collections: true,
|
|
791
|
-
assets: true
|
|
792
|
-
});
|
|
793
|
-
/** Cached root initialization shared by metadata and query methods. */
|
|
794
|
-
rootPromise = null;
|
|
795
|
-
/** Source document URL retained for resolving relative links and assets. */
|
|
796
|
-
documentUrls = /* @__PURE__ */ new WeakMap();
|
|
797
|
-
/** Creates a source for a static STAC root or STAC API landing page. */
|
|
798
|
-
constructor(url, options, coreApi) {
|
|
799
|
-
super(url, options, STACSourceLoaderWithParser.defaultOptions, coreApi);
|
|
800
|
-
}
|
|
801
|
-
/** Returns the cached root Catalog or Collection. */
|
|
802
|
-
async getRoot(options = {}) {
|
|
803
|
-
throwIfAborted(options.signal);
|
|
804
|
-
if (!this.rootPromise) {
|
|
805
|
-
const rootPromise = this.fetchObject(this.url).then((object) => {
|
|
806
|
-
if (!isCatalog(object) && !isCollection(object)) {
|
|
807
|
-
throw new Error(`STAC root must be a Catalog or Collection: ${this.url}`);
|
|
808
|
-
}
|
|
809
|
-
return object;
|
|
810
|
-
});
|
|
811
|
-
this.rootPromise = rootPromise;
|
|
812
|
-
void rootPromise.catch(() => {
|
|
813
|
-
if (this.rootPromise === rootPromise) {
|
|
814
|
-
this.rootPromise = null;
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
return await waitForPromiseWithSignal(this.rootPromise, options.signal);
|
|
819
|
-
}
|
|
820
|
-
/** Returns root metadata and whether a STAC API search relation was discovered. */
|
|
821
|
-
async getMetadata(options = {}) {
|
|
822
|
-
const root = await this.getRoot(options);
|
|
823
|
-
const conformsTo = Array.isArray(root.conformsTo) ? root.conformsTo : [];
|
|
824
|
-
return {
|
|
825
|
-
root,
|
|
826
|
-
mode: findLink(root.links, "search") || conformsTo.length > 0 ? "api" : "static",
|
|
827
|
-
conformsTo
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Lists collections from an API Collections endpoint or a static catalog hierarchy.
|
|
832
|
-
* Static traversal follows `child` links but never fetches Item links.
|
|
833
|
-
*/
|
|
834
|
-
async getCollections(options = {}) {
|
|
835
|
-
const metadata = await this.getMetadata({ signal: options.signal });
|
|
836
|
-
if (metadata.mode === "api") {
|
|
837
|
-
return await this.getAPICollections(metadata.root, options.signal);
|
|
838
|
-
}
|
|
839
|
-
return await this.getStaticCollections(metadata.root, options);
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Searches a STAC API and follows `next` links until all result pages are consumed.
|
|
843
|
-
* Throws for static catalogs; use `traverse()` to opt into client-side crawling.
|
|
844
|
-
*/
|
|
845
|
-
async *search(query = {}) {
|
|
846
|
-
const root = await this.getRoot({ signal: query.signal });
|
|
847
|
-
const searchLink = findLink(root.links, "search");
|
|
848
|
-
if (!searchLink) {
|
|
849
|
-
throw new Error("This is a static STAC catalog; use STACSource.traverse() explicitly");
|
|
850
|
-
}
|
|
851
|
-
let request = createSearchRequest(
|
|
852
|
-
searchLink,
|
|
853
|
-
this.getDocumentUrl(root),
|
|
854
|
-
query
|
|
855
|
-
);
|
|
856
|
-
const visitedRequests = /* @__PURE__ */ new Set();
|
|
857
|
-
while (request) {
|
|
858
|
-
throwIfAborted(query.signal);
|
|
859
|
-
const requestKey = getRequestKey(request);
|
|
860
|
-
if (visitedRequests.has(requestKey)) {
|
|
861
|
-
throw new Error(`STAC pagination cycle detected at ${request.url}`);
|
|
862
|
-
}
|
|
863
|
-
visitedRequests.add(requestKey);
|
|
864
|
-
const page = await this.fetchItemCollection(request, query.signal);
|
|
865
|
-
for (const item of page.features) {
|
|
866
|
-
yield item;
|
|
867
|
-
}
|
|
868
|
-
const nextLink = findLink(page.links, "next");
|
|
869
|
-
request = nextLink ? createNextRequest(nextLink, this.getDocumentUrl(page), request) : null;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Explicitly traverses a static STAC link graph with cycle, depth, and request limits.
|
|
874
|
-
* Optional standard Item Search constraints are evaluated locally.
|
|
875
|
-
*/
|
|
876
|
-
async *traverse(options = {}) {
|
|
877
|
-
var _a, _b;
|
|
878
|
-
const root = await this.getRoot({ signal: options.signal });
|
|
879
|
-
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
|
|
880
|
-
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
|
|
881
|
-
validateTraversalLimit("maxDepth", maxDepth);
|
|
882
|
-
validateTraversalLimit("maxRequests", maxRequests);
|
|
883
|
-
const rootUrl = this.getDocumentUrl(root);
|
|
884
|
-
const queue = [{ url: rootUrl, depth: 0 }];
|
|
885
|
-
const visitedUrls = /* @__PURE__ */ new Set();
|
|
886
|
-
let requestCount = 0;
|
|
887
|
-
while (queue.length > 0) {
|
|
888
|
-
throwIfAborted(options.signal);
|
|
889
|
-
const entry = queue.shift();
|
|
890
|
-
if (visitedUrls.has(entry.url)) {
|
|
891
|
-
continue;
|
|
892
|
-
}
|
|
893
|
-
if (requestCount >= maxRequests) {
|
|
894
|
-
throw new Error(`STAC traversal exceeded maxRequests (${maxRequests})`);
|
|
895
|
-
}
|
|
896
|
-
visitedUrls.add(entry.url);
|
|
897
|
-
requestCount++;
|
|
898
|
-
const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
|
|
899
|
-
if (isItem(object)) {
|
|
900
|
-
if (matchesItem(object, options)) {
|
|
901
|
-
yield object;
|
|
902
|
-
}
|
|
903
|
-
continue;
|
|
904
|
-
}
|
|
905
|
-
if (isItemCollection(object)) {
|
|
906
|
-
for (const item of object.features) {
|
|
907
|
-
if (matchesItem(item, options)) {
|
|
908
|
-
yield item;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
for (const link of object.links) {
|
|
913
|
-
if (link.rel !== "child" && link.rel !== "item") {
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
const depth = link.rel === "child" ? entry.depth + 1 : entry.depth;
|
|
917
|
-
if (depth <= maxDepth) {
|
|
918
|
-
queue.push({ url: resolveUrl(link.href, this.getDocumentUrl(object)), depth });
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
/** Returns matching Item assets with document-relative URLs resolved to absolute URLs. */
|
|
924
|
-
getAssets(item, selection = {}) {
|
|
925
|
-
const baseUrl = this.documentUrls.get(item) || this.url;
|
|
926
|
-
const requiredRoles = new Set(selection.roles || []);
|
|
927
|
-
const requiredMediaTypes = new Set(selection.mediaTypes || []);
|
|
928
|
-
return Object.entries(item.assets).filter(([, asset]) => {
|
|
929
|
-
var _a;
|
|
930
|
-
const matchesRole = requiredRoles.size === 0 || ((_a = asset.roles) == null ? void 0 : _a.some((role) => requiredRoles.has(role)));
|
|
931
|
-
const matchesMediaType = requiredMediaTypes.size === 0 || Boolean(asset.type && requiredMediaTypes.has(asset.type));
|
|
932
|
-
return matchesRole && matchesMediaType;
|
|
933
|
-
}).map(([key, asset]) => ({ ...asset, key, href: resolveUrl(asset.href, baseUrl) }));
|
|
934
|
-
}
|
|
935
|
-
/** Fetches every page from a STAC API Collections relation. */
|
|
936
|
-
async getAPICollections(root, signal) {
|
|
937
|
-
const collectionsLink = findLink(root.links, "data") || findLink(root.links, "collections");
|
|
938
|
-
if (!collectionsLink) {
|
|
939
|
-
return isCollection(root) ? [root] : [];
|
|
940
|
-
}
|
|
941
|
-
const collections = [];
|
|
942
|
-
const visitedUrls = /* @__PURE__ */ new Set();
|
|
943
|
-
let url = resolveUrl(collectionsLink.href, this.getDocumentUrl(root));
|
|
944
|
-
while (url) {
|
|
945
|
-
throwIfAborted(signal);
|
|
946
|
-
if (visitedUrls.has(url)) {
|
|
947
|
-
throw new Error(`STAC Collections pagination cycle detected at ${url}`);
|
|
948
|
-
}
|
|
949
|
-
visitedUrls.add(url);
|
|
950
|
-
const response = await this.fetch(url, { signal });
|
|
951
|
-
assertResponse(response, url);
|
|
952
|
-
const page = validateCollections(await response.json(), url);
|
|
953
|
-
this.attachDocumentUrl(page, url);
|
|
954
|
-
for (const collection of page.collections) {
|
|
955
|
-
this.attachDocumentUrl(collection, url);
|
|
956
|
-
}
|
|
957
|
-
collections.push(...page.collections);
|
|
958
|
-
const nextLink = findLink(page.links, "next");
|
|
959
|
-
url = nextLink ? resolveUrl(nextLink.href, url) : null;
|
|
960
|
-
}
|
|
961
|
-
return collections;
|
|
962
|
-
}
|
|
963
|
-
/** Traverses only static `child` links to collect Collection documents. */
|
|
964
|
-
async getStaticCollections(root, options) {
|
|
965
|
-
var _a, _b;
|
|
966
|
-
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
|
|
967
|
-
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
|
|
968
|
-
validateTraversalLimit("maxDepth", maxDepth);
|
|
969
|
-
validateTraversalLimit("maxRequests", maxRequests);
|
|
970
|
-
const rootUrl = this.getDocumentUrl(root);
|
|
971
|
-
const queue = [{ url: rootUrl, depth: 0 }];
|
|
972
|
-
const visitedUrls = /* @__PURE__ */ new Set();
|
|
973
|
-
const collections = [];
|
|
974
|
-
let requestCount = 0;
|
|
975
|
-
while (queue.length > 0) {
|
|
976
|
-
throwIfAborted(options.signal);
|
|
977
|
-
const entry = queue.shift();
|
|
978
|
-
if (visitedUrls.has(entry.url)) {
|
|
979
|
-
continue;
|
|
980
|
-
}
|
|
981
|
-
if (requestCount >= maxRequests) {
|
|
982
|
-
throw new Error(`STAC collection traversal exceeded maxRequests (${maxRequests})`);
|
|
983
|
-
}
|
|
984
|
-
visitedUrls.add(entry.url);
|
|
985
|
-
requestCount++;
|
|
986
|
-
const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
|
|
987
|
-
if (isCollection(object)) {
|
|
988
|
-
collections.push(object);
|
|
989
|
-
}
|
|
990
|
-
if (!isCatalog(object) && !isCollection(object)) {
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
if (entry.depth < maxDepth) {
|
|
994
|
-
for (const link of object.links) {
|
|
995
|
-
if (link.rel === "child") {
|
|
996
|
-
queue.push({
|
|
997
|
-
url: resolveUrl(link.href, this.getDocumentUrl(object)),
|
|
998
|
-
depth: entry.depth + 1
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return collections;
|
|
1005
|
-
}
|
|
1006
|
-
/** Fetches and validates one core STAC document. */
|
|
1007
|
-
async fetchObject(url, signal) {
|
|
1008
|
-
throwIfAborted(signal);
|
|
1009
|
-
const response = await this.fetch(url, { signal });
|
|
1010
|
-
assertResponse(response, url);
|
|
1011
|
-
const object = validateObject(await response.json(), url);
|
|
1012
|
-
this.attachDocumentUrl(object, url);
|
|
1013
|
-
if (isItemCollection(object)) {
|
|
1014
|
-
for (const item of object.features) {
|
|
1015
|
-
this.attachDocumentUrl(item, url);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
return object;
|
|
1019
|
-
}
|
|
1020
|
-
/** Executes one STAC API Item Search page request. */
|
|
1021
|
-
async fetchItemCollection(request, signal) {
|
|
1022
|
-
const headers = new Headers(request.headers);
|
|
1023
|
-
let url = request.url;
|
|
1024
|
-
let body;
|
|
1025
|
-
if (request.method === "POST") {
|
|
1026
|
-
headers.set("content-type", "application/json");
|
|
1027
|
-
body = JSON.stringify(request.body || {});
|
|
1028
|
-
} else if (request.body && Object.keys(request.body).length > 0) {
|
|
1029
|
-
url = appendQuery(url, request.body);
|
|
1030
|
-
}
|
|
1031
|
-
const response = await this.fetch(url, { method: request.method, headers, body, signal });
|
|
1032
|
-
assertResponse(response, url);
|
|
1033
|
-
const page = validateItemCollection(await response.json(), url);
|
|
1034
|
-
this.attachDocumentUrl(page, url);
|
|
1035
|
-
for (const item of page.features) {
|
|
1036
|
-
this.attachDocumentUrl(item, url);
|
|
1037
|
-
}
|
|
1038
|
-
return page;
|
|
1039
|
-
}
|
|
1040
|
-
/** Associates an object and its nested links with the fetched document URL. */
|
|
1041
|
-
attachDocumentUrl(object, url) {
|
|
1042
|
-
this.documentUrls.set(object, url);
|
|
1043
|
-
}
|
|
1044
|
-
/** Returns the URL from which a STAC object was fetched. */
|
|
1045
|
-
getDocumentUrl(object) {
|
|
1046
|
-
return this.documentUrls.get(object) || this.url;
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
});
|
|
1051
|
-
|
|
1052
|
-
// dist/stac/stac-source.js
|
|
1053
|
-
var stac_source_exports2 = {};
|
|
1054
|
-
__export(stac_source_exports2, {
|
|
1055
|
-
STACSource: () => STACSource2,
|
|
1056
|
-
STACSourceLoader: () => STACSourceLoaderWithParser2,
|
|
1057
|
-
STACSourceLoaderWithParser: () => STACSourceLoaderWithParser2
|
|
1058
|
-
});
|
|
1059
|
-
module.exports = __toCommonJS(stac_source_exports2);
|
|
1060
|
-
init_loader_utils();
|
|
1061
494
|
|
|
1062
495
|
// dist/stac/stac-source-loader-types.js
|
|
1063
|
-
var
|
|
1064
|
-
async function
|
|
1065
|
-
const { STACSourceLoaderWithParser:
|
|
1066
|
-
return
|
|
496
|
+
var VERSION2 = true ? "5.0.0-beta.2" : "latest";
|
|
497
|
+
async function preloadSTACSourceLoader() {
|
|
498
|
+
const { STACSourceLoaderWithParser: STACSourceLoaderWithParser2 } = await import("@loaders.gl/ogc/stac-source");
|
|
499
|
+
return STACSourceLoaderWithParser2;
|
|
1067
500
|
}
|
|
1068
|
-
var
|
|
501
|
+
var STACSourceLoader = {
|
|
1069
502
|
dataType: null,
|
|
1070
503
|
batchType: null,
|
|
1071
504
|
name: "STACSourceLoader",
|
|
1072
505
|
id: "stac-source",
|
|
1073
506
|
module: "ogc",
|
|
1074
|
-
version:
|
|
507
|
+
version: VERSION2,
|
|
1075
508
|
extensions: ["json"],
|
|
1076
509
|
mimeTypes: ["application/json", "application/geo+json"],
|
|
1077
510
|
type: "stac",
|
|
@@ -1090,26 +523,26 @@ var STACSourceLoader2 = {
|
|
|
1090
523
|
}
|
|
1091
524
|
},
|
|
1092
525
|
testURL: (url) => /(?:^|[/_.-])stac(?:[/_.?#-]|$)|\/(?:catalog|collection)\.json(?:$|[?#])/i.test(url),
|
|
1093
|
-
preload:
|
|
526
|
+
preload: preloadSTACSourceLoader,
|
|
1094
527
|
createDataSource(_data, _options, _coreApi) {
|
|
1095
|
-
throw new Error("STACSourceLoader requires async load() or an explicit @loaders.gl/ogc/stac
|
|
528
|
+
throw new Error("STACSourceLoader requires async load() or an explicit @loaders.gl/ogc/stac-source import");
|
|
1096
529
|
}
|
|
1097
530
|
};
|
|
1098
531
|
|
|
1099
532
|
// dist/stac/stac-source.js
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1102
|
-
var { preload:
|
|
1103
|
-
var
|
|
1104
|
-
...
|
|
533
|
+
var DEFAULT_MAX_DEPTH = 32;
|
|
534
|
+
var DEFAULT_MAX_REQUESTS = 1e3;
|
|
535
|
+
var { preload: _preloadSTACSourceLoader, createDataSource: _createMetadataDataSource, ...STACSourceLoaderBase } = STACSourceLoader;
|
|
536
|
+
var STACSourceLoaderWithParser = {
|
|
537
|
+
...STACSourceLoaderBase,
|
|
1105
538
|
createDataSource(data, options, coreApi) {
|
|
1106
539
|
if (typeof data !== "string") {
|
|
1107
540
|
throw new Error("STACSource requires a catalog URL");
|
|
1108
541
|
}
|
|
1109
|
-
return new
|
|
542
|
+
return new STACSource(data, options, coreApi);
|
|
1110
543
|
}
|
|
1111
544
|
};
|
|
1112
|
-
var
|
|
545
|
+
var STACSource = class extends DataSource {
|
|
1113
546
|
/** Features exposed through the protocol-neutral catalog interface. */
|
|
1114
547
|
capabilities = Object.freeze({
|
|
1115
548
|
search: true,
|
|
@@ -1128,14 +561,14 @@ var STACSource2 = class extends DataSource {
|
|
|
1128
561
|
documentUrls = /* @__PURE__ */ new WeakMap();
|
|
1129
562
|
/** Creates a source for a static STAC root or STAC API landing page. */
|
|
1130
563
|
constructor(url, options, coreApi) {
|
|
1131
|
-
super(url, options,
|
|
564
|
+
super(url, options, STACSourceLoaderWithParser.defaultOptions, coreApi);
|
|
1132
565
|
}
|
|
1133
566
|
/** Returns the cached root Catalog or Collection. */
|
|
1134
567
|
async getRoot(options = {}) {
|
|
1135
|
-
|
|
568
|
+
throwIfAborted(options.signal);
|
|
1136
569
|
if (!this.rootPromise) {
|
|
1137
570
|
const rootPromise = this.fetchObject(this.url).then((object) => {
|
|
1138
|
-
if (!
|
|
571
|
+
if (!isCatalog(object) && !isCollection(object)) {
|
|
1139
572
|
throw new Error(`STAC root must be a Catalog or Collection: ${this.url}`);
|
|
1140
573
|
}
|
|
1141
574
|
return object;
|
|
@@ -1147,7 +580,7 @@ var STACSource2 = class extends DataSource {
|
|
|
1147
580
|
}
|
|
1148
581
|
});
|
|
1149
582
|
}
|
|
1150
|
-
return await
|
|
583
|
+
return await waitForPromiseWithSignal(this.rootPromise, options.signal);
|
|
1151
584
|
}
|
|
1152
585
|
/** Returns root metadata and whether a STAC API search relation was discovered. */
|
|
1153
586
|
async getMetadata(options = {}) {
|
|
@@ -1155,7 +588,7 @@ var STACSource2 = class extends DataSource {
|
|
|
1155
588
|
const conformsTo = Array.isArray(root.conformsTo) ? root.conformsTo : [];
|
|
1156
589
|
return {
|
|
1157
590
|
root,
|
|
1158
|
-
mode:
|
|
591
|
+
mode: findLink(root.links, "search") || conformsTo.length > 0 ? "api" : "static",
|
|
1159
592
|
conformsTo
|
|
1160
593
|
};
|
|
1161
594
|
}
|
|
@@ -1176,15 +609,15 @@ var STACSource2 = class extends DataSource {
|
|
|
1176
609
|
*/
|
|
1177
610
|
async *search(query = {}) {
|
|
1178
611
|
const root = await this.getRoot({ signal: query.signal });
|
|
1179
|
-
const searchLink =
|
|
612
|
+
const searchLink = findLink(root.links, "search");
|
|
1180
613
|
if (!searchLink) {
|
|
1181
614
|
throw new Error("This is a static STAC catalog; use STACSource.traverse() explicitly");
|
|
1182
615
|
}
|
|
1183
|
-
let request =
|
|
616
|
+
let request = createSearchRequest(searchLink, this.getDocumentUrl(root), query);
|
|
1184
617
|
const visitedRequests = /* @__PURE__ */ new Set();
|
|
1185
618
|
while (request) {
|
|
1186
|
-
|
|
1187
|
-
const requestKey =
|
|
619
|
+
throwIfAborted(query.signal);
|
|
620
|
+
const requestKey = getRequestKey(request);
|
|
1188
621
|
if (visitedRequests.has(requestKey)) {
|
|
1189
622
|
throw new Error(`STAC pagination cycle detected at ${request.url}`);
|
|
1190
623
|
}
|
|
@@ -1193,8 +626,8 @@ var STACSource2 = class extends DataSource {
|
|
|
1193
626
|
for (const item of page.features) {
|
|
1194
627
|
yield item;
|
|
1195
628
|
}
|
|
1196
|
-
const nextLink =
|
|
1197
|
-
request = nextLink ?
|
|
629
|
+
const nextLink = findLink(page.links, "next");
|
|
630
|
+
request = nextLink ? createNextRequest(nextLink, this.getDocumentUrl(page), request) : null;
|
|
1198
631
|
}
|
|
1199
632
|
}
|
|
1200
633
|
/**
|
|
@@ -1204,16 +637,16 @@ var STACSource2 = class extends DataSource {
|
|
|
1204
637
|
async *traverse(options = {}) {
|
|
1205
638
|
var _a, _b;
|
|
1206
639
|
const root = await this.getRoot({ signal: options.signal });
|
|
1207
|
-
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ??
|
|
1208
|
-
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ??
|
|
1209
|
-
|
|
1210
|
-
|
|
640
|
+
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
|
|
641
|
+
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
|
|
642
|
+
validateTraversalLimit("maxDepth", maxDepth);
|
|
643
|
+
validateTraversalLimit("maxRequests", maxRequests);
|
|
1211
644
|
const rootUrl = this.getDocumentUrl(root);
|
|
1212
645
|
const queue = [{ url: rootUrl, depth: 0 }];
|
|
1213
646
|
const visitedUrls = /* @__PURE__ */ new Set();
|
|
1214
647
|
let requestCount = 0;
|
|
1215
648
|
while (queue.length > 0) {
|
|
1216
|
-
|
|
649
|
+
throwIfAborted(options.signal);
|
|
1217
650
|
const entry = queue.shift();
|
|
1218
651
|
if (visitedUrls.has(entry.url)) {
|
|
1219
652
|
continue;
|
|
@@ -1224,15 +657,15 @@ var STACSource2 = class extends DataSource {
|
|
|
1224
657
|
visitedUrls.add(entry.url);
|
|
1225
658
|
requestCount++;
|
|
1226
659
|
const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
|
|
1227
|
-
if (
|
|
1228
|
-
if (
|
|
660
|
+
if (isItem(object)) {
|
|
661
|
+
if (matchesItem(object, options)) {
|
|
1229
662
|
yield object;
|
|
1230
663
|
}
|
|
1231
664
|
continue;
|
|
1232
665
|
}
|
|
1233
|
-
if (
|
|
666
|
+
if (isItemCollection(object)) {
|
|
1234
667
|
for (const item of object.features) {
|
|
1235
|
-
if (
|
|
668
|
+
if (matchesItem(item, options)) {
|
|
1236
669
|
yield item;
|
|
1237
670
|
}
|
|
1238
671
|
}
|
|
@@ -1243,7 +676,7 @@ var STACSource2 = class extends DataSource {
|
|
|
1243
676
|
}
|
|
1244
677
|
const depth = link.rel === "child" ? entry.depth + 1 : entry.depth;
|
|
1245
678
|
if (depth <= maxDepth) {
|
|
1246
|
-
queue.push({ url:
|
|
679
|
+
queue.push({ url: resolveUrl(link.href, this.getDocumentUrl(object)), depth });
|
|
1247
680
|
}
|
|
1248
681
|
}
|
|
1249
682
|
}
|
|
@@ -1258,50 +691,50 @@ var STACSource2 = class extends DataSource {
|
|
|
1258
691
|
const matchesRole = requiredRoles.size === 0 || ((_a = asset.roles) == null ? void 0 : _a.some((role) => requiredRoles.has(role)));
|
|
1259
692
|
const matchesMediaType = requiredMediaTypes.size === 0 || Boolean(asset.type && requiredMediaTypes.has(asset.type));
|
|
1260
693
|
return matchesRole && matchesMediaType;
|
|
1261
|
-
}).map(([key, asset]) => ({ ...asset, key, href:
|
|
694
|
+
}).map(([key, asset]) => ({ ...asset, key, href: resolveUrl(asset.href, baseUrl) }));
|
|
1262
695
|
}
|
|
1263
696
|
/** Fetches every page from a STAC API Collections relation. */
|
|
1264
697
|
async getAPICollections(root, signal) {
|
|
1265
|
-
const collectionsLink =
|
|
698
|
+
const collectionsLink = findLink(root.links, "data") || findLink(root.links, "collections");
|
|
1266
699
|
if (!collectionsLink) {
|
|
1267
|
-
return
|
|
700
|
+
return isCollection(root) ? [root] : [];
|
|
1268
701
|
}
|
|
1269
702
|
const collections = [];
|
|
1270
703
|
const visitedUrls = /* @__PURE__ */ new Set();
|
|
1271
|
-
let url =
|
|
704
|
+
let url = resolveUrl(collectionsLink.href, this.getDocumentUrl(root));
|
|
1272
705
|
while (url) {
|
|
1273
|
-
|
|
706
|
+
throwIfAborted(signal);
|
|
1274
707
|
if (visitedUrls.has(url)) {
|
|
1275
708
|
throw new Error(`STAC Collections pagination cycle detected at ${url}`);
|
|
1276
709
|
}
|
|
1277
710
|
visitedUrls.add(url);
|
|
1278
711
|
const response = await this.fetch(url, { signal });
|
|
1279
|
-
|
|
1280
|
-
const page =
|
|
712
|
+
assertResponse(response, url);
|
|
713
|
+
const page = validateCollections(await response.json(), url);
|
|
1281
714
|
this.attachDocumentUrl(page, url);
|
|
1282
715
|
for (const collection of page.collections) {
|
|
1283
716
|
this.attachDocumentUrl(collection, url);
|
|
1284
717
|
}
|
|
1285
718
|
collections.push(...page.collections);
|
|
1286
|
-
const nextLink =
|
|
1287
|
-
url = nextLink ?
|
|
719
|
+
const nextLink = findLink(page.links, "next");
|
|
720
|
+
url = nextLink ? resolveUrl(nextLink.href, url) : null;
|
|
1288
721
|
}
|
|
1289
722
|
return collections;
|
|
1290
723
|
}
|
|
1291
724
|
/** Traverses only static `child` links to collect Collection documents. */
|
|
1292
725
|
async getStaticCollections(root, options) {
|
|
1293
726
|
var _a, _b;
|
|
1294
|
-
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ??
|
|
1295
|
-
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ??
|
|
1296
|
-
|
|
1297
|
-
|
|
727
|
+
const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
|
|
728
|
+
const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
|
|
729
|
+
validateTraversalLimit("maxDepth", maxDepth);
|
|
730
|
+
validateTraversalLimit("maxRequests", maxRequests);
|
|
1298
731
|
const rootUrl = this.getDocumentUrl(root);
|
|
1299
732
|
const queue = [{ url: rootUrl, depth: 0 }];
|
|
1300
733
|
const visitedUrls = /* @__PURE__ */ new Set();
|
|
1301
734
|
const collections = [];
|
|
1302
735
|
let requestCount = 0;
|
|
1303
736
|
while (queue.length > 0) {
|
|
1304
|
-
|
|
737
|
+
throwIfAborted(options.signal);
|
|
1305
738
|
const entry = queue.shift();
|
|
1306
739
|
if (visitedUrls.has(entry.url)) {
|
|
1307
740
|
continue;
|
|
@@ -1312,17 +745,17 @@ var STACSource2 = class extends DataSource {
|
|
|
1312
745
|
visitedUrls.add(entry.url);
|
|
1313
746
|
requestCount++;
|
|
1314
747
|
const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
|
|
1315
|
-
if (
|
|
748
|
+
if (isCollection(object)) {
|
|
1316
749
|
collections.push(object);
|
|
1317
750
|
}
|
|
1318
|
-
if (!
|
|
751
|
+
if (!isCatalog(object) && !isCollection(object)) {
|
|
1319
752
|
continue;
|
|
1320
753
|
}
|
|
1321
754
|
if (entry.depth < maxDepth) {
|
|
1322
755
|
for (const link of object.links) {
|
|
1323
756
|
if (link.rel === "child") {
|
|
1324
757
|
queue.push({
|
|
1325
|
-
url:
|
|
758
|
+
url: resolveUrl(link.href, this.getDocumentUrl(object)),
|
|
1326
759
|
depth: entry.depth + 1
|
|
1327
760
|
});
|
|
1328
761
|
}
|
|
@@ -1333,12 +766,12 @@ var STACSource2 = class extends DataSource {
|
|
|
1333
766
|
}
|
|
1334
767
|
/** Fetches and validates one core STAC document. */
|
|
1335
768
|
async fetchObject(url, signal) {
|
|
1336
|
-
|
|
769
|
+
throwIfAborted(signal);
|
|
1337
770
|
const response = await this.fetch(url, { signal });
|
|
1338
|
-
|
|
1339
|
-
const object =
|
|
771
|
+
assertResponse(response, url);
|
|
772
|
+
const object = validateObject(await response.json(), url);
|
|
1340
773
|
this.attachDocumentUrl(object, url);
|
|
1341
|
-
if (
|
|
774
|
+
if (isItemCollection(object)) {
|
|
1342
775
|
for (const item of object.features) {
|
|
1343
776
|
this.attachDocumentUrl(item, url);
|
|
1344
777
|
}
|
|
@@ -1354,11 +787,11 @@ var STACSource2 = class extends DataSource {
|
|
|
1354
787
|
headers.set("content-type", "application/json");
|
|
1355
788
|
body = JSON.stringify(request.body || {});
|
|
1356
789
|
} else if (request.body && Object.keys(request.body).length > 0) {
|
|
1357
|
-
url =
|
|
790
|
+
url = appendQuery(url, request.body);
|
|
1358
791
|
}
|
|
1359
792
|
const response = await this.fetch(url, { method: request.method, headers, body, signal });
|
|
1360
|
-
|
|
1361
|
-
const page =
|
|
793
|
+
assertResponse(response, url);
|
|
794
|
+
const page = validateItemCollection(await response.json(), url);
|
|
1362
795
|
this.attachDocumentUrl(page, url);
|
|
1363
796
|
for (const item of page.features) {
|
|
1364
797
|
this.attachDocumentUrl(item, url);
|
|
@@ -1374,28 +807,28 @@ var STACSource2 = class extends DataSource {
|
|
|
1374
807
|
return this.documentUrls.get(object) || this.url;
|
|
1375
808
|
}
|
|
1376
809
|
};
|
|
1377
|
-
function
|
|
810
|
+
function createSearchRequest(link, baseUrl, query) {
|
|
1378
811
|
const { signal: _signal, ...body } = query;
|
|
1379
812
|
return {
|
|
1380
|
-
url:
|
|
813
|
+
url: resolveUrl(link.href, baseUrl),
|
|
1381
814
|
method: link.method || "POST",
|
|
1382
815
|
headers: link.headers,
|
|
1383
816
|
body
|
|
1384
817
|
};
|
|
1385
818
|
}
|
|
1386
|
-
function
|
|
819
|
+
function createNextRequest(link, baseUrl, previousRequest) {
|
|
1387
820
|
const linkBody = link.body || {};
|
|
1388
821
|
return {
|
|
1389
|
-
url:
|
|
822
|
+
url: resolveUrl(link.href, baseUrl),
|
|
1390
823
|
method: link.method || previousRequest.method,
|
|
1391
824
|
headers: { ...previousRequest.headers, ...link.headers },
|
|
1392
825
|
body: link.merge ? { ...previousRequest.body, ...linkBody } : link.body
|
|
1393
826
|
};
|
|
1394
827
|
}
|
|
1395
|
-
function
|
|
828
|
+
function getRequestKey(request) {
|
|
1396
829
|
return `${request.method} ${request.url} ${JSON.stringify(request.body || {})}`;
|
|
1397
830
|
}
|
|
1398
|
-
function
|
|
831
|
+
function appendQuery(url, body) {
|
|
1399
832
|
const parsedUrl = new URL(url);
|
|
1400
833
|
for (const [key, value] of Object.entries(body)) {
|
|
1401
834
|
if (value !== void 0) {
|
|
@@ -1404,40 +837,40 @@ function appendQuery2(url, body) {
|
|
|
1404
837
|
}
|
|
1405
838
|
return parsedUrl.href;
|
|
1406
839
|
}
|
|
1407
|
-
function
|
|
840
|
+
function resolveUrl(url, baseUrl) {
|
|
1408
841
|
return new URL(url, baseUrl).href;
|
|
1409
842
|
}
|
|
1410
|
-
function
|
|
843
|
+
function findLink(links, relation) {
|
|
1411
844
|
return links.find((link) => link.rel === relation);
|
|
1412
845
|
}
|
|
1413
|
-
function
|
|
846
|
+
function assertResponse(response, url) {
|
|
1414
847
|
if (!response.ok) {
|
|
1415
848
|
throw new Error(`STAC request failed (${response.status} ${response.statusText}): ${url}`);
|
|
1416
849
|
}
|
|
1417
850
|
}
|
|
1418
|
-
function
|
|
851
|
+
function validateTraversalLimit(name, value) {
|
|
1419
852
|
if (!Number.isSafeInteger(value) || value < 1) {
|
|
1420
853
|
throw new Error(`STAC ${name} must be a positive integer`);
|
|
1421
854
|
}
|
|
1422
855
|
}
|
|
1423
|
-
function
|
|
856
|
+
function throwIfAborted(signal) {
|
|
1424
857
|
if (signal == null ? void 0 : signal.aborted) {
|
|
1425
858
|
throw signal.reason || new DOMException("The operation was aborted", "AbortError");
|
|
1426
859
|
}
|
|
1427
860
|
}
|
|
1428
|
-
function
|
|
861
|
+
function waitForPromiseWithSignal(promise, signal) {
|
|
1429
862
|
if (!signal) {
|
|
1430
863
|
return promise;
|
|
1431
864
|
}
|
|
1432
|
-
|
|
865
|
+
throwIfAborted(signal);
|
|
1433
866
|
return new Promise((resolve, reject) => {
|
|
1434
867
|
const handleAbort = () => reject(signal.reason || new DOMException("The operation was aborted", "AbortError"));
|
|
1435
868
|
signal.addEventListener("abort", handleAbort, { once: true });
|
|
1436
869
|
void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", handleAbort));
|
|
1437
870
|
});
|
|
1438
871
|
}
|
|
1439
|
-
function
|
|
1440
|
-
if (!
|
|
872
|
+
function validateObject(value, url) {
|
|
873
|
+
if (!isRecord(value)) {
|
|
1441
874
|
throw new Error(`Invalid STAC JSON document: ${url}`);
|
|
1442
875
|
}
|
|
1443
876
|
if (value.type === "Catalog" || value.type === "Collection") {
|
|
@@ -1447,80 +880,80 @@ function validateObject2(value, url) {
|
|
|
1447
880
|
return value;
|
|
1448
881
|
}
|
|
1449
882
|
if (value.type === "Feature") {
|
|
1450
|
-
if (typeof value.id !== "string" || !
|
|
883
|
+
if (typeof value.id !== "string" || !isRecord(value.assets) || !Array.isArray(value.links)) {
|
|
1451
884
|
throw new Error(`Invalid STAC Item: ${url}`);
|
|
1452
885
|
}
|
|
1453
886
|
return value;
|
|
1454
887
|
}
|
|
1455
888
|
if (value.type === "FeatureCollection") {
|
|
1456
|
-
return
|
|
889
|
+
return validateItemCollection(value, url);
|
|
1457
890
|
}
|
|
1458
891
|
throw new Error(`Unsupported STAC object type at ${url}`);
|
|
1459
892
|
}
|
|
1460
|
-
function
|
|
1461
|
-
if (!
|
|
893
|
+
function validateItemCollection(value, url) {
|
|
894
|
+
if (!isRecord(value) || value.type !== "FeatureCollection" || !Array.isArray(value.features) || !Array.isArray(value.links)) {
|
|
1462
895
|
throw new Error(`Invalid STAC ItemCollection: ${url}`);
|
|
1463
896
|
}
|
|
1464
897
|
for (const item of value.features) {
|
|
1465
|
-
if (!
|
|
898
|
+
if (!isItem(item)) {
|
|
1466
899
|
throw new Error(`Invalid STAC Item in ItemCollection: ${url}`);
|
|
1467
900
|
}
|
|
1468
901
|
}
|
|
1469
902
|
return value;
|
|
1470
903
|
}
|
|
1471
|
-
function
|
|
1472
|
-
if (!
|
|
904
|
+
function validateCollections(value, url) {
|
|
905
|
+
if (!isRecord(value) || !Array.isArray(value.collections) || !Array.isArray(value.links)) {
|
|
1473
906
|
throw new Error(`Invalid STAC Collections response: ${url}`);
|
|
1474
907
|
}
|
|
1475
|
-
if (!value.collections.every(
|
|
908
|
+
if (!value.collections.every(isCollection)) {
|
|
1476
909
|
throw new Error(`Invalid Collection in STAC Collections response: ${url}`);
|
|
1477
910
|
}
|
|
1478
911
|
return value;
|
|
1479
912
|
}
|
|
1480
|
-
function
|
|
1481
|
-
return
|
|
913
|
+
function isCatalog(value) {
|
|
914
|
+
return isRecord(value) && value.type === "Catalog" && Array.isArray(value.links);
|
|
1482
915
|
}
|
|
1483
|
-
function
|
|
1484
|
-
return
|
|
916
|
+
function isCollection(value) {
|
|
917
|
+
return isRecord(value) && value.type === "Collection" && Array.isArray(value.links);
|
|
1485
918
|
}
|
|
1486
|
-
function
|
|
1487
|
-
return
|
|
919
|
+
function isItem(value) {
|
|
920
|
+
return isRecord(value) && value.type === "Feature" && typeof value.id === "string" && isRecord(value.assets) && Array.isArray(value.links);
|
|
1488
921
|
}
|
|
1489
|
-
function
|
|
1490
|
-
return
|
|
922
|
+
function isItemCollection(value) {
|
|
923
|
+
return isRecord(value) && value.type === "FeatureCollection" && Array.isArray(value.features) && Array.isArray(value.links);
|
|
1491
924
|
}
|
|
1492
|
-
function
|
|
925
|
+
function isRecord(value) {
|
|
1493
926
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1494
927
|
}
|
|
1495
|
-
function
|
|
928
|
+
function matchesItem(item, query) {
|
|
1496
929
|
if (query.ids && !query.ids.includes(item.id)) {
|
|
1497
930
|
return false;
|
|
1498
931
|
}
|
|
1499
932
|
if (query.collections && (!item.collection || !query.collections.includes(item.collection))) {
|
|
1500
933
|
return false;
|
|
1501
934
|
}
|
|
1502
|
-
if (query.bbox && item.bbox && !
|
|
935
|
+
if (query.bbox && item.bbox && !intersectsBoundingBox(query.bbox, item.bbox)) {
|
|
1503
936
|
return false;
|
|
1504
937
|
}
|
|
1505
|
-
return !query.datetime ||
|
|
938
|
+
return !query.datetime || intersectsDatetime(query.datetime, item);
|
|
1506
939
|
}
|
|
1507
|
-
function
|
|
940
|
+
function intersectsBoundingBox(left, right) {
|
|
1508
941
|
const leftMaximumX = left.length === 6 ? left[3] : left[2];
|
|
1509
942
|
const leftMaximumY = left.length === 6 ? left[4] : left[3];
|
|
1510
943
|
const rightMaximumX = right.length === 6 ? right[3] : right[2];
|
|
1511
944
|
const rightMaximumY = right.length === 6 ? right[4] : right[3];
|
|
1512
945
|
return !(leftMaximumX < right[0] || rightMaximumX < left[0] || leftMaximumY < right[1] || rightMaximumY < left[1]);
|
|
1513
946
|
}
|
|
1514
|
-
function
|
|
1515
|
-
const queryInterval =
|
|
947
|
+
function intersectsDatetime(datetime, item) {
|
|
948
|
+
const queryInterval = parseDatetimeInterval(datetime, true);
|
|
1516
949
|
const itemDatetime = item.properties.datetime;
|
|
1517
|
-
const itemInterval = typeof itemDatetime === "string" ?
|
|
950
|
+
const itemInterval = typeof itemDatetime === "string" ? parseDatetimeInterval(itemDatetime, false) : parseItemDatetimeInterval(item);
|
|
1518
951
|
if (!itemInterval) {
|
|
1519
952
|
return true;
|
|
1520
953
|
}
|
|
1521
954
|
return queryInterval[0] <= itemInterval[1] && itemInterval[0] <= queryInterval[1];
|
|
1522
955
|
}
|
|
1523
|
-
function
|
|
956
|
+
function parseDatetimeInterval(datetime, throwOnInvalid) {
|
|
1524
957
|
const parts = datetime.split("/");
|
|
1525
958
|
const start = parts[0] === ".." ? Number.NEGATIVE_INFINITY : Date.parse(parts[0]);
|
|
1526
959
|
const endPart = parts.length > 1 ? parts[1] : parts[0];
|
|
@@ -1533,12 +966,12 @@ function parseDatetimeInterval2(datetime, throwOnInvalid) {
|
|
|
1533
966
|
}
|
|
1534
967
|
return [start, end];
|
|
1535
968
|
}
|
|
1536
|
-
function
|
|
969
|
+
function parseItemDatetimeInterval(item) {
|
|
1537
970
|
const start = item.properties.start_datetime;
|
|
1538
971
|
const end = item.properties.end_datetime;
|
|
1539
972
|
if (!start || !end) {
|
|
1540
973
|
return null;
|
|
1541
974
|
}
|
|
1542
|
-
return
|
|
975
|
+
return parseDatetimeInterval(`${start}/${end}`, false);
|
|
1543
976
|
}
|
|
1544
977
|
//# sourceMappingURL=stac-source.cjs.map
|