Coverage validation to account for different bounding box co-ordinate names
@@ -1576,7 +1576,7 @@ class Coverage(AbstractMetaDataElement):
graph.add((coverage, RDF.value, Literal(value_string)))
@classmethod
- def validate_coverage_type_value_attributes(cls, coverage_type, value_dict):
+ def validate_coverage_type_value_attributes(cls, coverage_type, value_dict, use_limit_postfix=True):
"""Validate values based on coverage type."""
def compute_longitude(key_name):
if value_dict[key_name] <= -180 and value_dict[key_name] >= -360:
@@ -1612,7 +1612,12 @@ class Coverage(AbstractMetaDataElement):
elif coverage_type == 'box':
# check that all the required sub-elements exist
- for value_item in ['units', 'northlimit', 'eastlimit', 'southlimit', 'westlimit']:
+ box_key_names = {'north': 'north', 'east': 'east', 'south': 'south', 'west': 'west'}
+ if use_limit_postfix:
+ for key, value in box_key_names.items():
+ box_key_names[key] = f"{value}limit"
+ required_keys = list(box_key_names.values()) + ['units']
+ for value_item in required_keys:
if value_item not in value_dict:
raise ValidationError("For coverage of type 'box' values for one or more "
"bounding box limits or 'units' is missing.")
@@ -1624,22 +1629,22 @@ class Coverage(AbstractMetaDataElement):
raise ValidationError("Value for '{}' must be numeric"
.format(value_item))
- if value_dict['northlimit'] < -90 or value_dict['northlimit'] > 90:
+ if value_dict[box_key_names['north']] < -90 or value_dict[box_key_names['north']] > 90:
raise ValidationError("Value for North latitude should be "
"in the range of -90 to 90")
- if value_dict['southlimit'] < -90 or value_dict['southlimit'] > 90:
+ if value_dict[box_key_names['south']] < -90 or value_dict[box_key_names['south']] > 90:
raise ValidationError("Value for South latitude should be "
"in the range of -90 to 90")
- if (value_dict['northlimit'] < 0 and value_dict['southlimit'] < 0) or (
- value_dict['northlimit'] > 0 and value_dict['southlimit'] > 0):
- if value_dict['northlimit'] < value_dict['southlimit']:
+ if (value_dict[box_key_names['north']] < 0 and value_dict[box_key_names['south']] < 0) or (
+ value_dict[box_key_names['north']] > 0 and value_dict[box_key_names['south']] > 0):
+ if value_dict[box_key_names['north']] < value_dict[box_key_names['south']]:
raise ValidationError("Value for North latitude must be greater than or "
"equal to that of South latitude.")
- compute_longitude(key_name='eastlimit')
- compute_longitude(key_name='westlimit')
+ compute_longitude(key_name=box_key_names['east'])
+ compute_longitude(key_name=box_key_names['west'])
def get_html(self, pretty=True):
"""Use the dominate module to generate element display HTML.
