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
3e97dfce
Commit
3e97dfce
authored
4 years ago
by
Fabian Schindler
Browse files
Options
Downloads
Patches
Plain Diff
Fixed GSC footprint parsing
Added option to extract level via RE
parent
f267ca1a
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/registrar/scheme.py
+39
-4
39 additions, 4 deletions
core/registrar/scheme.py
with
39 additions
and
4 deletions
core/registrar/scheme.py
+
39
−
4
View file @
3e97dfce
...
...
@@ -102,16 +102,51 @@ class Sentinel2RegistrationScheme(RegistrationScheme):
)
def
parse_ring
(
string
):
raw_coords
=
string
.
split
()
return
[(
lon
,
lat
)
for
lat
,
lon
in
pairwise
(
raw_coords
)]
def
parse_polygons_gsc
(
elem
):
def
serialize_coord_list
(
coords
):
return
'
,
'
.
join
(
f
'
{
x
}
{
y
}
'
for
x
,
y
in
coords
)
interior
=
serialize_coord_list
(
parse_ring
(
elem
.
xpath
(
"
gml:exterior/gml:LinearRing/gml:posList
"
,
namespaces
=
elem
.
nsmap
)[
0
].
text
.
strip
()
)
)
exteriors
=
[
f
'''
(
{
serialize_coord_list
(
parse_ring
(
poslist_elem
.
text
.
strip
())
)
}
)
'''
for
poslist_elem
in
elem
.
xpath
(
"
gml:interior/gml:LinearRing/gml:posList
"
,
namespaces
=
elem
.
nsmap
)
]
return
f
"
POLYGON((
{
interior
}
)
{
'
,
'
if
exteriors
else
''
}{
'
,
'
.
join
(
exteriors
)
}
)
"
class
GSCRegistrationScheme
(
RegistrationScheme
):
GSC_SCHEMA
=
{
'
identifier
'
:
Parameter
(
'
//gml:metaDataProperty/gsc:EarthObservationMetaData/eop:identifier/text()
'
),
'
type
'
:
Parameter
(
'
//gml:using/eop:EarthObservationEquipment/eop:platform/eop:Platform/eop:shortName/text()
'
),
'
level
'
:
Parameter
(
'
//gml:metaDataProperty/gsc:EarthObservationMetaData/eop:parentIdentifier/text()
'
),
'
mask
'
:
Parameter
(
'
//gsc:opt_metadata/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:vendorSpecific/eop:SpecificInformation[eop:localAttribute/text() =
"
CF_POLY
"
]/eop:localValue/text()
'
),
'
footprint
'
:
Parameter
(
'
//
gsc:
opt
_metadata
/gml:
meta
D
ata
Property/gsc:EarthObservationMetaData/eop:vendorSpecific/eop:SpecificInformation[eop:localAttribute/text() =
"
CF_POLY
"
]/eop:localValue/text()
'
),
'
mask
'
:
Parameter
(
'
//gsc:opt_metadata/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:vendorSpecific/eop:SpecificInformation[eop:localAttribute/text() =
"
CF_POLY
"
]/eop:localValue/text()
'
,
True
),
'
footprint
'
:
Parameter
(
'
(
gsc:
sar
_metadata
|gsc:opt_
meta
d
ata
)/gml:target/eop:Footprint/gml:multiExtentOf/gml:MultiSurface/gml:surfaceMembers/gml:Polygon
'
,
True
,
parse_polygons_gsc
),
}
def
__init__
(
self
,
level_re
:
str
=
r
'
.*(Level_[0-9]+)$
'
):
self
.
level_re
=
level_re
def
get_context
(
self
,
source
:
Source
,
path
:
str
)
->
Context
:
gsc_filenames
=
source
.
list_files
(
path
,
[
'
GSC*.xml
'
,
'
GSC*.XML
'
])
metadata_file
=
gsc_filenames
[
0
]
...
...
@@ -123,7 +158,7 @@ class GSCRegistrationScheme(RegistrationScheme):
metadata
[
'
type
'
]:
source
.
list_files
(
path
,
[
'
*.tif
'
,
'
*.TIF
'
])
}
match
=
re
.
match
(
r
'
.*(Level_[0-9]+)$
'
,
metadata
[
'
level
'
])
match
=
re
.
match
(
self
.
level_re
,
metadata
[
'
level
'
])
if
match
:
level
=
match
.
groups
()[
0
]
else
:
...
...
@@ -136,7 +171,7 @@ class GSCRegistrationScheme(RegistrationScheme):
product_level
=
level
,
raster_files
=
tiff_files
,
masks
=
{
'
validity
'
:
metadata
[
'
mask
'
]
'
validity
'
:
metadata
[
'
mask
'
]
[
0
]
if
metadata
[
'
mask
'
]
else
None
},
metadata_files
=
[
metadata_file
],
metadata
=
{
...
...
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