def analyze_recent_data(lat, lon, start, end, sort_by, bands, bmin, bmax, opacity): """Returns metadata and *first* tile url from GEE for all Sentinel images in date range ('start'-'end') that intersect with lat,lon. #Example of valid inputs (for area focused on Tenerife) lat = -16.589 lon = 28.246 start ='2017-03-01' end ='2017-03-10' """ loop = asyncio.new_event_loop() try: data = RecentTiles.recent_data(lat=lat, lon=lon, start=start, end=end, sort_by=sort_by) data = loop.run_until_complete( RecentTiles.async_fetch(loop, RecentTiles.recent_tiles, data, bands, bmin, bmax, opacity, 'first')) except RecentTilesError as e: logging.error('[ROUTER]: ' + e.message) return error(status=500, detail=e.message) except Exception as e: logging.error('[ROUTER]: ' + str(e)) return error(status=500, detail='Generic Error') return jsonify(data=serialize_recent_data(data, 'recent_tiles_data')), 200
def analyze_recent_thumbs(data_array, bands, bmin, bmax, opacity): """Takes an array of JSON objects with a 'source' key for each tile url to be returned. Returns an array of 'source' names and 'thumb_url' values. """ loop = asyncio.new_event_loop() try: data = loop.run_until_complete( RecentTiles.async_fetch(loop, RecentTiles.recent_thumbs, data_array, bands, bmin, bmax, opacity)) except RecentTilesError as e: logging.error('[ROUTER]: ' + e.message) return error(status=500, detail=e.message) except Exception as e: logging.error('[ROUTER]: ' + str(e)) return error(status=500, detail='Generic Error') return jsonify(data=serialize_recent_url(data, 'recent_thumbs_url')), 200