eodash_catalog 0.0.27__py3-none-any.whl → 0.0.29__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.

@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Daniel Santillan <daniel.santillan@eox.at>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.0.27"
4
+ __version__ = "0.0.29"
@@ -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, timezone
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,
@@ -527,20 +532,7 @@ def handle_WMS_endpoint(
527
532
  )
528
533
  # optionally filter time results
529
534
  if query := endpoint_config.get("Query"):
530
- datetime_query = [
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
- ]
535
+ times = filter_time_entries(times, query)
544
536
  # Create an item per time to allow visualization in stac clients
545
537
  if len(times) > 0:
546
538
  for t in times:
@@ -574,7 +566,7 @@ def handle_WMS_endpoint(
574
566
 
575
567
 
576
568
  def generate_veda_tiles_link(endpoint_config: dict, item: str | None) -> str:
577
- collection = "collection={}".format(endpoint_config["CollectionId"])
569
+ collection = endpoint_config["CollectionId"]
578
570
  assets = ""
579
571
  for asset in endpoint_config["Assets"]:
580
572
  assets += f"&assets={asset}"
@@ -584,8 +576,8 @@ def generate_veda_tiles_link(endpoint_config: dict, item: str | None) -> str:
584
576
  no_data = ""
585
577
  if "NoData" in endpoint_config:
586
578
  no_data = "&no_data={}".format(endpoint_config["NoData"])
587
- item = f"&item={item}" if item else ""
588
- target_url = f"https://openveda.cloud/api/raster/stac/tiles/WebMercatorQuad/{{z}}/{{x}}/{{y}}?{collection}{item}{assets}{color_formula}{no_data}"
579
+ item = item if item else "{item}"
580
+ target_url = f"https://openveda.cloud/api/raster/collections/{collection}/items/{item}/tiles/WebMercatorQuad/{{z}}/{{x}}/{{y}}?{assets}{color_formula}{no_data}"
589
581
  return target_url
590
582
 
591
583
 
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.27
3
+ Version: 0.0.29
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
@@ -1,14 +1,14 @@
1
- eodash_catalog/__about__.py,sha256=bsufHVYvcGAaEqZ-VbCVPXCXjTYF4YBFZ8XQRpAR5QQ,138
1
+ eodash_catalog/__about__.py,sha256=b4oiVp9QoxhxuwZjnnNaBjZ7HyycZmuA6hHWdt8ZIXU,138
2
2
  eodash_catalog/__init__.py,sha256=_W_9emPYf6FUqc0P8L2SmADx6hGSd7PlQV3yRmCk5uM,115
3
3
  eodash_catalog/duration.py,sha256=B6XOZfvNU7SuqpxuVtT1kNKODoOQJXDI6mocvA_U1ik,10816
4
- eodash_catalog/endpoints.py,sha256=vldV3ojAQ9s_nsCM_ItFHIaHiELlhn4tvX-F3w0HbT4,35364
4
+ eodash_catalog/endpoints.py,sha256=ijiOad7mdb1oFgTzAPWty9XVK2a4jjtKcJXEeH03UHY,34938
5
5
  eodash_catalog/generate_indicators.py,sha256=0IHhu_0yOUoUtLqiTsoYQ2IrTrq00yZme3UE6pC9PIU,19772
6
6
  eodash_catalog/sh_endpoint.py,sha256=F99LpYT-MGhPiwdSSysm3xBTjaQBXRUkieh-q-vhTvE,1012
7
7
  eodash_catalog/stac_handling.py,sha256=AHV9BLzYcHzUprX42b-yjVvN8TERymWF_iZQruFMQlY,18414
8
8
  eodash_catalog/thumbnails.py,sha256=31Wk38oNQDxfhSUbMLBpHuZFhsR8v_7luYr65XQtDf0,2213
9
- eodash_catalog/utils.py,sha256=GmRypfWP8XlYqldJJCRLXAYlF6ovRJcPs-Ms8M91llw,10309
10
- eodash_catalog-0.0.27.dist-info/METADATA,sha256=Q3kSlyimqUyfVifa4wQMc4rXPhi_qS72eNxX2iWJbU0,3203
11
- eodash_catalog-0.0.27.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
12
- eodash_catalog-0.0.27.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
13
- eodash_catalog-0.0.27.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
14
- eodash_catalog-0.0.27.dist-info/RECORD,,
9
+ eodash_catalog/utils.py,sha256=sW1YKOaDBFM3rkx458NIG8KGq8kuwGKjTvWhb2-y808,11044
10
+ eodash_catalog-0.0.29.dist-info/METADATA,sha256=37udKFOHd7Vao0V9C5KqQmmXPhi2mpj2Jy6HSjU9y8o,3203
11
+ eodash_catalog-0.0.29.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
12
+ eodash_catalog-0.0.29.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
13
+ eodash_catalog-0.0.29.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
14
+ eodash_catalog-0.0.29.dist-info/RECORD,,