eodash_catalog 0.0.28__py3-none-any.whl → 0.0.30__py3-none-any.whl
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.
Potentially problematic release.
This version of eodash_catalog might be problematic. Click here for more details.
- eodash_catalog/__about__.py +1 -1
- eodash_catalog/endpoints.py +46 -24
- eodash_catalog/stac_handling.py +2 -2
- eodash_catalog/utils.py +19 -1
- {eodash_catalog-0.0.28.dist-info → eodash_catalog-0.0.30.dist-info}/METADATA +1 -1
- eodash_catalog-0.0.30.dist-info/RECORD +14 -0
- eodash_catalog-0.0.28.dist-info/RECORD +0 -14
- {eodash_catalog-0.0.28.dist-info → eodash_catalog-0.0.30.dist-info}/WHEEL +0 -0
- {eodash_catalog-0.0.28.dist-info → eodash_catalog-0.0.30.dist-info}/entry_points.txt +0 -0
- {eodash_catalog-0.0.28.dist-info → eodash_catalog-0.0.30.dist-info}/licenses/LICENSE.txt +0 -0
eodash_catalog/__about__.py
CHANGED
eodash_catalog/endpoints.py
CHANGED
|
@@ -4,7 +4,7 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
import uuid
|
|
6
6
|
from collections.abc import Callable
|
|
7
|
-
from datetime import datetime, timedelta
|
|
7
|
+
from datetime import datetime, timedelta
|
|
8
8
|
from itertools import groupby
|
|
9
9
|
from operator import itemgetter
|
|
10
10
|
|
|
@@ -27,6 +27,7 @@ from eodash_catalog.utils import (
|
|
|
27
27
|
Options,
|
|
28
28
|
create_geojson_from_bbox,
|
|
29
29
|
create_geojson_point,
|
|
30
|
+
filter_time_entries,
|
|
30
31
|
generate_veda_cog_link,
|
|
31
32
|
replace_with_env_variables,
|
|
32
33
|
retrieveExtentFromWMSWMTS,
|
|
@@ -69,6 +70,10 @@ def process_STAC_Datacube_Endpoint(
|
|
|
69
70
|
time_dimension = k
|
|
70
71
|
break
|
|
71
72
|
time_entries = dimensions.get(time_dimension).get("values")
|
|
73
|
+
# optionally subset time results based on config
|
|
74
|
+
if query := endpoint_config.get("Query"):
|
|
75
|
+
time_entries = filter_time_entries(time_entries, query)
|
|
76
|
+
|
|
72
77
|
for t in time_entries:
|
|
73
78
|
item = Item(
|
|
74
79
|
id=t,
|
|
@@ -322,10 +327,10 @@ def handle_SH_WMS_endpoint(
|
|
|
322
327
|
catalog_config: dict, endpoint_config: dict, collection_config: dict, catalog: Catalog
|
|
323
328
|
) -> Collection:
|
|
324
329
|
# create collection and subcollections (based on locations)
|
|
330
|
+
root_collection = get_or_create_collection(
|
|
331
|
+
catalog, collection_config["Name"], collection_config, catalog_config, endpoint_config
|
|
332
|
+
)
|
|
325
333
|
if "Locations" in collection_config:
|
|
326
|
-
root_collection = get_or_create_collection(
|
|
327
|
-
catalog, collection_config["Name"], collection_config, catalog_config, endpoint_config
|
|
328
|
-
)
|
|
329
334
|
for location in collection_config["Locations"]:
|
|
330
335
|
# create and populate location collections based on times
|
|
331
336
|
# TODO: Should we add some new description per location?
|
|
@@ -368,6 +373,26 @@ def handle_SH_WMS_endpoint(
|
|
|
368
373
|
for c_child in root_collection.get_children():
|
|
369
374
|
if isinstance(c_child, Collection):
|
|
370
375
|
root_collection.extent.spatial.bboxes.append(c_child.extent.spatial.bboxes[0])
|
|
376
|
+
else:
|
|
377
|
+
# if locations are not provided, treat the collection as a
|
|
378
|
+
# general proxy to the sentinel hub layer
|
|
379
|
+
times = get_collection_times_from_config(endpoint_config)
|
|
380
|
+
bbox = endpoint_config.get("Bbox", [-180, -85, 180, 85])
|
|
381
|
+
for time in times:
|
|
382
|
+
item = Item(
|
|
383
|
+
id=time,
|
|
384
|
+
bbox=bbox,
|
|
385
|
+
properties={},
|
|
386
|
+
geometry=None,
|
|
387
|
+
datetime=parser.isoparse(time),
|
|
388
|
+
stac_extensions=[
|
|
389
|
+
"https://stac-extensions.github.io/web-map-links/v1.1.0/schema.json",
|
|
390
|
+
],
|
|
391
|
+
)
|
|
392
|
+
add_projection_info(endpoint_config, item)
|
|
393
|
+
add_visualization_info(item, collection_config, endpoint_config, time=time)
|
|
394
|
+
item_link = root_collection.add_item(item)
|
|
395
|
+
item_link.extra_fields["datetime"] = time
|
|
371
396
|
# eodash v4 compatibility
|
|
372
397
|
add_collection_information(catalog_config, root_collection, collection_config)
|
|
373
398
|
add_visualization_info(root_collection, collection_config, endpoint_config)
|
|
@@ -527,20 +552,7 @@ def handle_WMS_endpoint(
|
|
|
527
552
|
)
|
|
528
553
|
# optionally filter time results
|
|
529
554
|
if query := endpoint_config.get("Query"):
|
|
530
|
-
|
|
531
|
-
parser.isoparse(times[0]).replace(tzinfo=timezone.utc),
|
|
532
|
-
parser.isoparse(times[-1]).replace(tzinfo=timezone.utc),
|
|
533
|
-
]
|
|
534
|
-
if start := query.get("Start"):
|
|
535
|
-
datetime_query[0] = parser.isoparse(start).replace(tzinfo=timezone.utc)
|
|
536
|
-
if end := query.get("End"):
|
|
537
|
-
datetime_query[1] = parser.isoparse(end).replace(tzinfo=timezone.utc)
|
|
538
|
-
# filter times based on query Start/End
|
|
539
|
-
times = [
|
|
540
|
-
datetime_str
|
|
541
|
-
for datetime_str in times
|
|
542
|
-
if datetime_query[0] <= parser.isoparse(datetime_str) < datetime_query[1]
|
|
543
|
-
]
|
|
555
|
+
times = filter_time_entries(times, query)
|
|
544
556
|
# Create an item per time to allow visualization in stac clients
|
|
545
557
|
if len(times) > 0:
|
|
546
558
|
for t in times:
|
|
@@ -614,16 +626,22 @@ def add_visualization_info(
|
|
|
614
626
|
"role": ["data"],
|
|
615
627
|
}
|
|
616
628
|
)
|
|
629
|
+
dimensions = {}
|
|
630
|
+
if dimensions_config := endpoint_config.get("Dimensions", {}):
|
|
631
|
+
for key, value in dimensions_config.items():
|
|
632
|
+
dimensions[key] = value
|
|
617
633
|
if time is not None:
|
|
618
634
|
if endpoint_config["Name"] == "Sentinel Hub WMS":
|
|
619
635
|
# SH WMS for public collections needs time interval, we use full day here
|
|
620
|
-
datetime_object = datetime.
|
|
636
|
+
datetime_object = datetime.fromisoformat(time)
|
|
621
637
|
start = datetime_object.isoformat()
|
|
622
638
|
end = (datetime_object + timedelta(days=1) - timedelta(milliseconds=1)).isoformat()
|
|
623
639
|
time_interval = f"{start}/{end}"
|
|
624
|
-
|
|
640
|
+
dimensions["TIME"] = time_interval
|
|
625
641
|
if endpoint_config["Name"] == "Sentinel Hub":
|
|
626
|
-
|
|
642
|
+
dimensions["TIME"] = time
|
|
643
|
+
if dimensions != {}:
|
|
644
|
+
extra_fields["wms:dimensions"] = dimensions
|
|
627
645
|
stac_object.add_link(
|
|
628
646
|
Link(
|
|
629
647
|
rel="wms",
|
|
@@ -640,10 +658,14 @@ def add_visualization_info(
|
|
|
640
658
|
"role": ["data"],
|
|
641
659
|
}
|
|
642
660
|
)
|
|
661
|
+
dimensions = {}
|
|
662
|
+
if dimensions_config := endpoint_config.get("Dimensions", {}):
|
|
663
|
+
for key, value in dimensions_config.items():
|
|
664
|
+
dimensions[key] = value
|
|
643
665
|
if time is not None:
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
666
|
+
dimensions["TIME"] = time
|
|
667
|
+
if dimensions != {}:
|
|
668
|
+
extra_fields["wms:dimensions"] = dimensions
|
|
647
669
|
if "Styles" in endpoint_config:
|
|
648
670
|
extra_fields["wms:styles"] = endpoint_config["Styles"]
|
|
649
671
|
media_type = endpoint_config.get("MediaType", "image/jpeg")
|
eodash_catalog/stac_handling.py
CHANGED
|
@@ -44,7 +44,7 @@ def get_or_create_collection(
|
|
|
44
44
|
)
|
|
45
45
|
times: list[str] = []
|
|
46
46
|
temporal_extent = TemporalExtent([[datetime.now(), None]])
|
|
47
|
-
if endpoint_config
|
|
47
|
+
if endpoint_config:
|
|
48
48
|
if endpoint_config.get("Times"):
|
|
49
49
|
times = list(endpoint_config.get("Times", []))
|
|
50
50
|
times_datetimes = sorted([parser.isoparse(time) for time in times])
|
|
@@ -389,7 +389,7 @@ def add_extra_fields(stac_object: Collection | Link, collection_config: dict) ->
|
|
|
389
389
|
|
|
390
390
|
def get_collection_times_from_config(endpoint_config: dict) -> list[str]:
|
|
391
391
|
times: list[str] = []
|
|
392
|
-
if endpoint_config
|
|
392
|
+
if endpoint_config:
|
|
393
393
|
if endpoint_config.get("Times"):
|
|
394
394
|
times = list(endpoint_config.get("Times", []))
|
|
395
395
|
elif endpoint_config.get("DateTimeInterval"):
|
eodash_catalog/utils.py
CHANGED
|
@@ -5,7 +5,7 @@ import time
|
|
|
5
5
|
import uuid
|
|
6
6
|
from collections.abc import Iterator
|
|
7
7
|
from dataclasses import dataclass
|
|
8
|
-
from datetime import datetime, timedelta
|
|
8
|
+
from datetime import datetime, timedelta, timezone
|
|
9
9
|
from decimal import Decimal
|
|
10
10
|
from functools import reduce, wraps
|
|
11
11
|
from typing import Any
|
|
@@ -307,3 +307,21 @@ def retry(exceptions, tries=3, delay=2, backoff=1, logger=None):
|
|
|
307
307
|
return wrapper
|
|
308
308
|
|
|
309
309
|
return decorator
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def filter_time_entries(time_entries: list[str], query: dict[str, str]) -> list[str]:
|
|
313
|
+
datetime_query = [
|
|
314
|
+
parser.isoparse(time_entries[0]).replace(tzinfo=timezone.utc),
|
|
315
|
+
parser.isoparse(time_entries[-1]).replace(tzinfo=timezone.utc),
|
|
316
|
+
]
|
|
317
|
+
if start := query.get("Start"):
|
|
318
|
+
datetime_query[0] = parser.isoparse(start).replace(tzinfo=timezone.utc)
|
|
319
|
+
if end := query.get("End"):
|
|
320
|
+
datetime_query[1] = parser.isoparse(end).replace(tzinfo=timezone.utc)
|
|
321
|
+
# filter times based on query Start/End
|
|
322
|
+
time_entries = [
|
|
323
|
+
datetime_str
|
|
324
|
+
for datetime_str in time_entries
|
|
325
|
+
if datetime_query[0] <= parser.isoparse(datetime_str) < datetime_query[1]
|
|
326
|
+
]
|
|
327
|
+
return time_entries
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: eodash_catalog
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.30
|
|
4
4
|
Summary: This package is intended to help create a compatible STAC catalog for the eodash dashboard client. It supports configuration of multiple endpoint types for information extraction.
|
|
5
5
|
Project-URL: Documentation, https://github.com/eodash/eodash_catalog#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/eodash/eodash_catalog/issues
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
eodash_catalog/__about__.py,sha256=jhzZSQrCp7KQrReK8FJfif9ZfKLYZXTUzAui64xJkDs,138
|
|
2
|
+
eodash_catalog/__init__.py,sha256=_W_9emPYf6FUqc0P8L2SmADx6hGSd7PlQV3yRmCk5uM,115
|
|
3
|
+
eodash_catalog/duration.py,sha256=B6XOZfvNU7SuqpxuVtT1kNKODoOQJXDI6mocvA_U1ik,10816
|
|
4
|
+
eodash_catalog/endpoints.py,sha256=ZMjPBPpSsgr-0PDfadD0TCkECxoua6kYCzOnTtfNG78,36257
|
|
5
|
+
eodash_catalog/generate_indicators.py,sha256=0IHhu_0yOUoUtLqiTsoYQ2IrTrq00yZme3UE6pC9PIU,19772
|
|
6
|
+
eodash_catalog/sh_endpoint.py,sha256=F99LpYT-MGhPiwdSSysm3xBTjaQBXRUkieh-q-vhTvE,1012
|
|
7
|
+
eodash_catalog/stac_handling.py,sha256=lipa0_zGdVeTe4eiVcUQKejz4iJ87z7bIyuyxCVwj50,18310
|
|
8
|
+
eodash_catalog/thumbnails.py,sha256=31Wk38oNQDxfhSUbMLBpHuZFhsR8v_7luYr65XQtDf0,2213
|
|
9
|
+
eodash_catalog/utils.py,sha256=sW1YKOaDBFM3rkx458NIG8KGq8kuwGKjTvWhb2-y808,11044
|
|
10
|
+
eodash_catalog-0.0.30.dist-info/METADATA,sha256=UCh3ufTL0kTABl2aWGVWEtSvG3HxJVyszXQgp2xxB1U,3203
|
|
11
|
+
eodash_catalog-0.0.30.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
12
|
+
eodash_catalog-0.0.30.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
|
|
13
|
+
eodash_catalog-0.0.30.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
|
|
14
|
+
eodash_catalog-0.0.30.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
eodash_catalog/__about__.py,sha256=eUPbOifB9Bv_vaPkbS7mfoJNKWtqw3Syp0TZbPe5RZk,138
|
|
2
|
-
eodash_catalog/__init__.py,sha256=_W_9emPYf6FUqc0P8L2SmADx6hGSd7PlQV3yRmCk5uM,115
|
|
3
|
-
eodash_catalog/duration.py,sha256=B6XOZfvNU7SuqpxuVtT1kNKODoOQJXDI6mocvA_U1ik,10816
|
|
4
|
-
eodash_catalog/endpoints.py,sha256=y3g4uSmKI0-jixlqaeLPMRvfNDLn4xtJxMADhuT5aT0,35350
|
|
5
|
-
eodash_catalog/generate_indicators.py,sha256=0IHhu_0yOUoUtLqiTsoYQ2IrTrq00yZme3UE6pC9PIU,19772
|
|
6
|
-
eodash_catalog/sh_endpoint.py,sha256=F99LpYT-MGhPiwdSSysm3xBTjaQBXRUkieh-q-vhTvE,1012
|
|
7
|
-
eodash_catalog/stac_handling.py,sha256=AHV9BLzYcHzUprX42b-yjVvN8TERymWF_iZQruFMQlY,18414
|
|
8
|
-
eodash_catalog/thumbnails.py,sha256=31Wk38oNQDxfhSUbMLBpHuZFhsR8v_7luYr65XQtDf0,2213
|
|
9
|
-
eodash_catalog/utils.py,sha256=GmRypfWP8XlYqldJJCRLXAYlF6ovRJcPs-Ms8M91llw,10309
|
|
10
|
-
eodash_catalog-0.0.28.dist-info/METADATA,sha256=b3qjQ4YFsBarXMrX-bVC4xqkT13QQij-uIsfuFk2KR0,3203
|
|
11
|
-
eodash_catalog-0.0.28.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
12
|
-
eodash_catalog-0.0.28.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
|
|
13
|
-
eodash_catalog-0.0.28.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
|
|
14
|
-
eodash_catalog-0.0.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|