Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
geomultisens
gms_preprocessing
Commits
98c1894b
Commit
98c1894b
authored
Dec 04, 2017
by
Daniel Scheffler
Browse files
Merge remote-tracking branch 'origin/master'
parents
ca7b25ee
448cdff8
Pipeline
#1672
passed with stages
in 11 minutes and 35 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gms_preprocessing/misc/spatial_index_mediator.py
View file @
98c1894b
...
...
@@ -141,7 +141,7 @@ class SpatialIndexMediator:
return
seasonCode
def
getFullSceneDataForDataset
(
self
,
envelope
,
timeStart
,
timeEnd
,
minCloudCover
,
maxCloudCover
,
datasetid
,
refDate
=
None
,
maxDaysDelta
=
None
):
dayNight
=
0
,
refDate
=
None
,
maxDaysDelta
=
None
):
"""
Query the spatial index with the given parameters in order to get a list of matching scenes intersecting the
given envelope
...
...
@@ -155,6 +155,7 @@ class SpatialIndexMediator:
:param minCloudCover: minimum cloudcover in percent, e.g. 12, will return scenes with cloudcover >= 12% only
:param maxCloudCover: maximum cloudcover in percent, e.g. 23, will return scenes with cloudcover <= 23% only
:param datasetid: datasetid of the dataset in question, e.g. 104 for Landsat-8
:param dayNight day/night indicator, with (0 = both, 1 = day, 2 = night)
:param refDate: reference timestamp as datetime instance, e.g. datetime(2015, 1, 1) [optional]
:param maxDaysDelta: maximum allowed number of days the target scenes might be apart from the given refDate
[optional]
...
...
@@ -163,8 +164,8 @@ class SpatialIndexMediator:
filterTimerange
=
not
(
refDate
is
None
or
maxDaysDelta
is
None
)
# prepare buffer
# numbytes = 1 + 4*8 + 8 + 8 + 4 + 1 + 1 + 2 + 2
b
=
bytearray
(
59
)
# numbytes = 1 + 4*8 + 8 + 8 + 4 + 1 + 1 + 2 + 2
+ 1
b
=
bytearray
(
60
)
# pack msg header and envelope
offset
=
0
...
...
@@ -184,7 +185,8 @@ class SpatialIndexMediator:
# pack the rest
# TODO: send unconstraint min/max proclevel values
struct
.
pack_into
(
'> i 2b h 2b'
,
b
,
offset
,
seasonCode
,
minCloudCover
,
maxCloudCover
,
datasetid
,
0
,
127
)
struct
.
pack_into
(
'> i 2b h 3b'
,
b
,
offset
,
seasonCode
,
minCloudCover
,
maxCloudCover
,
datasetid
,
0
,
127
,
dayNight
)
# get connection and lock the channel
con
=
Connection
(
self
.
host
,
self
.
port
,
self
.
timeout
)
...
...
@@ -221,16 +223,26 @@ class SpatialIndexMediator:
scenes
=
[]
for
_x
in
range
(
numScenes
):
scenedata
=
struct
.
unpack_from
(
'> i h 9b'
,
b
,
offset
)
offset
+=
15
# [0] id (4 byte)
# [1] year (2 byte)
# [2] month (1 byte)
# [3] day (1 byte)
# [4] hour (1 byte)
# [5] minute (1 byte)
# [6] second (1 byte)
# [7] empty (1 byte)
# [8] cloud cover (1 byte)
# [9] proc_level (1 byte) caution: this gets not yet updated in the index
# [10] day/night (1 byte)
# [11] length of bounds array (1 byte)
scenedata
=
struct
.
unpack_from
(
'> i h 10b'
,
b
,
offset
)
offset
+=
16
# print(scenedata)
timestamp
=
datetime
(
scenedata
[
1
],
scenedata
[
2
],
scenedata
[
3
],
scenedata
[
4
],
scenedata
[
5
],
scenedata
[
6
])
# ignore unused scenedata[7]
# read bounds
numBounds
=
scenedata
[
1
0
]
numBounds
=
scenedata
[
1
1
]
fmt
=
"> {0}d"
.
format
(
numBounds
)
bounds
=
struct
.
unpack_from
(
fmt
,
b
,
offset
)
offset
+=
numBounds
*
8
...
...
@@ -248,7 +260,7 @@ class SpatialIndexMediator:
continue
# create scene
scenes
.
append
(
Scene
(
scenedata
[
0
],
timestamp
,
scenedata
[
8
],
scenedata
[
9
],
bounds
))
scenes
.
append
(
Scene
(
scenedata
[
0
],
timestamp
,
scenedata
[
8
],
scenedata
[
9
],
scenedata
[
10
],
bounds
))
return
scenes
...
...
@@ -309,11 +321,12 @@ class Connection:
class
Scene
:
"""Scene Metadata class"""
def
__init__
(
self
,
sceneid
,
acquisitiondate
,
cloudcover
,
proclevel
,
bounds
):
def
__init__
(
self
,
sceneid
,
acquisitiondate
,
cloudcover
,
proclevel
,
daynight
,
bounds
):
"""
:param sceneid: database sceneid, e.g. 26366229
:param acquisitiondate: acquisition date of the scene as datetime instance, e.g. 2016-03-25 10:15:26
:param cloudcover: cloudcover value of the scene, e.g. 11
:param daynight: day/night indicator (0=unknown, 1=day, 2=night)
:param bounds: scene bounds as list of lat/lon wgs84 coordinates (lon1, lat1, lon2, lat2, ...),
e.g. (10.00604, 49.19385, 7.45638, 49.64513, 8.13739, 51.3515, 10.77705, 50.89307)
"""
...
...
@@ -321,6 +334,7 @@ class Scene:
self
.
acquisitiondate
=
acquisitiondate
self
.
cloudcover
=
cloudcover
self
.
proclevel
=
proclevel
self
.
daynight
=
daynight
self
.
bounds
=
bounds
tempList
=
list
(
bounds
)
+
[
None
]
*
2
self
.
coordsLonLat
=
[
tempList
[
n
:
n
+
2
]
for
n
in
range
(
0
,
len
(
bounds
),
2
)]
...
...
Daniel Scheffler
@danschef
mentioned in commit
d9cc25d9
·
Feb 06, 2018
mentioned in commit
d9cc25d9
mentioned in commit d9cc25d9d36e7831722586db8c87a318444691eb
Toggle commit list
Daniel Scheffler
@danschef
mentioned in commit
6dac5642
·
Mar 31, 2020
mentioned in commit
6dac5642
mentioned in commit 6dac564210869bec42e32dd022ed277cd8e586b6
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment