Commit 4e1c9426 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Some adjustments to current code.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent f3f8fd26
Pipeline #8049 failed with stage
in 18 minutes and 26 seconds
......@@ -571,7 +571,7 @@ def dump_all_SRFs(outpath_dump=os.path.abspath(os.path.join(os.path.dirname(__fi
['ASTER_VNIR1', 'ASTER_VNIR2', 'ASTER_SWIR', 'ASTER_TIR', 'LANDSAT_TM5', 'LANDSAT_TM7', 'LANDSAT_LDCM',
'RapidEye_5', 'Spot_1', 'Spot_4', 'Spot_5']):
out_dict[out_sensorcode] = SRF_Reader(sensorcode, logger)
out_dict[out_sensorcode] = SRF_Reader(sensorcode)
with open(outpath_dump, 'wb') as outFile:
pickle.dump(out_dict, outFile)
......@@ -600,7 +600,7 @@ class GMSObjWriter(object):
"""Base class for writing GMS objects."""
def __init__(self, GMSObj, is_tempfile=False):
# type: (GMS_object) -> None
# type: (GMS_object, bool) -> None
if not GMSObj.arr_shape in ['cube', 'block', 'MGRS_tile']:
raise ValueError("GMSObjWriter supports only array shapes 'cube', 'block' and 'MGRS_tile'. "
"Received %s." % GMSObj.arr_shape)
......@@ -733,21 +733,21 @@ class GMSObjWriter(object):
def get_updated_db_entry(self):
"""Get id of updated record (needed for cross-refs in later db entrys."""
if not self.is_tempfile and self.GMSObj.arr_shape in ['cube', 'block']:
res = DB_T.get_info_from_postgreSQLdb(CFG.job.conn_database, 'scenes_proc', ['id'],
res = DB_T.get_info_from_postgreSQLdb(CFG.conn_database, 'scenes_proc', ['id'],
{'sceneid': self.GMSObj.scene_ID})
assert len(res) == 1, \
'Found multiple database records for the last updated record. sceneid: %s' % self.GMSObj.scene_ID
self.updated_db_entry.update(dict(table='scenes_proc', ID=res[0][0]))
elif not self.is_tempfile and self.GMSObj.arr_shape == 'MGRS_tile':
res = DB_T.get_info_from_postgreSQLdb(CFG.job.conn_database, 'mgrs_tiles_proc', ['id'],
res = DB_T.get_info_from_postgreSQLdb(CFG.conn_database, 'mgrs_tiles_proc', ['id'],
{'sceneid': self.GMSObj.scene_ID,
'virtual_sensor_id': CFG.usecase.virtual_sensor_id,
'virtual_sensor_id': CFG.virtual_sensor_id,
'mgrs_code': self.GMSObj.MGRS_info['tile_ID']})
assert len(res) == 1, \
'Found multiple database records for the last updated record. sceneid: %s; mgrs_code: %s; ' \
'virtual_sensor_id: %s' \
% (self.GMSObj.scene_ID, self.GMSObj.MGRS_info['tile_ID'], CFG.usecase.virtual_sensor_id)
% (self.GMSObj.scene_ID, self.GMSObj.MGRS_info['tile_ID'], CFG.virtual_sensor_id)
self.updated_db_entry.update(dict(table='mgrs_tiles_proc', ID=res[0][0]))
return self.updated_db_entry
......@@ -767,7 +767,7 @@ class _BlockWriter(GMSObjWriter):
"""Base class for writing block-like objects."""
def __init__(self, GMSObj, is_tempfile=False):
# type: (GMS_object) -> None
# type: (GMS_object, bool) -> None
super(_BlockWriter, self).__init__(GMSObj, is_tempfile=is_tempfile)
self.updated_ID_scenes_proc = None
......@@ -776,7 +776,7 @@ class _BlockWriter(GMSObjWriter):
super(_BlockWriter, self).update_database()
# get id of updated record (needed for cross-refs in later db entrys
res = DB_T.get_info_from_postgreSQLdb(CFG.job.conn_database, 'scenes_proc', ['id'],
res = DB_T.get_info_from_postgreSQLdb(CFG.conn_database, 'scenes_proc', ['id'],
{'sceneid': self.GMSObj.scene_ID})
assert len(res) == 1, \
'Found multiple database records for the last updated record. sceneid: %s' % self.GMSObj.scene_ID
......@@ -787,7 +787,7 @@ class _BlockWriter(GMSObjWriter):
class SceneWriter(_BlockWriter):
"""Class for writing full scene objects."""
def __init__(self, GMSObj, is_tempfile=False):
# type: (GMS_object) -> None
# type: (GMS_object, bool) -> None
"""
:param GMSObj:
......@@ -804,7 +804,7 @@ class TileWriter(_BlockWriter):
"""Class for writing tiles/block-subsets of full scene objects."""
def __init__(self, GMSObj, is_tempfile=False):
# type: (GMS_object) -> None
# type: (GMS_object, bool) -> None
"""
:param GMSObj:
......@@ -828,7 +828,7 @@ class TileWriter(_BlockWriter):
class MGRSTileWriter(TileWriter):
def __init__(self, GMSObj, is_tempfile):
# type: (GMS_object) -> None
# type: (GMS_object, bool) -> None
"""
:param GMSObj:
......@@ -846,13 +846,13 @@ class MGRSTileWriter(TileWriter):
super(MGRSTileWriter, self).update_database()
# get id of updated record (needed for cross-refs in later db entrys
res = DB_T.get_info_from_postgreSQLdb(CFG.job.conn_database, 'mgrs_tiles_proc', ['id'],
res = DB_T.get_info_from_postgreSQLdb(CFG.conn_database, 'mgrs_tiles_proc', ['id'],
{'sceneid': self.GMSObj.scene_ID,
'virtual_sensor_id': CFG.usecase.virtual_sensor_id,
'virtual_sensor_id': CFG.virtual_sensor_id,
'mgrs_code': self.GMSObj.MGRS_info['tile_ID']})
assert len(res) == 1, 'Found multiple database records for the last updated record. sceneid: %s;' \
'mgrs_code: %s; virtual_sensor_id: %s' \
% (self.GMSObj.scene_ID, self.GMSObj.MGRS_info['tile_ID'], CFG.usecase.virtual_sensor_id)
% (self.GMSObj.scene_ID, self.GMSObj.MGRS_info['tile_ID'], CFG.virtual_sensor_id)
self.mgrs_tiles_proc_ID = res[0][0]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment