EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit d98b484b authored by Fabian Schindler's avatar Fabian Schindler
Browse files

Fixing Sentinel-2 registration schema

parent a6385847
No related branches found
No related tags found
1 merge request!61Staging to master 1.3.0
......@@ -12,6 +12,7 @@ from .exceptions import RegistrationError
logger = logging.getLogger(__name__)
class RegistrationScheme:
def get_context(self) -> List[Context]:
raise NotImplementedError
......@@ -36,8 +37,7 @@ def parse_footprint(value):
class Sentinel2RegistrationScheme(RegistrationScheme):
name = 'sentinel-2-l2a'
name = 'sentinel-2'
MTD_SCHEMAS = {
'MSIL1C': {
......@@ -94,19 +94,19 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
def get_context(self, source: Source, path: str) -> List[Context]:
try:
metadata_file = join(path, 'MTD_MSIL2A.xml')
mtd_schema = MTD_SCHEMAS['MSIL2A']
mtd_namespaces = MTD_NAMESPACES['MSIL2A']
mtd_tl_schema = MTD_TL_SCHEMAS['MSIL2A']
mtd_tl_namespaces = MTD_TL_NAMESPACES['MSIL2A']
tree = read_xml(source, metadata_file)
mtd_schema = self.MTD_SCHEMAS['MSIL2A']
mtd_namespaces = self.MTD_NAMESPACES['MSIL2A']
mtd_tl_schema = self.MTD_TL_SCHEMAS['MSIL2A']
mtd_tl_namespaces = self.MTD_TL_NAMESPACES['MSIL2A']
except:
except Exception:
metadata_file = join(path, 'MTD_MSIL1C.xml')
mtd_schema = MTD_SCHEMAS['MSIL1C']
mtd_namespaces = MTD_NAMESPACES['MSIL1C']
mtd_tl_schema = MTD_TL_SCHEMAS['MSIL1C']
mtd_tl_namespaces = MTD_TL_NAMESPACES['MSIL1C']
tree = read_xml(source, metadata_file)
tree = read_xml(source, metadata_file)
mtd_schema = self.MTD_SCHEMAS['MSIL1C']
mtd_namespaces = self.MTD_NAMESPACES['MSIL1C']
mtd_tl_schema = self.MTD_TL_SCHEMAS['MSIL1C']
mtd_tl_namespaces = self.MTD_TL_NAMESPACES['MSIL1C']
# get product metadata
metadata = parse_metadata_schema(tree, mtd_schema, mtd_namespaces)
......@@ -204,7 +204,9 @@ class GSCRegistrationScheme(RegistrationScheme):
metadata_file = gsc_filenames[0]
tree = read_xml(source, metadata_file)
metadata = parse_metadata_schema(tree, self.GSC_SCHEMA, tree.getroot().nsmap)
metadata = parse_metadata_schema(
tree, self.GSC_SCHEMA, tree.getroot().nsmap
)
tiff_files = {
metadata['type']: source.list_files(path, ['*.tif', '*.TIF'])
......@@ -294,6 +296,7 @@ REGISTRATION_SCHEMES = {
'stac-item': STACCollectionScheme,
}
def get_scheme(config: dict, path: str) -> RegistrationScheme:
cfg_schemes = config['schemes']
......@@ -305,10 +308,11 @@ def get_scheme(config: dict, path: str) -> RegistrationScheme:
break
else:
# no source found
raise RegistrationError(f'Could not find a suitable scheme for the path {path}')
raise RegistrationError(
f'Could not find a suitable scheme for the path {path}'
)
return REGISTRATION_SCHEMES[cfg_scheme['type']](
*cfg_scheme.get('args', []),
**cfg_scheme.get('kwargs', {}),
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment