Skip to content

Commit

Permalink
Normalise file format name
Browse files Browse the repository at this point in the history
Historical formats use 'GeoTIFF', MTL uses 'GEOTIFF'.
  • Loading branch information
jeremyh committed May 9, 2016
1 parent f277dba commit dc2ed47
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
18 changes: 17 additions & 1 deletion eodatasets/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __init__(self, name=None, type_=None, operation_mode=None):

class FormatMetadata(SimpleObject):
def __init__(self, name=None, version=None):
self.name = name
self.name = _normalise_format_name(name)
self.version = version


Expand Down Expand Up @@ -244,6 +244,22 @@ class PointPolygon(Polygon):
}


def _normalise_format_name(name):
"""
>>> _normalise_format_name('GEOTIFF')
'GeoTIFF'
>>> _normalise_format_name('MD')
'MD'
"""
if not name:
return name

if name.lower() == 'geotiff':
return 'GeoTIFF'

return name


class ExtentMetadata(SimpleObject):
"""
Standardised spatial and temporal information.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ls7_ortho.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_package():
'y': 75, 'x': 88},
'cloud_cover_percentage': 0.0},
'format': {
'name': 'GEOTIFF'
'name': 'GeoTIFF'
},
'lineage': {
'machine': {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ls8_nbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def test_package():
'label': 'Alice Springs'
}
},
'format': {'name': 'GEOTIFF'},
'format': {'name': 'GeoTIFF'},
'lineage': {
'algorithm': {
'name': 'LPGS',
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ls8_ortho.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_package():
'usgs': {
'scene_id': 'LC81120792014026ASA00'
},
'format': {'name': 'GEOTIFF'},
'format': {'name': 'GeoTIFF'},
# Creation date comes from the MTL.
'creation_dt': datetime.datetime(2015, 4, 7, 0, 58, 8),
'platform': {'code': 'LANDSAT_8'},
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ls8_pqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_package():
'product_type': 'ortho',
'creation_dt': datetime.datetime(2015, 4, 7, 3, 25, 59),
'checksum_path': 'package.sha1',
'format': {'name': 'GEOTIFF'},
'format': {'name': 'GeoTIFF'},
'extent': {
'center_dt': datetime.datetime(2014, 7, 26, 23, 49, 0, 343853),
'coord': {
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/mtl/test_ls5_definitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
operation_mode='BUMPER'
),
format_=ptype.FormatMetadata(
name='GEOTIFF'
name='GeoTIFF'
),
acquisition=ptype.AcquisitionMetadata(
groundstation=ptype.GroundstationMetadata(
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/mtl/test_ls7_definitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
operation_mode='SAM'
),
format_=ptype.FormatMetadata(
name='GEOTIFF'
name='GeoTIFF'
),
acquisition=ptype.AcquisitionMetadata(
groundstation=ptype.GroundstationMetadata(
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/mtl/test_ls8.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
name='OLI_TIRS'
),
format_=ptype.FormatMetadata(
name='GEOTIFF'
name='GeoTIFF'
),
acquisition=ptype.AcquisitionMetadata(
groundstation=ptype.GroundstationMetadata(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def test_deserialize_dataset(self):
'lr': {'lat': -26.99055, 'lon': 136.25985},
'ul': {'lat': -24.98805, 'lon': 133.97954},
'ur': {'lat': -24.9864, 'lon': 136.23866}}},
'format': {'name': 'GEOTIFF'},
'format': {'name': 'GeoTIFF'},
'usgs': {
'interval_id': 'LC81010782014285LGN00'
},
Expand Down

0 comments on commit dc2ed47

Please sign in to comment.