# THIS SOFTWARE IS PROVIDED BY THE ABOVE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL EDINA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. """ Datacube processing functions """ from backend import logtool from backend.helper import isdate log = logtool.getLogger("db", "datacube_precesses") # Make this configurable once the user can dymanically generate one's own datasets # Accelerated LS8 ingested from S3 -- R,G,B,NIR LS8 = {'env': None, 'product': 'ls8_rgb_ndvi'} # Raw BOA S2 L2A from disk -- all bands, 2 years, less coverage L2A = {'env': 'l2a_safe', 'product': 's2a_sen2cor_granule'} # Raw TOA S2 L1C from disk -- all bands, all years, full coverage L1C = { 'env': 'l1c_safe', 'product': 's2a_level1c_granule' # 'product' : 's2b_level1c_granule' }
####################################################### ### Maps HTTP/REST requests to python functions ### ### They can all be tested ith wget/curl ### ####################################################### """ import bottle from bottle import route, request, response, static_file, hook ## backend imports from backend import logtool from backend import config from backend.rest import GeoRest log = logtool.getLogger("backend") ### /ws/operation1/... operation1 ### @route('/ws/operation1', method=["GET", ]) def operation1(): return GeoRest(request, response).operation1() ### /ws/operation2/... operation2 index support ### @route('/ws/operation2', method=["GET", ]) def operation2(): return GeoRest(request, response).operation2() ### Optional: STATIC FILES (html/css/js etc.). Reserved for future deployments
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL EDINA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. from tempfile import NamedTemporaryFile from os.path import basename from bottle import static_file from backend import helper, logtool from backend.db import landsat, sentinel, datacube_processes log = logtool.getLogger("GeoRest", "backend") class GeoRest(object): """REST request handler object. Return values should be direct json""" def __init__(self, request, response): self.request = request self.response = response def landsat_coverage(self): """ Execure landsat.get_coverage for all dataset that contain lon, lat Mandatory GET Args: lon: Longitude lat: Latitude Returns: Relevant Landsat datasets entries as an array of JSON objects
# THIS SOFTWARE IS PROVIDED BY THE ABOVE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL EDINA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. """ Sentinel specific functions """ from backend.db import spatialite from backend import logtool log = logtool.getLogger("db", "sentinel") def get_coverage(lon, lat): """ Find all indexed Landsat dataset entries that contain lon, lat Args: lon: Longitude lat: Latitude Returns: All return rows as an array of dictionaries """ point = 'POINT({} {})'.format(lon, lat) # check cloudCover!=-1 and big differences in lat / lon as mercator border data res = spatialite.execute( """ SELECT productName, timestamp, epoch, cloudCover,
# THIS SOFTWARE IS PROVIDED BY THE ABOVE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL EDINA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. """ Landsat specific functions """ from backend.db import spatialite from backend import logtool log = logtool.getLogger("db", "landsat") def get_coverage(lon, lat): """ Find all indexed Landsat dataset entries that contain lon, lat Args: lon: Longitude lat: Latitude Returns: All return rows as an array of dictionaries """ point = 'POINT({} {})'.format(lon, lat) # check cloudCover!=-1 and big differences in lat / lon as signs of erroneous data res = spatialite.execute( """ SELECT productId, entityId, acquisitionDate, epoch, cloudCover,