Skip to content

Commit

Permalink
Add gco:useLimitation element
Browse files Browse the repository at this point in the history
  • Loading branch information
benjwadams committed Feb 19, 2024
1 parent 3b7fa0f commit d21678b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ckanext/spatial/harvested_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,35 @@ def get_values(self, elements):
return values


class ISOUseLimitations(ISOElement):
'''
For gmd:MD_UseLimitations
'''
def __init__(self, name, search_paths=[], multiplicity="*", elements=[]):
ISOElement.__init__(self, name, search_paths, multiplicity, elements)

def get_values(self, elements):
'''
If the restriction code is set to otherRestrictions, pull the text
string from gmd:otherConstraints, otherwise use the
gmd:MD_RestrictionCode
'''
values = []
for element in elements:
# if the node is text, instead of XML, just return the text node
if isinstance(element, str):
values.append(element)
continue
use_limitations = element.xpath("./gmd:useLimitation",
namespaces=self.namespaces)
if use_limitations:
for use_limitation in use_limitations:
value = use_limitation.xpath("./gco:CharacterString/text()",
namespaces=self.namespaces)
values.extend(value)
return values


class ISOAggregationInfo(ISOElement):

elements = [
Expand Down Expand Up @@ -863,6 +892,13 @@ class ISODocument(MappedXmlDocument):
],
multiplicity='*'
),
ISOUseLimitations(
name="use-limitations",
search_paths=[
"gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints",
],
multiplicity='*'
),
ISOAggregationInfo(
name="aggregation-info",
search_paths=[
Expand Down

0 comments on commit d21678b

Please sign in to comment.