Skip to content

Commit

Permalink
fix to make gis scripts work in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas loubrieu committed Sep 10, 2024
1 parent 6db80da commit 5c5eb5e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ES_DISCOVERY_TYPE=single-node
# --------------------------------------------------------------------

# Docker image of the Registry API
REG_API_IMAGE=nasapds/registry-api-service:latest
REG_API_IMAGE=nasapds/registry-api-service:1.5.0

# Absolute path of the application.properties file to be used for the Registry API
REG_API_APP_PROPERTIES_FILE=./default-config/application.properties
Expand Down
24 changes: 16 additions & 8 deletions src/pds/registry/utils/geostac/create_lola_pds4.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Script to scrape GeoSTAC for Lola point clouds and make pds4 xml."""
import argparse
import importlib
import os
from datetime import date
from pathlib import Path

Expand Down Expand Up @@ -53,7 +54,7 @@ def create_reference_list(item):
bbox1 = [bb_west, bb_south, bb_east, bb_north]

# needs to be updated with the collection we want to check for overlapping bounding boxes with
url = "http://localhost:8080/products/urn:nasa:pds:lro_lola_rdr:data_gridded::1.0/members"
url = "http://pds.nasa.gov/api/search/1/products/urn:nasa:pds:lro_lola_rdr:data_gridded::1.0/members"
response = requests.get(url, timeout=30)
json_data = response.json()

Expand Down Expand Up @@ -82,15 +83,16 @@ def create_product_external(item):
"""
# create env
env = Environment()

with importlib.resources.open_text(templates, "product-external-template.xml") as io:
template_text = io.read()
template = env.from_string(template_text)

item_title = item["assets"]["data"]["title"]

last_slash_i = item["assets"]["data"]["href"].rfind("/")
file = item["assets"]["data"]["href"][last_slash_i + 1:]
file = "data/" +item["assets"]["data"]["href"][last_slash_i + 1:]
print(f'file is on {item["assets"]["data"]["href"]},fake file is on {file}')
open("lola_xml/product_external/" + file, 'a').close()

# fill out template params
lid = "urn:nasa:pds:geostac:external:" + item_title.lower()
Expand Down Expand Up @@ -147,7 +149,10 @@ def create_product_browse(item):
item_title = item["assets"]["data"]["title"]

last_slash_i = item["assets"]["thumbnail"]["href"].rfind("/")
file = item["assets"]["thumbnail"]["href"][last_slash_i + 1:]
file = "data/" + item["assets"]["thumbnail"]["href"][last_slash_i + 1:]
print(f'file is on {item["assets"]["thumbnail"]["href"]},fake file is on {file}')
open("lola_xml/product_browse/" + file, 'a').close()

data_type = item["assets"]["thumbnail"]["type"]
encoding_map = {"image/jpeg": "JPEG"}

Expand Down Expand Up @@ -210,15 +215,18 @@ def main():
json_data = response.json()
features = json_data["features"]

if save_xml:
# create destination directoru if they don't exist
Path(dest + "/product_external").mkdir(parents=True, exist_ok=True)
Path(dest + "/product_external/data").mkdir(parents=True, exist_ok=True)
Path(dest + "/product_browse").mkdir(parents=True, exist_ok=True)
Path(dest + "/product_browse/data").mkdir(parents=True, exist_ok=True)

for item in features:
external_pds4 = create_product_external(item)
browse_pds4 = create_product_browse(item)

if save_xml:
# create destination directoru if they don't exist
Path(dest + "/product_external").mkdir(parents=True, exist_ok=True)
Path(dest + "/product_browse").mkdir(parents=True, exist_ok=True)

ex_path = dest + "/product_external/" + item["assets"]["data"]["title"] + "_product_external.xml"
with open(ex_path, "w") as f:
f.write(external_pds4)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml-model
href="https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1L00.sch" schematypens="http://purl.oclc.org/dsdl/schematron"
?>
<Product_Browse>
<Product_Browse
xmlns="http://pds.nasa.gov/pds4/pds/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pds.nasa.gov/pds4/pds/v1 https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1M00.xsd">
<Identification_Area>
<logical_identifier>
{{lid|e}}
Expand Down

0 comments on commit 5c5eb5e

Please sign in to comment.