Skip to content

Commit

Permalink
prefix "eodash:" for client-only custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lubojr committed Jul 18, 2024
1 parent 5b1769c commit 3d49c6c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
52 changes: 26 additions & 26 deletions src/eodash_catalog/generate_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,64 +196,64 @@ def process_collection_file(
with open(file_path) as f:
collection_config: dict = yaml.load(f, Loader=SafeLoader)
if "Resources" in collection_config:
for resource in collection_config["Resources"]:
for endpoint_config in collection_config["Resources"]:
collection = None
if resource["Name"] == "Sentinel Hub":
if endpoint_config["Name"] == "Sentinel Hub":
collection = handle_SH_endpoint(
catalog_config, resource, collection_config, catalog, options
catalog_config, endpoint_config, collection_config, catalog, options
)
elif resource["Name"] == "Sentinel Hub WMS":
elif endpoint_config["Name"] == "Sentinel Hub WMS":
collection = handle_SH_WMS_endpoint(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
elif resource["Name"] == "GeoDB":
elif endpoint_config["Name"] == "GeoDB":
collection = handle_GeoDB_endpoint(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
elif resource["Name"] == "VEDA":
elif endpoint_config["Name"] == "VEDA":
collection = handle_VEDA_endpoint(
catalog_config, resource, collection_config, catalog, options
catalog_config, endpoint_config, collection_config, catalog, options
)
elif resource["Name"] == "marinedatastore":
elif endpoint_config["Name"] == "marinedatastore":
collection = handle_WMS_endpoint(
catalog_config, resource, collection_config, catalog, wmts=True
catalog_config, endpoint_config, collection_config, catalog, wmts=True
)
elif resource["Name"] == "xcube":
elif endpoint_config["Name"] == "xcube":
collection = handle_xcube_endpoint(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
elif resource["Name"] == "WMS":
elif endpoint_config["Name"] == "WMS":
collection = handle_WMS_endpoint(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
elif resource["Name"] == "JAXA_WMTS_PALSAR":
elif endpoint_config["Name"] == "JAXA_WMTS_PALSAR":
# somewhat one off creation of individual WMTS layers as individual items
collection = handle_WMS_endpoint(
catalog_config, resource, collection_config, catalog, wmts=True
catalog_config, endpoint_config, collection_config, catalog, wmts=True
)
elif resource["Name"] == "Collection-only":
elif endpoint_config["Name"] == "Collection-only":
collection = handle_collection_only(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
elif resource["Name"] == "Custom-Endpoint":
elif endpoint_config["Name"] == "Custom-Endpoint":
collection = handle_custom_endpoint(
catalog_config,
resource,
endpoint_config,
collection_config,
catalog,
)
elif resource["Name"] in ["COG source", "GeoJSON source"]:
elif endpoint_config["Name"] in ["COG source", "GeoJSON source"]:
collection = handle_raw_source(
catalog_config, resource, collection_config, catalog
catalog_config, endpoint_config, collection_config, catalog
)
else:
raise ValueError("Type of Resource is not supported")
if collection:
add_single_item_if_collection_empty(collection)
add_projection_info(resource, collection)
add_to_catalog(collection, catalog, resource, collection_config)
add_projection_info(endpoint_config, collection)
add_to_catalog(collection, catalog, endpoint_config, collection_config)
else:
raise Exception(f"No collection was generated for resource {resource}")
raise Exception(f"No collection was generated for resource {endpoint_config}")
elif "Subcollections" in collection_config:
# if no endpoint is specified we check for definition of subcollections
parent_collection = get_or_create_collection(
Expand Down
4 changes: 2 additions & 2 deletions src/eodash_catalog/stac_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def add_extra_fields(stac_object: Collection | Catalog | Link, collection_config
if "Other" in collection_config["DataSource"]:
stac_object.extra_fields["otherSources"] = collection_config["DataSource"]["Other"]
if "MapProjection" in collection_config:
stac_object.extra_fields["mapProjection"] = collection_config["MapProjection"]
stac_object.extra_fields["eodash:mapProjection"] = collection_config["MapProjection"]


def get_collection_times_from_config(endpoint_config: dict) -> list[str]:
Expand Down Expand Up @@ -416,6 +416,6 @@ def add_projection_info(
# so we are taking over the DataProjection as is and deal with it in the eodash client
# in a non-standard compliant way
# https://github.com/proj4js/proj4js/issues/400
stac_object.extra_fields["proj4_def"] = proj
stac_object.extra_fields["eodash:proj4_def"] = proj
else:
raise Exception(f"Incorrect type of proj definition {proj}")
4 changes: 2 additions & 2 deletions tests/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_indicator_map_projection_added(catalog_output_folder):
with open(os.path.join(root_collection_path, "collection.json")) as fp:
indicator_json = json.load(fp)
# test that collection has map projection defined
assert indicator_json["mapProjection"] == 3035
assert indicator_json["eodash:mapProjection"] == 3035


def test_baselayers_and_overlays_added(catalog_output_folder):
Expand Down Expand Up @@ -184,4 +184,4 @@ def test_baselayer_with_custom_projection_added(catalog_output_folder):
# overwrites default_baselayers, so there is just 1
assert len(baselayer_links) == 1
# test that custom proj4 definition is added to link
assert baselayer_links[0]["proj4_def"]["name"] == "ORTHO:680500"
assert baselayer_links[0]["eodash:proj4_def"]["name"] == "ORTHO:680500"

0 comments on commit 3d49c6c

Please sign in to comment.