def create_tables_tiles():
    """ creates a report for specified month """
       
    sensor = request.args.get('sensor','')
    name = request.args.get('name','')
    cell = request.args.get('cell', '')
    geo = request.args.get('geo','')    
        
    r = Tile(sensor=sensor, name=name, cells=[cell] ,geo=geo)
    r.save()

    return r.as_json() 
Esempio n. 2
0
def imagepicker_tile():    
       
    if request.method == 'POST' and request.form.get('list_cloud_percent') and request.form.get('date_start') and request.form.get('date_end'):
        

        date_start         = request.form.get('date_start')
        date_end           = request.form.get('date_end')
        date_start = datetime.datetime.strptime(date_start,"%d/%b/%Y")
        date_end = datetime.datetime.strptime(date_end,"%d/%b/%Y")
        
        list_cloud_percent = request.form.get('list_cloud_percent')
        list_cloud_percent = json.loads(list_cloud_percent)
        
        landstat = EELandsat(date_start, date_end)
        result = landstat.get_thumbs(list_cloud_percent)
                
        return jsonify({'result': result})
    elif request.method == 'POST' and request.form.get('thumbs_tile'):
        
        logging.info(request.form.get('thumbs_tile'))
        thumbs_tile = request.form.get('thumbs_tile')        
        thumbs_tile = thumbs_tile.split(',')
        
        date_start  = request.form.get('date_start')
        date_end    = request.form.get('date_end')
        date_start = datetime.datetime.strptime(date_start,"%d/%b/%Y")
        date_end = datetime.datetime.strptime(date_end,"%d/%b/%Y")
        
        result = ""
        sensor_date = {}
        
        for i in range(len(thumbs_tile)):
            date, tile, sensor = thumbs_tile[i].split('__')
            
            if tile not in sensor_date.keys():
                sensor_date[tile]                = {}
                sensor_date[tile]['location']    = Tile.find_geo_region(tile.replace("_", "/"))
                sensor_date[tile]['sensor_date'] = []
                sensor_date[tile]['sensor_date'].append(sensor+'__'+date)
            else:
                sensor_date[tile]['sensor_date'].append(sensor+'__'+date)
                
            

        report = Report.current()
        
        logging.info("===== sensor_date =====")
        logging.info(sensor_date)
        
        for key in sensor_date:
            imagePicker = ImagePicker(report=report, added_by= users.get_current_user(), cell=str(key.replace("_", "/")),  location=str(sensor_date[key]['location']), sensor_dates=sensor_date[key]['sensor_date'], start=date_start, end=date_end)
            result = result + imagePicker.save()
        
        return jsonify({'result': result})
    else:     
        return jsonify({'result': None})