def add_site(request):
    select_source = SelectInput(display_text='Select Source',
                                name='select-source',
                                multiple=False,
                                options=[('One', '1'), ('Two', '2'), ('Three', '3')])
    select_site_type = SelectInput(display_text='Select Site Type',
                                   name='select-site-type',
                                   multiple=False,
                                   options=[('Four', '4'), ('Five', '5'), ('Six', '6')])
    select_vertical_datum = SelectInput(display_text='Select Vertical Datum',
                                        name='select-vertical-datum',
                                        multiple=False,
                                        options=[('MSL', 'MSL'), ('NAVD88', 'NAVDD88'), ('NGVD29', 'NGVD29'), ('Something', 'Something'), ('Unknown', 'Unknown')])
    select_spatial_reference = SelectInput(display_text='Select Spatial Reference',
                                           name='select-spatial-reference',
                                           multiple=False,
                                           options=[('WGS84', 'WGS84'), ('NAD27', 'NAD27')])
    google_map_view = GoogleMapView(height='400px',
                                    width='100%',
                                    maps_api_key='S0mEaPIk3y',
                                    drawing_types_enabled=['POINTS'])
    if request.POST and 'site-name' in request.POST:
        site_name = request.POST['site-name']

    context = {"select_source": select_source, "select_site_type": select_site_type, "select_vertical_datum": select_vertical_datum,
               "select_spatial_reference": select_spatial_reference, "google_map_view": google_map_view}
    return render(request, 'hydroexplorer/addsite.html', context)
def hydroshare_view(request):
    """
    Controller for the Hydroshare view page.
    """
    watersheds_select_input = SelectInput(
        display_text='Select A Watershed',
        name='watersheds_select_input',
        multiple=False,
        original=True,
        options=[['View All Watersheds', ''],
                 ["Islands", "islands-geoglows"],
                 ["Australia", "australia-geoglows"],
                 ["Japan", "japan-geoglows"],
                 ["East Asia", "east_asia-geoglows"],
                 ["South Asia", "south_asia-geoglows"],
                 ["Central Asia", "central_asia-geoglows"],
                 ["West Asia", "west_asia-geoglows"],
                 ["Middle East", "middle_east-geoglows"],
                 ["Europe", "europe-geoglows"],
                 ["Africa", "africa-geoglows"],
                 ["South America", "south_america-geoglows"],
                 ["Central America", "central_america-geoglows"],
                 ["North America", "north_america-geoglows"]],
        initial=''
    )

    delete_old_observations()

    uploaded_observations = SelectInput(
        display_text='Uploaded Observational Data',
        name='uploaded_observations',
        multiple=False,
        original=True,
        options=list_uploaded_observations(),
    )
    gauge_networks = SelectInput(
        display_text='Stream Gauge Networks',
        name='gauge_networks',
        multiple=False,
        original=True,
        options=list_gauge_networks(),
    )
    upload_new_observation = Button(
        name='Upload New Observation',
        display_text='Upload New Observation',
    )

    context = {
        # constants
        'endpoint': gsf.ENDPOINT,
        # uploaded data
        'uploaded_observations': uploaded_observations,
        'upload_new_observation': upload_new_observation,
        # gauge_networks
        'gauge_networks': gauge_networks,
        # controls
        'watersheds_select_input': watersheds_select_input,
    }

    return render(request, 'geoglows_hydroviewer/geoglows_hydroviewer.html', context)
示例#3
0
def home(request):
    """
    Controller for the app home page.
    """
    catalog = app.get_spatial_dataset_service(app.THREDDS_SERVICE_NAME, as_engine=True)

    # Retrieve dataset options from the THREDDS service
    # Retrieve dataset options from the THREDDS service
    log.info('Retrieving Datasets...')
    datasets = parse_datasets(catalog)
    initial_dataset_option = datasets[0]
    log.debug(datasets)
    log.debug(initial_dataset_option)

    dataset_select = SelectInput(
        display_text='Dataset',
        name='dataset',
        multiple=False,
        options=datasets,
        initial=initial_dataset_option,
        select2_options={'placeholder': 'Select a dataset',
                         'allowClear': False}
    )
    # Retrieve dataset options from the THREDDS service
    # datasets = []
    #
    # dataset_select = SelectInput(
    #     display_text='Dataset',
    #     name='dataset',
    #     multiple=False,
    #     options=datasets,
    #     initial=None,
    #     select2_options={'placeholder': 'Select a dataset',
    #                      'allowClear': False}
    # )

    variable_select = SelectInput(
        display_text='Variable',
        name='variable',
        multiple=False,
        options=(),
        select2_options={'placeholder': 'Select a variable',
                         'allowClear': False}
    )

    style_select = SelectInput(
        display_text='Style',
        name='style',
        multiple=False,
        options=(),
        select2_options={'placeholder': 'Select a style',
                         'allowClear': False}
    )

    context = {
        'dataset_select': dataset_select,
        'variable_select': variable_select,
        'style_select': style_select,
    }
    return render(request, 'thredds_tutorial/home.html', context)
示例#4
0
def ecmwf(request):
    model_input = SelectInput(display_text='',
                              name='model',
                              multiple=False,
                              options=[('Select Model', ''),
                                       ('ECMWF-RAPID', 'ecmwf'),
                                       ('LIS-RAPID', 'lis')],
                              initial=['ecmwf'],
                              original=True)

    res = requests.get(
        'https://tethys.byu.edu/apps/streamflow-prediction-tool/api/GetWatersheds/',
        headers={
            'Authorization': 'Token 72b145121add58bcc5843044d9f1006d9140b84b'
        })

    watershed_list_raw = json.loads(res.content)
    watershed_list = [
        value for value in watershed_list_raw
        if "Nepal" in value[0] or "NEPAL" in value[0] or "nepal" in value[0]
    ]
    watershed_list.append(['Select Watershed', ''])

    watershed_select = SelectInput(display_text='',
                                   name='watershed',
                                   options=watershed_list,
                                   initial=['Select Watershed'],
                                   original=True)

    context = {
        'model_input': model_input,
        'watershed_select': watershed_select
    }

    return render(request, 'hydroviewer/ecmwf.html', context)
示例#5
0
def map(request):
    """
    Controller for the map viewer page.
    """
    # get/check information from AJAX request
    post_info = request.GET
    watershed_ids = post_info.getlist('watershed_select')
    info = watersheds_db()
    watersheds_info = []
    for i in range(len(watershed_ids)):
        watersheds_info.append(info[watershed_ids[i]])

    # if there was no watershed selected, return to home page with warning
    if not watershed_ids:
        msg = "No watershed selected. Please select one then try again"
        return redirect_with_message(request, "..", msg, severity="WARNING")

    available_forecast_dates = []
    watersheds = watershedlist()

    # set up the inputs
    watershed_select = SelectInput(display_text='Select Watershed',
                                   name='watershed_select',
                                   options=watersheds)
    units_toggle_switch = ToggleSwitch(display_text='Units:',
                                       name='units-toggle',
                                       on_label='Metric',
                                       off_label='English',
                                       size='mini',
                                       initial=True)

    warning_point_date_select = None
    warning_point_forecast_folder = ""
    if available_forecast_dates:
        available_forecast_dates = sorted(available_forecast_dates,
                                          key=lambda k: k['id'],
                                          reverse=True)
        warning_point_forecast_folder = available_forecast_dates[0]['id']
        forecast_date_select_input = []
        for available_forecast_date in available_forecast_dates:
            next_row_info = (available_forecast_date['text'],
                             available_forecast_date['id'])
            if next_row_info not in forecast_date_select_input:
                forecast_date_select_input.append(next_row_info)

        warning_point_date_select = SelectInput(
            display_text='Select Forecast Date',
            name='warning_point_date_select',
            options=forecast_date_select_input)

    context = {
        'watersheds_info': json.dumps(watersheds_info),
        'geoserver_url': json.dumps(get_geoserver()),
        'warning_point_forecast_folder': warning_point_forecast_folder,
        'watershed_select': watershed_select,
        'warning_point_date_select': warning_point_date_select,
        'units_toggle_switch': units_toggle_switch,
    }
    return render(request, 'sfpt/map.html', context)
示例#6
0
def home(request):
    """
    Controller for map page.
    """
    # Define Gizmo Options
    select_model = SelectInput(
        display_text='Model Type:',
        name='select_model',
        multiple=False,
        options=(('SPT (Standard Penetration Test)', 'spt'),
                 ('CPT (Cone Penetration Test)', 'cpt')),
        initial=('SPT (Standard Penetration Test)', 'spt'),
    )
    select_year = SelectInput(display_text='Model/Data Year:',
                              name='select_year',
                              multiple=False,
                              options=[(2014, 2014), (2008, 2008)],
                              initial=[(2014, 2014)])
    select_return_period = SelectInput(display_text='Return Period (years):',
                                       name='select_return_period',
                                       multiple=False,
                                       options=[('475', 475), ('1033', 1033),
                                                ('2475', 2475)],
                                       initial=['475', 475])
    select_state = SelectInput(display_text='State:',
                               name='select_state',
                               multiple=False,
                               options=[
                                   ('Alaska', 'Alaska'),
                                   ('Arizona', 'Arizona'),
                                   ('California', 'California'),
                                   ('Connecticut', 'Connecticut'),
                                   ('Idaho', 'Idaho'),
                                   ('Montana', 'Montana'),
                                   ('Nevada', 'Nevada'),
                                   ('Oregon', 'Oregon'),
                                   ('South Carolina', 'South_Carolina'),
                                   ('Utah', 'Utah'),
                                   ('Washington', 'Washington'),
                               ],
                               initial=['Utah', 'Utah'])

    text_input_lat = TextInput(display_text='Latitude', name='lat-input')
    text_input_lon = TextInput(display_text='Longitude', name='lon-input')

    context = {
        'select_model': select_model,
        'select_year': select_year,
        'select_return_period': select_return_period,
        'select_state': select_state,
        'text_input_lat': text_input_lat,
        'text_input_lon': text_input_lon,
    }

    return render(request, 'lfhazard/home.html', context)
示例#7
0
def add_new_layer(request):
    """
    Controller for the upload layer page.
    """

    add_new_select = SelectInput(display_text='Add New Layer',
                                 name='add-new-select',
                                 attributes={'id': 'add-new-select'},
                                 multiple=False,
                                 options=[('True', 'True'),
                                          ('False', 'False')])

    layer_text_input = TextInput(
        display_text='Layer Name',
        name='layer-text-input',
        placeholder='e.g.: Hospitals',
        attributes={'id': 'layer-text-input'},
    )

    layer_options = get_layer_options()
    layer_list = [(layer, layer) for key, val in layer_options.items()
                  for layer in val]

    layer_select_input = SelectInput(
        display_text='Select Layer',
        name='layer-select-input',
        multiple=False,
        original=True,
        options=layer_list,
    )

    attributes_button = Button(
        display_text='Get Attributes',
        icon='glyphicon glyphicon-plus',
        style='primary',
        name='submit-get-attributes',
        attributes={'id': 'submit-get-attributes'},
    )

    add_button = Button(display_text='Add Layer',
                        icon='glyphicon glyphicon-plus',
                        style='primary',
                        name='submit-add-layer',
                        attributes={'id': 'submit-add-layer'},
                        classes="hidden add")

    context = {
        'add_new_select': add_new_select,
        'layer_text_input': layer_text_input,
        'layer_select_input': layer_select_input,
        'attributes_button': attributes_button,
        'add_button': add_button
    }

    return render(request, 'glo_dda/add_new_layer.html', context)
示例#8
0
def show_log(request, job_id):
    try:
        job = TethysJob.objects.get_subclass(id=job_id)
        # Get the Job logs.
        data = job.get_logs()

        sub_job_options = [(k, k) for k in data.keys()]
        sub_job_select = SelectInput(display_text='Select Log:',
                                     name='sub_job_select',
                                     multiple=False,
                                     options=sub_job_options,
                                     attributes={'data-job-id': job_id})

        context = {'sub_job_select': sub_job_select, 'log_options': {}}

        for k, v in data.items():
            if isinstance(v, dict):
                context['log_options'][f'log_select_{k}'] = SelectInput(
                    name=f'log_{k}',
                    multiple=False,
                    options=[(key, key) for key in v.keys()],
                )

        html = render_to_string('tethys_gizmos/gizmos/job_logs.html', context)

        def remove_callables(item):
            if callable(item):
                return
            elif isinstance(item, dict):
                for k, v in item.items():
                    item[k] = remove_callables(v)
                return item
            else:
                return item.replace('\n', '<br/>')

        log_contents = remove_callables(data)

        return JsonResponse({
            'success': True,
            'html': html,
            'log_contents': log_contents
        })
    except Exception as e:
        message = str(e)
        log.error(
            'The following error occurred when retrieving logs for job %s: %s',
            job_id, message)

        return JsonResponse({
            'success':
            False,
            'error_message':
            'ERROR: An error occurred while retrieving job logs.'
        })
示例#9
0
def home(request):
    """
    Controller for the app home page.
    """
    # Get the options for the GLDAS Variables
    variables = gldas_variables()
    variable_opts = []
    for key in sorted(variables.keys()):
        variable_opts.append((key, variables[key]))
    del variables
    date_opts = available_dates()
    color_opts = wms_colors()

    variables = SelectInput(
        display_text='Pick a Variable',
        name='variables',
        multiple=False,
        options=variable_opts,
        initial=['Air Temperature'],
    )

    dates = SelectInput(
        display_text='Date Selection',
        name='dates',
        multiple=False,
        options=date_opts,
        initial=[date_opts[0]],
    )

    rasteropacity = RangeSlider(
        display_text='LDAS Layer Opacity',
        name='rasteropacity',
        min=.4,
        max=1,
        step=.05,
        initial=.8,
    )

    colors = SelectInput(
        display_text='Pick a Color Scale',
        name='colors',
        multiple=False,
        options=color_opts,
        initial=['Red-Blue'],
    )

    context = {
        'variables': variables,
        'dates': dates,
        'rasteropacity': rasteropacity,
        'colors': colors,
    }

    return render(request, 'malaria/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """
    variables = gfs_variables()
    options = []
    for key in sorted(variables.keys()):
        tuple1 = (key, variables[key])
        options.append(tuple1)
    del tuple1, key, variables

    layers = SelectInput(
        display_text='Select GFS Variable',
        name='layers',
        multiple=False,
        original=True,
        options=options,
    )

    colors = SelectInput(
        display_text='Color Scheme',
        name='colors',
        multiple=False,
        original=True,
        options=wms_colors(),
    )

    times = SelectInput(
        display_text='Time Interval',
        name='times',
        multiple=False,
        original=True,
        options=get_times(),
    )

    opacity = RangeSlider(
        display_text='Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=.75,
    )

    context = {
        'layers': layers,
        'opacity': opacity,
        'colors': colors,
        'times': times,
    }

    return render(request, 'gfs_viewer/home.html', context)
示例#11
0
def home(request):
    """
    Controller for the app home page.
    """

    ad_select = SelectInput(
        display_text='Select Additional Layer',
        name='ad_select',
        multiple=False,
        original=True,
        options=additional_layers(),
        initial='pop2020',
    )

    ad_opacity = RangeSlider(
        display_text='Additional Layer Opacity',
        name='ad_opacity',
        min=0,
        max=1,
        step=.05,
        initial=0.8,
    )

    fl_select = SelectInput(
        display_text='Select Flood Layer',
        name='fl_select',
        multiple=False,
        original=True,
        options=flood_layers(),
        initial='comp5',
    )

    fl_opacity = RangeSlider(
        display_text='Flood Layer Opacity',
        name='fl_opacity',
        min=0,
        max=1,
        step=.05,
        initial=.7,
    )

    context = {
        # display options
        'ad_select': ad_select,
        'ad_opacity': ad_opacity,
        'fl_select': fl_select,
        'fl_opacity': fl_opacity,
    }

    return render(request, 'viirs_explorer/home.html', context)
示例#12
0
def home(request):
    """
    Controller for the app home page.
    """

    chirpsproducts = SelectInput(
        display_text='Select a CHIRPS product',
        name='chirpsproducts',
        multiple=False,
        original=True,
        options=(
            ('CHIRPS GEFS 5 day forecast (average)', 'gefs_05day'),
            ('CHIRPS GEFS 10 day forecast (average)', 'gefs_10day'),
            ('CHIRPS GEFS 15 day forecast (average)', 'gefs_15day'),
        ),
    )

    colorscheme = SelectInput(display_text='Forecast Layer Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=(
                                  ('Precipitation', 'precipitation'),
                                  ('Greyscale', 'greyscale'),
                                  ('Rainbow', 'rainbow'),
                                  ('OCCAM', 'occam'),
                                  ('Red-Blue', 'redblue'),
                                  ('ALG', 'alg'),
                              ))

    opacity_raster = RangeSlider(
        display_text='Forecast Layer Opacity',
        name='opacity_raster',
        min=0,
        max=1,
        step=.05,
        initial=.5,
    )

    context = {
        'chirpsproducts': chirpsproducts,
        'colorscheme': colorscheme,
        'opacity_raster': opacity_raster,
        'filenames': get_forecast_netcdf_names(),
        'thredds_url': App.get_custom_setting('thredds_url'),
    }

    return render(request, 'chirps/home.html', context)
示例#13
0
def get_aquifer_select(region_id: Union[int, None],
                       aquifer_id: bool = False) -> Any:
    """
    Generate Aquifer Select Gizmo

    Args:
        region_id: Region Id as listed in the Region table
        aquifer_id: Boolean to decide the aquifer id type

    Returns:
        Aquifer Select Gizmo Object. Used to generate an aquifer select dropdown.
    """
    aquifer_list = []
    if region_id is not None:
        session = get_session_obj()
        aquifers = session.query(Aquifer).filter(
            Aquifer.region_id == region_id)

        for aquifer in aquifers:
            if aquifer_id:
                aquifer_list.append(("%s" % aquifer.aquifer_name, aquifer.id))
            else:
                aquifer_list.append(
                    ("%s" % aquifer.aquifer_name, aquifer.aquifer_id))
        session.close()

    aquifer_select = SelectInput(
        display_text='Select an Aquifer',
        name='aquifer-select',
        options=aquifer_list,
    )

    return aquifer_select
示例#14
0
def mapview(request):
    """
    Controller for the app home page.
    """
    select_region = SelectInput(display_text='Select a Region:',
                                name='select-region',
                                multiple=False,
                                original=True,
                                options=[('Utah Valley', '1'),
                                         ('Payson/Santaquin', '2'),
                                         ('Salt Lake ', '3'), ('Ogden', '4')],
                                initial=[''])

    select_region_button = Button(
        display_text='Select Region',
        name='select-region-button',
        icon='glyphicon glyphicon-plus',
        style='success',
    )

    add_region_button = Button(display_text='Add Region',
                               name='add-region-button',
                               icon='glyphicon glyphicon-plus',
                               style='success')
    context = {
        "select_region": select_region,
        "select_region_button": select_region_button,
        "add_region_button": add_region_button,
    }

    return render(request, 'snowpack_viewer/mapview.html', context)
示例#15
0
def home(request):
    if not shapefiles_downloaded():
        messages.warning(request, WARN_DOWNLOAD_SHAPEFILES)

    projects_path = os.path.join(App.get_app_workspace().path, 'projects')
    if not os.path.exists(projects_path):
        os.mkdir(projects_path)

    projects = os.listdir(projects_path)
    projects = [(prj.replace('_', ' '), prj) for prj in projects
                if os.path.isdir(os.path.join(projects_path, prj))]

    if len(projects) > 0:
        show_projects = True
    else:
        show_projects = False

    projects = SelectInput(display_text='Existing Hydroviewer Projects',
                           name='project',
                           multiple=False,
                           options=projects)

    context = {
        'projects': projects,
        'show_projects': show_projects,
    }

    return render(request,
                  'geoglows_hydroviewer/geoglows_hydroviewer_creator.html',
                  context)
示例#16
0
def simulations(request):
    """
    controller for the instructions page
    """

    # list of reservoirs to choose from for the simulation
    options = [(reservoir, reservoirs[reservoir]) for reservoir in reservoirs]
    options.sort()
    res_list = SelectInput(
        display_text='',
        name='reservoir',
        multiple=False,
        options=options,
        select2_options={
            'placeholder': 'Choose A Reservoir',
            'allowClear': True
        },
    )

    context = {
        'admin': has_permission(request, 'update_data'),
        'urls': generate_app_urls(request, reservoirs),
        'res_list': res_list,
        'youtubelink': App.youtubelink
    }

    return render(request, 'reservoirs/simulations.html', context)
示例#17
0
def home(request):
    global contOptions
    if not contOptions:
        contOptions = getContaminantOptions()

    cont_selector = SelectInput(display_text='Select Contaminants',
                                name='cont_selector',
                                multiple=True,
                                options=contOptions,
                                initial=[])

    search_button = Button(
        display_text='Search',
        name='search-button',
        icon='glyphicon glyphicon-search',
        style='primary',
        attributes={"onclick": "perform_search();"}
    )

    context = {
        'cont_selector': cont_selector,
        'search_button': search_button
    }

    return render(request, 'gw_contaminants/home.html', context)
def catalog_servers(request):

    # Connecting to the catalog service to
    # retrieve all the available HydroServers.
    url = request.POST['url']
    servers = []
    try:
        his_url = url + "?WSDL"
        client = Client(his_url)
        service_info = client.service.GetWaterOneFlowServiceInfo()
        services = service_info.ServiceInfo
    except Exception as e:
        # Can't use standard Suds API. Using XML directly
        services = parseService(url)

    finally:
        for i in services:
            try:
                url = i['servURL'].encode('utf-8')
                title = i['Title'].encode('utf-8')
                organization = i['organization'].encode('utf-8')
                variable_str = "Title: %s, Organization: %s" % (
                    title, organization)
                servers.append([variable_str, url])
            except Exception as e:
                print(e)

        select_his_server = SelectInput(display_text='Select HIS Server',
                                        name="select_server",
                                        multiple=False,
                                        options=servers)
        return render(request, 'hydroexplorer/modals/helpers/catalog.html', {"select_his_server": select_his_server})
示例#19
0
def map(request):
    """
    Controller for the map page
    """
    geoserver_engine = app.get_spatial_dataset_service(name='main_geoserver',
                                                       as_engine=True)

    options = []

    response = geoserver_engine.list_layers(with_properties=False)

    if response['success']:
        for layer in response['result']:
            options.append((layer.title(), layer))

    select_options = SelectInput(display_text='Choose Layer',
                                 name='layer',
                                 multiple=False,
                                 options=options)

    map_layers = []

    if request.POST and 'layer' in request.POST:
        selected_layer = request.POST['layer']
        legend_title = selected_layer.title()

        geoserver_layer = MVLayer(source='ImageWMS',
                                  options={
                                      'url':
                                      'http://localhost:8181/geoserver/wms',
                                      'params': {
                                          'LAYERS': selected_layer
                                      },
                                      'serverType': 'geoserver'
                                  },
                                  legend_title=legend_title,
                                  legend_extent=[-114, 36.5, -109, 42.5],
                                  legend_classes=[
                                      MVLegendClass('polygon',
                                                    'County',
                                                    fill='#999999'),
                                  ])

        map_layers.append(geoserver_layer)

    view_options = MVView(projection='EPSG:4326',
                          center=[-100, 40],
                          zoom=4,
                          maxZoom=18,
                          minZoom=2)

    map_options = MapView(height='500px',
                          width='100%',
                          layers=map_layers,
                          legend=True,
                          view=view_options)

    context = {'map_options': map_options, 'select_options': select_options}

    return render(request, 'cultivar/map.html', context)
def map(request):
    """
    Controller for the app map page.
    """
    event_id_list = [('None', 'none'),
                     ('Joseph Smith Birthplace Memorial', 'ID_00000'),
                     ('Smith Family Farm - Palmyra, New York', 'ID_00001'),
                     ('The Sacred Grove', 'ID_00002'),
                     ('Hill Cumorah', 'ID_00003'),
                     ('Harmony, Pennsylvania', 'ID_00004'),
                     ('Grandin Building', 'ID_00005'),
                     ('Peter Whitmer Farm', 'ID_00006'),
                     ('Newel K. Whitney Store', 'ID_00007'),
                     ('Independence, Missouri', 'ID_00008'),
                     ('Kirtland Temple', 'ID_00009'),
                     ('Far West, Missouri', 'ID_00010'),
                     ('Liberty Jail', 'ID_00011'),
                     ('Nauvoo, Illinois', 'ID_00012'),
                     ('Nauvoo Temple', 'ID_00013'),
                     ('Carthage Jail', 'ID_00014'),
                     ('Nauvoo House, Nauvoo, Illinois', 'ID_00015'),
                     ('Smith Burial Site', 'ID_00016')]

    select_input = SelectInput(display_text='Select Event',
                               name='select_event',
                               multiple=False,
                               options=event_id_list,
                               initial=['None'],
                               original=['None'])
    context = {'select_input': select_input}

    return render(request, 'church_event_history/map.html', context)
示例#21
0
def home(request):
    """
    Controller for the app home page.
    """

    # add_points()
    # add_polygons()

    counties_options = get_counties_options()

    select_counties_input = SelectInput(
        display_text='Select County(s)',
        name='select-county',
        multiple=True,
        original=False,
        options=counties_options,
        # initial=counties_options[0],
        attributes={'id': 'select-county'})

    context = {
        'select_counties_input': select_counties_input,
        'geoserver_wms_url': geoserver_wms_url
    }

    return render(request, 'glo_vli/home.html', context)
示例#22
0
def delete_endpoint(request):
    """
    Controller for the upload layer page.
    """

    endpoint_options = get_endpoint_options()

    layer_list = [(opt['layer_name'], opt['layer_name'])
                  for opt in endpoint_options]

    layer_select_input = SelectInput(
        display_text='Select Endpoint',
        name='layer-select-input',
        multiple=False,
        original=True,
        options=layer_list,
    )

    delete_button = Button(display_text='Delete Layer',
                           icon='glyphicon glyphicon-minus',
                           style='danger',
                           name='submit-delete-endpoint',
                           attributes={'id': 'submit-delete-endpoint'},
                           classes="delete")

    context = {
        'layer_select_input': layer_select_input,
        'delete_button': delete_button
    }

    return render(request, 'glo_dda/delete_endpoint.html', context)
示例#23
0
def home(request):
    """
    Controller for the app home page.
    """
    # Retrieving HydroServers from CUAHSI Central
    his_servers = []

    his_url = "http://hiscentral.cuahsi.org/webservices/hiscentral.asmx?WSDL"
    client = Client(his_url)
    service_info = client.service.GetWaterOneFlowServiceInfo()
    services = service_info.ServiceInfo
    for i in services:
        try:
            url = str(i.servURL)
            title = str(i.Title)
            organization = str(i.organization)
            variable_str = "Title: %s, Organization: %s" % (title,
                                                            organization)
            his_servers.append([variable_str, url])
        except Exception as e:
            print e
    select_his_server = SelectInput(display_text='Select HIS Server',
                                    name="select_server",
                                    multiple=False,
                                    options=his_servers)

    context = {"select_his_server": select_his_server}

    return render(request, 'hydrocatalog/home.html', context)
示例#24
0
def home(request):
    """
    Controller for the app home page.
    """

    # Pre-populate lat-picker and lon_picker from model
    select_input = SelectInput(
        display_text='Basemap',
        name='select_input',
        multiple=False,
        options=[('Bing', 'bing_layer'), ('MapQuest', 'mapQuest_layer'),
                 ('OpenStreet', 'openstreet_layer'),
                 ('Stamen', 'stamen_layer')],
        original=['Bing'],
        attributes="id=selectInput onchange=run_select_basemap()")

    txtLocation = TextInput(display_text='Location Search:',
                            name="txtLocation",
                            initial="",
                            disabled=False,
                            attributes="onkeypress=handle_search_key(event);")

    btnSearch = Button(display_text="Search",
                       name="btnSearch",
                       attributes="onclick=run_geocoder();",
                       submit=False)

    select_navigation = SelectInput(
        display_text="",
        name='select_navigation',
        multiple=False,
        options=[('Select EPA WATERS Service', 'select'),
                 ('Delineate watershed', 'DeWa'), ('Upstream mainstem', 'UM'),
                 ('Upstream with tributaries', 'UT'),
                 ('Downstream mainstem', 'DM'),
                 ('Downstream with divergences', 'DD')],
        original=['Select EPA WATERS Service'],
        attributes="id=select_navigation onchange=select_function();")

    # Pass variables to the template via the context dictionary
    context = {
        'select_input': select_input,
        'txtLocation': txtLocation,
        'btnSearch': btnSearch,
        'select_navigation': select_navigation
    }
    return render(request, 'watershed_delin/home.html', context)
示例#25
0
def get_layer_select(storage_type):
    select_layer = SelectInput(
        display_text="Select a day",
        name="select-layer",
        multiple=False,
        options=get_grace_timestep_options(storage_type),
    )
    return select_layer
示例#26
0
def region(request):
    """
    Controller for the app home page.
    """
    select_region = SelectInput(display_text='Select Region',
                                name='select_region',
                                multiple=False,
                                options=[('California', "California"),
                                         ('Nepal', "Nepal"),
                                         ('Texas', "Texas"),
                                         ('La Plata', "LaPlata")])
    select_storage_type = SelectInput(
        display_text='Select Storage Component',
        name='select_storage_type',
        multiple=False,
        options=[('', ''),
                 ('Total Water Storage (GRACE)', "GRC_tot.25scaled.nc"),
                 ('Surface Water Storage (GLDAS)', "GRC_SW.nc"),
                 ('Soil Moisture Storage (GLDAS)',
                  "GRC_Soil_Moisture_Total_Anomaly.nc"),
                 ('Groundwater Storage (Calculated)', "GRC_gwtest.nc")],
        initial=[''])
    select_legend = SelectInput(display_text='Select Symbology',
                                name='select_legend',
                                multiple=False,
                                options=[('Grace', "grace"),
                                         ('Blue-red', "bluered"),
                                         ('Red-blue', "redblue"),
                                         ('Rainbow', "rainbow"),
                                         ('Occam', "occam"),
                                         ('ncview', "ncview"),
                                         ('sst_36', "sst_36"),
                                         ('greyscale', "greyscale"),
                                         ('alg2', "alg2"),
                                         ('occam_pastel-30',
                                          "occam_pastel-30"), ('alg', "alg"),
                                         ('ferret', "ferret")],
                                initial=[''])

    context = {
        "select_storage_type": select_storage_type,
        "select_legend": select_legend,
        "select_region": select_region
    }

    return render(request, 'newgrace/region.html', context)
示例#27
0
def add_endpoint(request):

    name_input = TextInput(display_text='Layer Name',
                           name='name-input',
                           placeholder='',
                           attributes={'id': 'name-input'})

    endpoint_input = TextInput(
        display_text='REST Endpoint',
        name='endpoint-input',
        placeholder='e.g.: REST Endpoint',
        attributes={'id': 'endpoint-input'},
    )

    endpoint_type = SelectInput(display_text='Endpoint Type',
                                name='endpoint-type',
                                attributes={'id': 'endpoint-type'},
                                multiple=False,
                                options=[('wfs', 'wfs'), ('wms', 'wms')])

    wms_layers_input = TextInput(display_text='WMS Layer Name',
                                 name='wms-layers-input',
                                 placeholder='e.g.: cite:qpf24hr_day1_latest',
                                 attributes={'id': 'wms-layers-input'},
                                 classes='wms_layer hidden')

    fill_opacity = TextInput(
        display_text='Fill Opacity',
        name='fill-opacity',
        placeholder='e.g.: 0.7. Goes from 0 to 1.',
        attributes={'id': 'fill-opacity'},
    )

    stroke_width = TextInput(
        display_text='Stroke Width',
        name='stroke-width',
        placeholder='e.g.: 2. The thickness of the fill stroke.',
        attributes={'id': 'stroke-width'},
    )

    add_button = Button(display_text='Add Endpoint',
                        icon='glyphicon glyphicon-plus',
                        style='primary',
                        name='submit-add-endpoint',
                        attributes={'id': 'submit-add-endpoint'},
                        classes="add")

    context = {
        "name_input": name_input,
        "endpoint_input": endpoint_input,
        "endpoint_type": endpoint_type,
        "wms_layers_input": wms_layers_input,
        "fill_opacity": fill_opacity,
        "stroke_width": stroke_width,
        "add_button": add_button
    }

    return render(request, 'glo_dda/add_endpoint.html', context)
def add_data_store(request):
    """
    Controller for the app add_data_store page.
    """
    # initialize session
    session_maker = app.get_persistent_store_database('main_db',
                                                      as_sessionmaker=True)
    session = session_maker()

    data_store_name_input = TextInput(display_text='Data Store Server Name',
                                      name='data-store-name-input',
                                      placeholder='e.g.: My CKAN Server',
                                      icon_append='glyphicon glyphicon-tag')

    # Query DB for data store types
    data_store_types = session.query(DataStoreType).filter(
        DataStoreType.id > 1).all()
    data_store_type_list = []
    for data_store_type in data_store_types:
        data_store_type_list.append(
            (data_store_type.human_readable_name, data_store_type.id))

    session.close()

    data_store_type_select_input = \
        SelectInput(display_text='Data Store Type',
                    name='data-store-type-select',
                    options=data_store_type_list,
                    initial=data_store_type_list[0][0])

    data_store_endpoint_input = TextInput(
        display_text='Data Store API Endpoint',
        name='data-store-endpoint-input',
        placeholder='e.g.: http://ciwweb.chpc.utah.edu/api/3/action',
        icon_append='glyphicon glyphicon-cloud-download')

    data_store_owner_org_input = TextInput(
        display_text='Data Store Owner Organization',
        name='data-store-owner_org-input',
        placeholder='e.g.: byu',
        icon_append='glyphicon glyphicon-home')

    add_button = Button(display_text='Add Data Store',
                        icon='glyphicon glyphicon-plus',
                        style='success',
                        name='submit-add-data-store',
                        attributes={'id': 'submit-add-data-store'})

    context = {
        'data_store_name_input': data_store_name_input,
        'data_store_type_select_input': data_store_type_select_input,
        'data_store_endpoint_input': data_store_endpoint_input,
        'data_store_owner_org_input': data_store_owner_org_input,
        'add_button': add_button,
    }

    return render(request, 'streamflow_prediction_tool/add_data_store.html',
                  context)
示例#29
0
def get_storage_type_select():
    select_storage_type = SelectInput(
        display_text="Select Storage Component",
        name="select-storage-type",
        multiple=False,
        options=storage_options(),
        initial=["Total Water Storage (GRACE)"],
    )
    return select_storage_type
示例#30
0
def choose_boundary_country(request):
    project = request.GET.get('project', False)
    if not project:
        messages.error(request, 'Unable to find this project')
        return redirect(
            reverse('geoglows_hydroviewer:geoglows_hydroviewer_creator'))

    regions = SelectInput(
        display_text='Pick A World Region (ESRI Living Atlas)',
        name='regions',
        multiple=False,
        original=True,
        options=(
            ('None', ''),
            ('Antarctica', 'Antarctica'),
            ('Asiatic Russia', 'Asiatic Russia'),
            ('Australia/New Zealand', 'Australia/New Zealand'),
            ('Caribbean', 'Caribbean'),
            ('Central America', 'Central America'),
            ('Central Asia', 'Central Asia'),
            ('Eastern Africa', 'Eastern Africa'),
            ('Eastern Asia', 'Eastern Asia'),
            ('Eastern Europe', 'Eastern Europe'),
            ('European Russia', 'European Russia'),
            ('Melanesia', 'Melanesia'),
            ('Micronesia', 'Micronesia'),
            ('Middle Africa', 'Middle Africa'),
            ('Northern Africa', 'Northern Africa'),
            ('Northern America', 'Northern America'),
            ('Northern Europe', 'Northern Europe'),
            ('Polynesia', 'Polynesia'),
            ('South America', 'South America'),
            ('Southeastern Asia', 'Southeastern Asia'),
            ('Southern Africa', 'Southern Africa'),
            ('Southern Asia', 'Southern Asia'),
            ('Southern Europe', 'Southern Europe'),
            ('Western Africa', 'Western Africa'),
            ('Western Asia', 'Western Asia'),
            ('Western Europe', 'Western Europe'),
        ))

    context = {
        'project':
        project,
        'project_title':
        project.replace('_', ' '),
        'regions':
        regions,
        'geojson':
        bool(
            os.path.exists(
                os.path.join(get_project_directory(project),
                             'boundaries.json'))),
    }
    return render(request,
                  'geoglows_hydroviewer/creator_boundaries_choose.html',
                  context)