Commit 11610bb9 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed not working status passing of spatial index mediator.

Former-commit-id: 785f799b
Former-commit-id: 45569bac
parent e8dcce40
......@@ -208,7 +208,6 @@ class L1B_object(L1A_object):
# set defaults
self._spatRef_available = None
self.spatRef_scene = None # set by self.get_spatial_reference_scene()
self._coreg_info = None
self.deshift_results = collections.OrderedDict()
if L1A_obj:
......@@ -489,34 +488,15 @@ class L1B_object(L1A_object):
return ref_band4match, shift_band4match
@property
def coreg_info(self):
if not self._coreg_info:
self._coreg_info = {
'corrected_shifts_px': {'x': 0, 'y': 0},
'corrected_shifts_map': {'x': 0, 'y': 0},
'original map info': self.meta_odict['map info'],
'updated map info': None,
'reference scene ID': None,
'reference entity ID': None,
'reference geotransform': None,
# reference projection must be the own projection in order to avoid overwriting with a wrong EPSG
'reference projection': self.meta_odict['coordinate system string'],
'reference extent': {'rows': None, 'cols': None},
'reference grid': [list(CFG.usecase.spatial_ref_gridx),
list(CFG.usecase.spatial_ref_gridy)],
'success': None
}
return self._coreg_info
@coreg_info.setter
def coreg_info(self, val):
self._coreg_info = val
def coregister_spatially(self):
if CFG.job.skip_coreg:
spatIdxSrv_status = os.environ['GMS_SPAT_IDX_SRV_STATUS'] if 'GMS_SPAT_IDX_SRV_STATUS' in os.environ else True
if spatIdxSrv_status == 'unavailable':
self.logger.warning('Coregistration skipped due to unavailable Spatial Index Mediator Server!"')
elif CFG.job.skip_coreg:
self.logger.warning('Coregistration skipped according to user configuration.')
elif self.coreg_needed and self.spatRef_available:
geoArr_ref = GeoArray(self.spatRef_scene.filePath)
geoArr_shift = GeoArray(self.arr)
......@@ -554,6 +534,7 @@ class L1B_object(L1A_object):
# TODO add database entry with error hint
[self.logger.error('ERROR during coregistration of scene %s (entity ID %s):\n%s'
% (self.scene_ID, self.entity_ID, err)) for err in COREG_obj.tracked_errors]
else:
if self.coreg_needed:
self.logger.warning('Coregistration skipped because no suitable reference scene is available or '
......
......@@ -32,12 +32,12 @@ class GMSEnvironment(object):
if not SpatIdxSrv.is_running:
SpatIdxSrv.start()
self.spatIdxSrvRunning = True
os.environ['GMS_SPAT_IDX_SRV_STATUS'] = 'available'
except GMSEnvironmentError as e:
self.logger.error(e, exc_info=False)
self.logger.warning('Coregistration will be skipped!')
self.spatIdxSrvRunning = False
os.environ['GMS_SPAT_IDX_SRV_STATUS'] = 'unavailable'
def _check_nonpip_packages(self):
"""Check for not pip-installable packages."""
......
......@@ -57,6 +57,7 @@ class GMS_object(Dataset):
self._dict_LayerOptTherm = None
self._cloud_masking_algorithm = None
self._meta_odict = None
self._coreg_info = None
self.job_ID = CFG.job.ID
# FIXME not needed anymore?:
......@@ -233,6 +234,31 @@ class GMS_object(Dataset):
def coreg_needed(self, value):
self._coreg_needed = value
@property
def coreg_info(self):
if not self._coreg_info:
self._coreg_info = {
'corrected_shifts_px': {'x': 0, 'y': 0},
'corrected_shifts_map': {'x': 0, 'y': 0},
'original map info': self.meta_odict['map info'],
'updated map info': None,
'reference scene ID': None,
'reference entity ID': None,
'reference geotransform': None,
# reference projection must be the own projection in order to avoid overwriting with a wrong EPSG
'reference projection': self.meta_odict['coordinate system string'],
'reference extent': {'rows': None, 'cols': None},
'reference grid': [list(CFG.usecase.spatial_ref_gridx),
list(CFG.usecase.spatial_ref_gridy)],
'success': False
}
return self._coreg_info
@coreg_info.setter
def coreg_info(self, val):
self._coreg_info = val
@property
def resamp_needed(self):
if self._resamp_needed is None:
......@@ -353,8 +379,8 @@ class GMS_object(Dataset):
out_dict = self.__dict__.copy()
# add some selected property values
for i in ['GMS_identifier', 'LayerBandsAssignment', 'coreg_needed', 'resamp_needed', 'dict_LayerOptTherm',
'georef', 'meta_odict']:
for i in ['GMS_identifier', 'LayerBandsAssignment', 'coreg_needed', 'coreg_info', 'resamp_needed',
'dict_LayerOptTherm', 'georef', 'meta_odict']:
out_dict[i] = getattr(self, i)
# remove private attributes
......
......@@ -100,16 +100,13 @@ def L1A_map_3(L1A_obj): # map (scene-wise parallelization)
@EXC_H.log_uncaught_exceptions
def L1B_map(L1A_obj, spatIdxSrvRunning):
def L1B_map(L1A_obj):
# type: (L1A_P.L1A_object) -> L1B_P.L1B_object
"""L1A_obj enthält in Python- (im Gegensatz zur Flink-) Implementierung KEINE ARRAY-DATEN!,
nur die für die ganze Szene gültigen Metadaten"""
L1B_obj = L1B_P.L1B_object(L1A_obj)
if spatIdxSrvRunning:
L1B_obj.coregister_spatially()
else:
L1B_obj.logger.warning('Coregistration skipped due to unavailable Spatial Index Mediator Server!')
L1B_obj.coregister_spatially()
if CFG.job.exec_L1BP[1]:
L1B_obj.to_ENVI()
......
......@@ -489,7 +489,7 @@ class process_controller(object):
L1A_DBObjects = self.get_DB_objects('L1B', self.L1A_newObjects, parallLev='scenes')
L1A_Instances = self.L1A_newObjects + L1A_DBObjects # combine newly and earlier processed L1A data
L1B_resObjects = MAP(L1B_map, [L1A_Instances, self.GMSEnv.spatIdxSrvRunning])
L1B_resObjects = MAP(L1B_map, L1A_Instances)
self.L1B_newObjects = [obj for obj in L1B_resObjects if isinstance(obj, L1B_P.L1B_object)]
self.failed_objects += [obj for obj in L1B_resObjects if isinstance(obj, failed_GMS_object) and
......
Markdown is supported
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