EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
02973c97
Commit
02973c97
authored
4 years ago
by
Fabian Schindler
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
217c6fee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!36
Staging to master to prepare 1.0.0 release
,
!32
Registrar modularization
,
!27
Registrar modularization
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/registrar/backend.py
+0
-2
0 additions, 2 deletions
core/registrar/backend.py
core/registrar/scheme.py
+33
-11
33 additions, 11 deletions
core/registrar/scheme.py
with
33 additions
and
13 deletions
core/registrar/backend.py
+
0
−
2
View file @
02973c97
...
...
@@ -111,9 +111,7 @@ class EOxServerBackend(Backend):
raster_item
=
item
.
raster_files
.
get
(
raster_identifier
)
raster_item
=
'
/
'
.
join
(
raster_item
.
split
(
'
/
'
)[
1
:])
logger
.
info
(
f
"
Adding browse
{
browse_type_name
or
'
default
'
}
{
raster_item
}
to product
"
)
logger
.
info
(
f
'
{
storage
+
[
raster_item
]
}
'
)
BrowseRegistrator
().
register
(
product
.
identifier
,
...
...
This diff is collapsed.
Click to expand it.
core/registrar/scheme.py
+
33
−
11
View file @
02973c97
import
re
from
os.path
import
join
import
logging
from
.xml
import
read_xml
,
parse_metadata_schema
,
Parameter
from
.context
import
Context
from
.source
import
Source
from
.exceptions
import
RegistrationError
class
RegistrationScheme
:
def
__init__
(
self
,
source
,
path
):
self
.
source
=
source
self
.
path
=
path
logger
=
logging
.
getLogger
(
__name__
)
class
RegistrationScheme
:
def
get_context
(
self
):
raise
NotImplementedError
def
parse_datetime
(
value
):
return
value
def
pairwise
(
iterable
):
"
s -> (s0,s1), (s2,s3), (s4, s5), ...
"
a
=
iter
(
iterable
)
return
zip
(
a
,
a
)
def
parse_footprint
(
value
):
coord_list
=
'
,
'
.
join
(
f
'
{
x
}
{
y
}
'
for
y
,
x
in
pairwise
(
value
.
split
())
)
return
f
'
POLYGON((
{
coord_list
}
))
'
class
Sentinel2RegistrationScheme
(
RegistrationScheme
):
...
...
@@ -23,10 +38,11 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
'
begin_time
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/PRODUCT_START_TIME/text()
'
,
False
,
parse_datetime
),
'
end_time
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/PRODUCT_STOP_TIME/text()
'
,
False
,
parse_datetime
),
'
identifier
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/PRODUCT_URI/text()
'
),
'
footprint
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:Geometric_Info/Product_Footprint/Product_Footprint/Global_Footprint/EXT_POS_LIST/text()
'
,
False
,
parse_footprint
),
'
level
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/PROCESSING_LEVEL/text()
'
),
'
type
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/PRODUCT_TYPE/text()
'
),
'
generation_time
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/GENERATION_TIME/text()
'
,
False
,
parse_datetime
),
'
cloud_cover
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:Quality_Indicators_Info/Cloud_Coverage_Assessment
'
),
'
cloud_cover
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:Quality_Indicators_Info/Cloud_Coverage_Assessment
/text()
'
),
'
image_file_paths
'
:
Parameter
(
'
/n1:Level-2A_User_Product/n1:General_Info/Product_Info/Product_Organisation/Granule_List/Granule/IMAGE_FILE/text()
'
,
True
),
'
mask_file_paths
'
:
Parameter
(
'
/n1:Level-2A_Tile_ID/n1:Quality_Indicators_Info/Pixel_Level_QI/MASK_FILENAME
'
,
True
),
}
...
...
@@ -35,9 +51,9 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
'
n1
'
:
"
https://psd-14.sentinel2.eo.esa.int/PSD/User_Product_Level-2A.xsd
"
}
def
get_context
(
self
):
metadata_file
=
join
(
self
.
path
,
'
MTD_
TL
.xml
'
)
mtd_tree
=
read_xml
(
self
.
source
,
metadata_file
)
def
get_context
(
self
,
source
:
Source
,
path
:
str
):
metadata_file
=
join
(
path
,
'
MTD_
MSIL2A
.xml
'
)
mtd_tree
=
read_xml
(
source
,
metadata_file
)
# get MTD metadata
...
...
@@ -45,18 +61,23 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
band_re
=
re
.
compile
(
r
'
.*([A-Z0-9]{3})_([0-9]{2}m)$
'
)
raster_files
=
{
band_re
.
match
(
image_file_path
).
groups
()[
0
]:
f
'
{
join
(
self
.
path
,
image_file_path
)
}
.jp2
'
band_re
.
match
(
image_file_path
).
groups
()[
0
]:
f
'
{
join
(
path
,
image_file_path
)
}
.jp2
'
for
image_file_path
in
metadata
[
'
image_file_paths
'
]
}
mask_type_re
=
re
.
compile
(
r
'
.*/MSK_([A-Z]*)_([A-Z0-9]{3}).[a-z0-9]+$
'
)
mask_files
=
{
mask_type_re
.
match
(
mask_file_path
).
groups
[
0
]:
mask_file_path
mask_type_re
.
match
(
mask_file_path
).
groups
[
0
]:
join
(
path
,
mask_file_path
)
for
mask_file_path
in
metadata
[
'
mask_file_paths
'
]
}
logger
.
info
(
f
'
{
mask_files
}
{
metadata
[
"
mask_file_paths
"
]
}
'
)
return
Context
(
identifier
=
metadata
[
'
identifier
'
],
path
=
path
,
product_type
=
metadata
[
'
type
'
],
product_level
=
metadata
[
'
level
'
],
raster_files
=
raster_files
,
mask_files
=
mask_files
,
metadata_files
=
[
metadata_file
],
...
...
@@ -65,6 +86,7 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
'
end_time
'
:
metadata
[
'
end_time
'
],
'
generation_time
'
:
metadata
[
'
generation_time
'
],
'
cloud_cover
'
:
metadata
[
'
cloud_cover
'
],
'
footprint
'
:
metadata
[
'
footprint
'
],
}
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment