def get_raster_zip(latlonbox, time_st, model, variable): # Parameter minx, miny, maxx, maxy = latlonbox # Files, paths, and store name & store id tiff_file = NamedTemporaryFile(suffix=".tif", delete=False) tiff_path = tiff_file.name file_name = tiff_file.name[:-4] store_name = os.path.basename(file_name) store_id = get_workspace() + ':' + store_name tfw_path = file_name + '.tfw' prj_path = file_name + '.prj' zip_path = file_name + '.zip' # Create tiff file url_image = urllib2.urlopen(get_datarods_png().format(minx, miny, maxx, maxy, time_st, get_wms_vars()[model][variable][0])) tiff_file.write(url_image.read()) tiff_file.close() # Create prj file create_prj_file(prj_path) # Create tfw file create_tfw_file(tfw_path, float(minx), float(miny), float(maxx), float(maxy)) create_zip_file(zip_path, tiff_path, tfw_path, prj_path) # Return return [zip_path, store_name, store_id]
def home(request): """ Controller for the app 'home' page. """ init_model() model = get_model_options()[0][1] select_model = create_select_model(model) select_date, select_hour = create_map_date_ctrls(model) # Load map map_view, map_view_options = create_map() start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot') start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2') select_model2 = SelectInput(display_text='', name='model2', multiple=False, original=True, options=get_model_options(), attributes="onchange=oc_model2();" ) years_list = create_years_list(1979) select_years = SelectInput(display_text='', name='years', multiple=True, original=False, options=years_list, attributes="onchange=oc_years();" ) plot_button3 = Button(display_text='Plot', name='years', style='', icon='', href='', submit=False, disabled=False, attributes='onclick=createPlot(this.name);', classes='btn-plot') # Context variables context = { 'select_model': select_model, 'MapView': map_view, 'map_view_options': map_view_options, 'select_date': select_date, 'select_hour': select_hour, 'MODEL_FENCES': dumps(get_model_fences()), 'VAR_DICT': dumps(get_var_dict()), 'DATARODS_PNG': dumps(get_datarods_png()), 'DATARODS_TSB': dumps(get_datarods_tsb()), 'WMS_VARS': dumps(get_wms_vars()), 'start_date1': start_date1, 'end_date1': end_date1, 'plot_button1': plot_button1, 'start_date2': start_date2, 'end_date2': end_date2, 'plot_button2': plot_button2, 'select_model2': select_model2, 'plot_button3': plot_button3, 'select_years': select_years, # 'messages': [{ # 'category': 'info', # 'text': 'Click on the map to define data query location.', # 'id': 'click-map' # }] } return render(request, 'data_rods_explorer/app_base_dre.html', context)
def home(request): """ Controller for the app 'home' page. """ init_model() model = get_model_options()[0][1] select_model = create_select_model(model) select_date, select_hour = create_map_date_ctrls(model) # Load map map_view, map_view_options = create_map() start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot') start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2') select_model2 = SelectInput(display_text='', name='model2', multiple=False, original=True, options=get_model_options(), attributes="onchange=oc_model2();" ) years_list = create_years_list(1979) select_years = SelectInput(display_text='', name='years', multiple=True, original=False, options=years_list, attributes="onchange=oc_years();" ) plot_button3 = Button(display_text='Plot', name='years', style='', icon='', href='', submit=False, disabled=False, attributes='onclick=createPlot(this.name);', classes='btn-plot') # Context variables context = { 'select_model': select_model, 'MapView': map_view, 'map_view_options': map_view_options, 'select_date': select_date, 'select_hour': select_hour, 'MODEL_FENCES': dumps(get_model_fences()), 'VAR_DICT': dumps(get_var_dict()), 'DATARODS_PNG': dumps(get_datarods_png()), 'DATARODS_TSB': dumps(get_datarods_tsb()), 'WMS_VARS': dumps(get_wms_vars()), 'start_date1': start_date1, 'end_date1': end_date1, 'plot_button1': plot_button1, 'start_date2': start_date2, 'end_date2': end_date2, 'plot_button2': plot_button2, 'select_model2': select_model2, 'plot_button3': plot_button3, 'select_years': select_years } return render(request, 'data_rods_explorer/app_base_dre.html', context)