Skip to content

Commit

Permalink
added reference lid to pds4 labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Anikiej committed Aug 6, 2024
1 parent ce056b4 commit 76801ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@
<encoding_standard_id>{{encoding_standard}}</encoding_standard_id>
</Encoded_External>
</File_Area_External>

<Reference_List>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:target:satellite.earth.moon</lid_reference>
<reference_type>data_to_target</reference_type>
</Internal_Reference>
</Reference_List>

</Product_External>
18 changes: 17 additions & 1 deletion src/pds/registry/utils/treks/product_service_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def __init__(self, data, target, save_xml=False, dest="xml_files", verbose=False

# get target info
self.target_type = None
self.target_lid = None
try:
name = self.target.capitalize()
pds_query_url = \
f"https://pds.nasa.gov/api/search/1/products?q=(pds:Target.pds:name%20eq%20%22{name}%22)"
response = requests.get(pds_query_url, timeout=30)
# search type of first hit
self.target_type = response.json()["data"][0]["properties"]["pds:Target.pds:type"][0]
self.target_lid = response.json()["data"][0]["properties"]["lid"][0]

except Exception:
if self.verbose:
Expand All @@ -51,7 +53,7 @@ def create_pds4_xml(self):
identification_area, lidvid = self.create_identification_area()
observation_area = self.create_observation_area()
service = self.create_service()
# TODO: add reference list?
reference_list = self.create_reference_list()

# create root
root = Et.Element("Product_Service")
Expand All @@ -71,6 +73,7 @@ def create_pds4_xml(self):
root.append(identification_area)
root.append(observation_area)
root.append(service)
root.append(reference_list)

tree = Et.ElementTree(root)

Expand Down Expand Up @@ -389,6 +392,19 @@ def create_service(self):

return service

def create_reference_list(self):
"""Creates Reference_Area for pds4 labeel.
:return: Reference_List section of pds4 xml
"""
reference_list = Et.Element("Reference_List")

internal_reference = Et.SubElement(reference_list, "Internal_Reference")
Et.SubElement(internal_reference, "lid_reference").text = self.target_lid
Et.SubElement(internal_reference, "reference_type").text = "data_to_target"

return reference_list

def get_fgdc(self):
"""Utility function to get fgdc metadata xml.
Expand Down

0 comments on commit 76801ec

Please sign in to comment.