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
67d61165
Commit
67d61165
authored
4 years ago
by
Fabian Schindler
Browse files
Options
Downloads
Patches
Plain Diff
Improving footprint extraction and GSC generation
parent
933650f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
preprocessor/gsc_generator.py
+28
-13
28 additions, 13 deletions
preprocessor/gsc_generator.py
preprocessor/preprocessor.py
+15
-8
15 additions, 8 deletions
preprocessor/preprocessor.py
with
43 additions
and
21 deletions
preprocessor/gsc_generator.py
+
28
−
13
View file @
67d61165
from
textwrap
import
dedent
from
osgeo
import
gdal
def
positions_to_poslist
(
positions
,
projection
):
...
...
@@ -9,26 +10,40 @@ def positions_to_poslist(positions, projection):
for
pair
in
positions
])
def
get_footprint_from_browse
(
browse
):
def
positions_from_corners
(
low
,
high
):
minx
,
miny
=
low
maxx
,
maxy
=
high
return
[
(
minx
,
miny
),
(
maxx
,
miny
),
(
maxx
,
maxy
),
(
minx
,
maxy
),
(
minx
,
minx
),
]
def
get_footprint_from_browse
(
data_file
,
browse
):
btype
=
browse
[
'
browse_type
'
]
if
btype
==
'
rectified_browse
'
:
low
,
high
=
browse
[
'
rectified
'
][
'
coord_list
'
]
minx
,
miny
=
low
maxx
,
maxy
=
high
positions
=
[
(
minx
,
miny
),
(
maxx
,
miny
),
(
maxx
,
maxy
),
(
minx
,
maxy
),
(
minx
,
minx
),
]
positions
=
positions_from_corners
(
low
,
high
)
elif
btype
==
'
footprint_browse
'
:
positions
=
browse
[
'
footprint
'
]
elif
btype
==
'
model_in_geotiff_browse
'
:
# TODO: read from input dataset
raise
NotImplementedError
(
'
Model in geotiff browses are not supported
'
)
ds
=
gdal
.
Open
(
data_file
)
gt
=
ds
.
GetGeoTransform
()
width
,
height
=
ds
.
RasterXSize
,
ds
.
RasterXSize
low
=
(
gt
[
0
],
gt
[
3
]
+
gt
[
5
]
*
height
)
high
=
(
gt
[
0
]
+
gt
[
1
]
*
width
,
gt
[
3
])
positions
=
positions_from_corners
(
low
,
high
)
elif
btype
==
'
regular_grid_browse
'
:
raise
NotImplementedError
(
'
Regular grid browses are not supported
'
)
...
...
This diff is collapsed.
Click to expand it.
preprocessor/preprocessor.py
+
15
−
8
View file @
67d61165
...
...
@@ -45,6 +45,7 @@ import subprocess
from
urllib.parse
import
urlparse
from
urllib.request
import
urlretrieve
from
datetime
import
datetime
import
json
from
swiftclient.multithreading
import
OutputManager
from
swiftclient.service
import
SwiftError
,
SwiftService
,
SwiftUploadObject
...
...
@@ -361,7 +362,7 @@ class BrowseReportPreprocessor(BasePreprocessor):
'
begin_time
'
:
browse
[
'
start_time
'
],
'
end_time
'
:
browse
[
'
end_time
'
],
'
product_type
'
:
browse
[
'
browse_type
'
],
'
footprint
'
:
gsc_generator
.
get_footprint_from_browse
(
browse
)
'
footprint
'
:
gsc_generator
.
get_footprint_from_browse
(
data_file
,
browse
)
}
out_filename
=
join
(
tmpdir
,
splitext
(
basename
(
browse
[
'
filename
'
]))[
0
]
+
'
.xml
'
)
...
...
@@ -548,13 +549,19 @@ def preprocessor_redis_wrapper(
while
True
:
logger
.
debug
(
"
waiting for redis queue
'
%s
'
...
"
%
preprocess_queue_key
)
queue
,
value
=
client
.
brpop
([
preprocess_queue_key
,
preprocess_md_queue_key
])
preprocessor
(
collection
,
value
[
1
],
replace
=
replace
,
client
=
client
,
register_queue_key
=
register_queue_key
)
if
queue
==
preprocess_md_queue_key
:
preprocessor
=
BrowseReportPreprocessor
(
json
.
loads
(
value
))
else
:
preprocessor
=
PackagePreprocessor
(
value
)
# preprocessor(
# collection,
# value[1],
# replace=replace,
# client=client,
# register_queue_key=register_queue_key
# )
if
__name__
==
"
__main__
"
:
...
...
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