Commit 3128d24a authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added api changes to the py index mediator implementation

Former-commit-id: 3ad3db23
Former-commit-id: dfacdeb0
parent 7444554f
......@@ -140,7 +140,7 @@ class SpatialIndexMediator:
return seasonCode
def getFullSceneDataForDataset(self, envelope, timeStart, timeEnd, minCloudCover, maxCloudCover, datasetid,
def getFullSceneDataForDataset(self, envelope, timeStart, timeEnd, minCloudCover, maxCloudCover, datasetid, 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
......@@ -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]
......@@ -184,7 +185,7 @@ 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 +222,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[10]
numBounds = scenedata[11]
fmt = "> {0}d".format(numBounds)
bounds = struct.unpack_from(fmt, b, offset)
offset += numBounds * 8
......@@ -248,7 +259,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 +320,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 +333,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)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment