ol-stac 1.7.1 → 1.8.1

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/layer/STAC.d.ts CHANGED
@@ -392,7 +392,8 @@ export type Options = {
392
392
  */
393
393
  /**
394
394
  * @classdesc
395
- * Renders STAC entities such as STAC Items, Collectons or lists of them as returned by APIs.
395
+ * Renders STAC entities such as STAC Items, Collections, Catalogs or lists of them as returned by APIs.
396
+ * Catalogs have no spatial extent, so only their web map links and children can be shown.
396
397
  * The layers created by this LayerGroup all have a 'stac' value that can be retrieved using `layer.get('stac')`.
397
398
  *
398
399
  * @extends LayerGroup
@@ -516,6 +517,12 @@ declare class STACLayer extends LayerGroup {
516
517
  * @private
517
518
  */
518
519
  private boundsLayer_;
520
+ /**
521
+ * The bounding boxes (WGS84) that web map link layers declare.
522
+ * @type {WeakMap<import("ol/layer/Base.js").default, Array<number>>}
523
+ * @private
524
+ */
525
+ private layerBounds_;
519
526
  /**
520
527
  * @type {boolean}
521
528
  * @private
@@ -531,6 +538,12 @@ declare class STACLayer extends LayerGroup {
531
538
  * @private
532
539
  */
533
540
  private eventQueue_;
541
+ /**
542
+ * Resolves once the initial layers are added.
543
+ * @type {Promise}
544
+ * @private
545
+ */
546
+ private initialLayers_;
534
547
  /**
535
548
  * @type {function(string,string):(*)|null}
536
549
  * @private
@@ -545,6 +558,15 @@ declare class STACLayer extends LayerGroup {
545
558
  * @return {Promise<*>} The (parsed) response body.
546
559
  */
547
560
  fetch_(url: string, responseType?: string, ref?: Asset | Link | STACObject | null): Promise<any>;
561
+ /**
562
+ * Gets the attribution for the given reference, see the attribution extension.
563
+ * Assets inherit the attribution from their STAC entity, Links fall back to the STAC entity.
564
+ *
565
+ * @param {Asset|Link|STACObject} ref The STAC Asset, Link or entity that is shown.
566
+ * @return {string|undefined} The attribution, if available.
567
+ * @private
568
+ */
569
+ private getAttributionFor_;
548
570
  /**
549
571
  * Rewrites the given URL based on the `getRequestUrl` option.
550
572
  *
@@ -616,6 +638,7 @@ declare class STACLayer extends LayerGroup {
616
638
  private dispatch_;
617
639
  /**
618
640
  * Flush all events.
641
+ * @param {boolean} [force] Flush even if the map is not set.
619
642
  * @private
620
643
  */
621
644
  private flush_;
@@ -740,6 +763,13 @@ declare class STACLayer extends LayerGroup {
740
763
  * @api
741
764
  */
742
765
  updateLayers(emit?: boolean): Promise<any>;
766
+ /**
767
+ * Flushes the events if the group has no layer.
768
+ * Without any layer, the map can't be detected, but nothing depends on it either.
769
+ * Child groups may still add layers, so wait for them first.
770
+ * @private
771
+ */
772
+ private flushIfEmpty_;
743
773
  /**
744
774
  * Indicates whether the LayerGroup shows only the bounds layer (i.e. no imagery/tile layers).
745
775
  * @return {boolean} `true` if only the bounds layer is shown, `false` otherwise.
@@ -810,6 +840,12 @@ declare class STACLayer extends LayerGroup {
810
840
  * @api
811
841
  */
812
842
  getAssets(): Array<Asset>;
843
+ /**
844
+ * @return {Array<Array<number>>} The bounding boxes (WGS84) that the shown web map link layers declare,
845
+ * including the layers of the children.
846
+ * @private
847
+ */
848
+ private getLayerBounds_;
813
849
  getLayerState(): import("ol/layer/Layer.js").State;
814
850
  /**
815
851
  * Get the attributions of the STAC entity assigned to this layer.
@@ -1 +1 @@
1
- {"version":3,"file":"STAC.d.ts","sourceRoot":"","sources":["../../../src/ol/layer/STAC.js"],"names":[],"mappings":";qBAsDa,OAAO,cAAc,EAAE,MAAM;oBAG7B,OAAO,mBAAmB,EAAE,OAAO;;;;;kBAenC,OAAO,WAAW,EAAE,OAAO;oBAG3B,OAAO,mBAAmB,EAAE,OAAO;4BAGnC,OAAO,mBAAmB,EAAE,aAAa;2BAGzC,OAAO,WAAW,EAAE,YAAY;2BAGhC,OAAO,YAAY,EAAE,YAAY;wBAGjC,OAAO,YAAY,EAAE,SAAS;2BAG9B,CAAS,IAA4D,EAA5D,CAAC,OAAO,aAAa,EAAE,OAAO,GAAC,OAAO,YAAY,EAAE,OAAO,CAAC,EAAE,I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;IAED;;;;OAIG;IACH,gBAHW,OAAO,uBAAuB,EAAE,KAAK,GAAC,IAAI,QAUpD;IAED;;;;;;;;;OASG;IACH,6BAJW,KAAK,CAAC,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,CAAC,GAAC,IAAI,gBAaxD;IAED;;;;;;OAMG;IACH,kBALW,KAAK,CAAC,MAAM,GAAC,KAAK,CAAC,GAAC,IAAI,iBACxB,OAAO,gBA0BjB;IAED;;;;;;;;;;OAUG;IACH,oBANW,aAAa,SAAQ,KAAK,CAAC,IAAI,MAAO,CAAC,GAAC,IAAI,YAC5C,OAAO,GAAC,IAAI,iBACZ,OAAO,gBA+BjB;IAED;;;;;OAKG;IACH,WAHY,IAAI,GAAC,KAAK,CAKrB;IAED;;;;;OAKG;IACH,eAHY,KAAK,CAAC,IAAI,CAAC,CAKtB;IAED;;;;;OAKG;IACH,aAHY,KAAK,CAAC,KAAK,CAAC,CAKvB;IAqDD;;;;OAIG;IACH,wBAUC;IAED,mDAOC;IAED;;;;;OAKG;IACH,mBAHY,KAAK,CAAC,MAAM,CAAC,CAMxB;IAED;;;OAGG;IACH,aAFY,UAAU,GAAC,IAAI,CAI1B;IAED;;;;;;;OAOG;IACH,6BAYC;CACF;uBAj5DsB,mBAAmB;sBAkBpB,WAAW;uBA7CV,mBAAmB;wBAGlB,oBAAoB"}
package/layer/STAC.js CHANGED
@@ -189,7 +189,8 @@ import LayerType from './type.js';
189
189
  */
190
190
  /**
191
191
  * @classdesc
192
- * Renders STAC entities such as STAC Items, Collectons or lists of them as returned by APIs.
192
+ * Renders STAC entities such as STAC Items, Collections, Catalogs or lists of them as returned by APIs.
193
+ * Catalogs have no spatial extent, so only their web map links and children can be shown.
193
194
  * The layers created by this LayerGroup all have a 'stac' value that can be retrieved using `layer.get('stac')`.
194
195
  *
195
196
  * @extends LayerGroup
@@ -325,6 +326,12 @@ class STACLayer extends LayerGroup {
325
326
  * @private
326
327
  */
327
328
  this.boundsLayer_ = null;
329
+ /**
330
+ * The bounding boxes (WGS84) that web map link layers declare.
331
+ * @type {WeakMap<import("ol/layer/Base.js").default, Array<number>>}
332
+ * @private
333
+ */
334
+ this.layerBounds_ = new WeakMap();
328
335
  /**
329
336
  * @type {boolean}
330
337
  * @private
@@ -340,6 +347,12 @@ class STACLayer extends LayerGroup {
340
347
  * @private
341
348
  */
342
349
  this.eventQueue_ = [];
350
+ /**
351
+ * Resolves once the initial layers are added.
352
+ * @type {Promise}
353
+ * @private
354
+ */
355
+ this.initialLayers_ = Promise.resolve();
343
356
  /**
344
357
  * @type {function(string,string):(*)|null}
345
358
  * @private
@@ -364,6 +377,25 @@ class STACLayer extends LayerGroup {
364
377
  .then((data) => this.configure_(data, options.url, options.children, options.assets, options.bands))
365
378
  .catch((error) => this.handleError_(error));
366
379
  }
380
+ /**
381
+ * Gets the attribution for the given reference, see the attribution extension.
382
+ * Assets inherit the attribution from their STAC entity, Links fall back to the STAC entity.
383
+ *
384
+ * @param {Asset|Link|STACObject} ref The STAC Asset, Link or entity that is shown.
385
+ * @return {string|undefined} The attribution, if available.
386
+ * @private
387
+ */
388
+ getAttributionFor_(ref) {
389
+ var _a, _b;
390
+ const candidates = [ref, ((_a = ref === null || ref === void 0 ? void 0 : ref.getContext) === null || _a === void 0 ? void 0 : _a.call(ref)) || this.getData()];
391
+ for (const candidate of candidates) {
392
+ const attribution = (_b = candidate === null || candidate === void 0 ? void 0 : candidate.getMetadata) === null || _b === void 0 ? void 0 : _b.call(candidate, 'attribution');
393
+ if (typeof attribution === 'string' && attribution.length > 0) {
394
+ return attribution;
395
+ }
396
+ }
397
+ return undefined;
398
+ }
367
399
  /**
368
400
  * Rewrites the given URL based on the `getRequestUrl` option.
369
401
  *
@@ -453,11 +485,15 @@ class STACLayer extends LayerGroup {
453
485
  * @api
454
486
  */
455
487
  isEmpty() {
456
- const count = this.getLayers().getLength();
457
- if (count > 1) {
488
+ var _a;
489
+ const hasContent = this.getLayers()
490
+ .getArray()
491
+ .some((layer) => layer !== this.boundsLayer_ &&
492
+ (!(layer instanceof STACLayer) || !layer.isEmpty()));
493
+ if (hasContent) {
458
494
  return false;
459
495
  }
460
- const bbox = this.getData().getBoundingBox();
496
+ const bbox = (_a = this.getData()) === null || _a === void 0 ? void 0 : _a.getBoundingBox();
461
497
  if (!bbox || isEmpty(toContinuousBBox(bbox))) {
462
498
  return true;
463
499
  }
@@ -526,7 +562,10 @@ class STACLayer extends LayerGroup {
526
562
  if (assets) {
527
563
  promises.push(this.setAssets(assets, false).catch(errorHandler));
528
564
  }
529
- Promise.all(promises).then(() => this.updateLayers().catch(errorHandler));
565
+ this.initialLayers_ = Promise.all(promises).then(() => this.updateLayers().catch((error) => {
566
+ errorHandler(error);
567
+ this.flushIfEmpty_();
568
+ }));
530
569
  /**
531
570
  * Invoked once the STAC entity is loaded and available.
532
571
  *
@@ -549,10 +588,11 @@ class STACLayer extends LayerGroup {
549
588
  }
550
589
  /**
551
590
  * Flush all events.
591
+ * @param {boolean} [force] Flush even if the map is not set.
552
592
  * @private
553
593
  */
554
- flush_() {
555
- if (this.map_) {
594
+ flush_(force = false) {
595
+ if (this.map_ || force) {
556
596
  for (const event of this.eventQueue_) {
557
597
  this.dispatchEvent(event);
558
598
  }
@@ -639,6 +679,7 @@ class STACLayer extends LayerGroup {
639
679
  projection,
640
680
  imageExtent: toOlExtent(bbox, projection),
641
681
  crossOrigin: this.crossOrigin_,
682
+ attributions: this.getAttributionFor_(image),
642
683
  };
643
684
  const imageLoadFunction = this.createLoadFunction_(createImageLoadFunction, image);
644
685
  if (imageLoadFunction) {
@@ -662,6 +703,7 @@ class STACLayer extends LayerGroup {
662
703
  * @api
663
704
  */
664
705
  async addLayerForLink(link) {
706
+ var _a, _b, _c;
665
707
  // Replace any occurances of {s} if possible, otherwise return
666
708
  let url = getSpecificWebMapUrl(link);
667
709
  if (!url) {
@@ -669,8 +711,7 @@ class STACLayer extends LayerGroup {
669
711
  }
670
712
  url = this.getRequestUrlFor_(url, link, link.rel === 'xyz');
671
713
  const options = {
672
- attributions: link.getMetadata('attribution') ||
673
- this.getData().getMetadata('attribution'),
714
+ attributions: this.getAttributionFor_(link),
674
715
  crossOrigin: this.crossOrigin_,
675
716
  url,
676
717
  };
@@ -685,6 +726,8 @@ class STACLayer extends LayerGroup {
685
726
  return options;
686
727
  };
687
728
  const sources = [];
729
+ // The bounding boxes (WGS84) that the sources declare
730
+ const sourceBounds = new Map();
688
731
  switch (link.rel) {
689
732
  case 'pmtiles': {
690
733
  const snapshot = JSON.stringify(options);
@@ -733,6 +776,12 @@ class STACLayer extends LayerGroup {
733
776
  ? new PMTilesVectorSource(pmOptions)
734
777
  : new PMTilesRasterSource(pmOptions);
735
778
  sources.push(source);
779
+ sourceBounds.set(source, [
780
+ pmtilesHeader.minLon,
781
+ pmtilesHeader.minLat,
782
+ pmtilesHeader.maxLon,
783
+ pmtilesHeader.maxLat,
784
+ ]);
736
785
  break;
737
786
  }
738
787
  case 'tilejson': {
@@ -740,7 +789,16 @@ class STACLayer extends LayerGroup {
740
789
  const tjOptions = await updateOptions(SourceType.TileJSON, options);
741
790
  if (tjOptions.jsonp || tjOptions.tileJSON) {
742
791
  // Let the source load the manifest itself (e.g. via JSONP)
743
- sources.push(new TileJSON(tjOptions));
792
+ if (tjOptions.tileJSON) {
793
+ // OpenLayers prefers the URL over an inline manifest
794
+ delete tjOptions.url;
795
+ }
796
+ const source = new TileJSON(tjOptions);
797
+ sources.push(source);
798
+ const bounds = (_a = tjOptions.tileJSON) === null || _a === void 0 ? void 0 : _a.bounds;
799
+ if (Array.isArray(bounds) && bounds.length === 4) {
800
+ sourceBounds.set(source, bounds);
801
+ }
744
802
  break;
745
803
  }
746
804
  // Load the manifest through the request function so that
@@ -759,7 +817,11 @@ class STACLayer extends LayerGroup {
759
817
  }
760
818
  delete tjOptions.url;
761
819
  tjOptions.tileJSON = tileJSON;
762
- sources.push(new TileJSON(tjOptions));
820
+ const source = new TileJSON(tjOptions);
821
+ sources.push(source);
822
+ if (Array.isArray(tileJSON === null || tileJSON === void 0 ? void 0 : tileJSON.bounds) && tileJSON.bounds.length === 4) {
823
+ sourceBounds.set(source, tileJSON.bounds);
824
+ }
763
825
  break;
764
826
  }
765
827
  case 'wms':
@@ -845,7 +907,12 @@ class STACLayer extends LayerGroup {
845
907
  else if (Array.isArray(opts.urls)) {
846
908
  opts.urls = opts.urls.map((u) => this.getRequestUrlFor_(u, link, opts.requestEncoding === 'REST'));
847
909
  }
848
- sources.push(new WMTS(opts));
910
+ const source = new WMTS(opts);
911
+ sources.push(source);
912
+ const capabilitiesLayer = (_c = (_b = wmtsCapabilities.Contents) === null || _b === void 0 ? void 0 : _b.Layer) === null || _c === void 0 ? void 0 : _c.find((l) => l.Identifier === opts.layer);
913
+ if (Array.isArray(capabilitiesLayer === null || capabilitiesLayer === void 0 ? void 0 : capabilitiesLayer.WGS84BoundingBox)) {
914
+ sourceBounds.set(source, capabilitiesLayer.WGS84BoundingBox);
915
+ }
849
916
  }
850
917
  break;
851
918
  case 'xyz':
@@ -868,6 +935,9 @@ class STACLayer extends LayerGroup {
868
935
  const layerOptions = await this.updateLayerOptions_(LayerType.Tile, { source }, link);
869
936
  layer = new TileLayer(layerOptions);
870
937
  }
938
+ if (sourceBounds.has(source)) {
939
+ this.layerBounds_.set(layer, sourceBounds.get(source));
940
+ }
871
941
  this.addLayer_(layer, link);
872
942
  return layer;
873
943
  }));
@@ -897,6 +967,7 @@ class STACLayer extends LayerGroup {
897
967
  sources: [sourceInfo],
898
968
  convertToRGB: 'auto',
899
969
  loadMissingProjection: true,
970
+ attributions: this.getAttributionFor_(asset),
900
971
  };
901
972
  const projection = await getProjection(asset);
902
973
  if (projection) {
@@ -915,6 +986,8 @@ class STACLayer extends LayerGroup {
915
986
  options = await this.getSourceOptions_(SourceType.GeoTIFF, options, asset);
916
987
  }
917
988
  const source = new GeoTIFF(options);
989
+ // OpenLayers < 10.8 doesn't pass the attributions option through
990
+ source.setAttributions(options.attributions);
918
991
  const status = new Promise((resolve, reject) => {
919
992
  source.on('error', reject);
920
993
  source.on('change', () => {
@@ -978,6 +1051,7 @@ class STACLayer extends LayerGroup {
978
1051
  * @type {import("ol/source/XYZ.js").Options}
979
1052
  */
980
1053
  let options = {
1054
+ attributions: this.getAttributionFor_(data),
981
1055
  crossOrigin: this.crossOrigin_,
982
1056
  url,
983
1057
  };
@@ -1019,6 +1093,19 @@ class STACLayer extends LayerGroup {
1019
1093
  layer.set('stac', data);
1020
1094
  }
1021
1095
  layer.setZIndex(zIndex);
1096
+ // The footprint sets the map once rendered, which defers the events until listeners are registered.
1097
+ // Without a footprint, the other layers are the only way to learn about the map.
1098
+ if (!(layer instanceof LayerGroup) && !layer.get('bounds')) {
1099
+ layer.addEventListener('change:map', () => {
1100
+ const map = layer.getMapInternal();
1101
+ if (map) {
1102
+ this.setMap_(map);
1103
+ }
1104
+ else if (!this.getLayersArray().some((l) => l.getMapInternal())) {
1105
+ this.setMap_(null);
1106
+ }
1107
+ });
1108
+ }
1022
1109
  this.getLayers().push(layer);
1023
1110
  }
1024
1111
  /**
@@ -1056,7 +1143,9 @@ class STACLayer extends LayerGroup {
1056
1143
  async addGeoJson_(asset) {
1057
1144
  try {
1058
1145
  const geojson = await this.fetch_(this.getRequestUrlFor_(asset.getAbsoluteUrl(), asset), 'json', asset);
1059
- const layerOptions = await this.updateLayerOptions_(LayerType.Vector, this.getGeoJsonLayerOptions_(geojson), asset);
1146
+ const vectorOptions = this.getGeoJsonLayerOptions_(geojson);
1147
+ vectorOptions.source.setAttributions(this.getAttributionFor_(asset));
1148
+ const layerOptions = await this.updateLayerOptions_(LayerType.Vector, vectorOptions, asset);
1060
1149
  const layer = new VectorLayer(layerOptions);
1061
1150
  this.addLayer_(layer, asset);
1062
1151
  return layer;
@@ -1189,6 +1278,7 @@ class STACLayer extends LayerGroup {
1189
1278
  }
1190
1279
  }
1191
1280
  let options = getGeoZarrSourceOptionsFromAsset(asset, this.bands_);
1281
+ options.attributions = this.getAttributionFor_(asset);
1192
1282
  // Web-Optimized Zarr describes its bands in the store metadata,
1193
1283
  // everything else must declare what to render in the STAC metadata
1194
1284
  // (or provide it through getSourceOptions for explicitly selected assets)
@@ -1217,6 +1307,8 @@ class STACLayer extends LayerGroup {
1217
1307
  }
1218
1308
  const GeoZarr = (await import('../source/GeoZarr.js')).default;
1219
1309
  const source = new GeoZarr(options);
1310
+ // The source doesn't pass the attributions option through
1311
+ source.setAttributions(options.attributions);
1220
1312
  await new Promise((resolve, reject) => {
1221
1313
  source.on('change', () => {
1222
1314
  if (source.getState() === 'error') {
@@ -1357,6 +1449,26 @@ class STACLayer extends LayerGroup {
1357
1449
  if (emit) {
1358
1450
  this.dispatch_('layersready');
1359
1451
  }
1452
+ this.flushIfEmpty_();
1453
+ }
1454
+ /**
1455
+ * Flushes the events if the group has no layer.
1456
+ * Without any layer, the map can't be detected, but nothing depends on it either.
1457
+ * Child groups may still add layers, so wait for them first.
1458
+ * @private
1459
+ */
1460
+ flushIfEmpty_() {
1461
+ if (this.map_) {
1462
+ return;
1463
+ }
1464
+ const groups = this.getLayers()
1465
+ .getArray()
1466
+ .filter((layer) => layer instanceof STACLayer);
1467
+ Promise.all(groups.map((group) => group.initialLayers_)).then(() => {
1468
+ if (!this.map_ && this.getLayersArray().length === 0) {
1469
+ this.flush_(true);
1470
+ }
1471
+ });
1360
1472
  }
1361
1473
  /**
1362
1474
  * Indicates whether the LayerGroup shows only the bounds layer (i.e. no imagery/tile layers).
@@ -1516,6 +1628,10 @@ class STACLayer extends LayerGroup {
1516
1628
  * EPSG:4326 instead of the map projection. Make sure to transform it with the
1517
1629
  * ol.proj.transformExtent function if needed.
1518
1630
  *
1631
+ * For STAC entities without spatial extent (e.g. Catalogs), the extent is derived from
1632
+ * the bounds that the shown web map links declare (PMTiles, TileJSON, WMTS), if available.
1633
+ * Returns `undefined` if no extent is known or the layer is not added to a map.
1634
+ *
1519
1635
  * @return {Extent|undefined} The layer extent.
1520
1636
  * @api
1521
1637
  */
@@ -1543,10 +1659,30 @@ class STACLayer extends LayerGroup {
1543
1659
  const bboxes = items.map((item) => item.getBoundingBox());
1544
1660
  bbox = unionBoundingBox(bboxes);
1545
1661
  }
1662
+ if (!(data === null || data === void 0 ? void 0 : data.getBoundingBox())) {
1663
+ bbox = unionBoundingBox([bbox, ...this.getLayerBounds_()]);
1664
+ }
1546
1665
  if (bbox) {
1547
1666
  return toOlExtent(bbox, view.getProjection());
1548
1667
  }
1549
1668
  }
1669
+ /**
1670
+ * @return {Array<Array<number>>} The bounding boxes (WGS84) that the shown web map link layers declare,
1671
+ * including the layers of the children.
1672
+ * @private
1673
+ */
1674
+ getLayerBounds_() {
1675
+ const bounds = [];
1676
+ for (const layer of this.getLayers().getArray()) {
1677
+ if (layer instanceof STACLayer) {
1678
+ bounds.push(...layer.getLayerBounds_());
1679
+ }
1680
+ else if (this.layerBounds_.has(layer)) {
1681
+ bounds.push(this.layerBounds_.get(layer));
1682
+ }
1683
+ }
1684
+ return bounds;
1685
+ }
1550
1686
  getLayerState() {
1551
1687
  const state = super.getLayerState();
1552
1688
  // Fixes the issue that the view is clipped based on the extent of the layer.
@@ -1562,15 +1698,8 @@ class STACLayer extends LayerGroup {
1562
1698
  * @api
1563
1699
  */
1564
1700
  getAttributions() {
1565
- const attribution = [];
1566
- const stac = this.getData();
1567
- if (stac) {
1568
- const attribution = stac.getMetadata('attribution');
1569
- if (attribution) {
1570
- attribution.push(attribution);
1571
- }
1572
- }
1573
- return attribution;
1701
+ const attribution = this.getAttributionFor_(this.getData());
1702
+ return attribution ? [attribution] : [];
1574
1703
  }
1575
1704
  /**
1576
1705
  * Get the layer source.