Ejemplo n.º 1
0
def home(request):
    """
    Controller for the app home page.
    """
    # Tiled ArcGIS REST Layer
    arc_gis_layer2 = MVLayer(
        source='TileArcGISRest',
        options={'url': 'https://services.nationalmap.gov/arcgis/rest/services/wbd/MapServer'},
        legend_title='Watershed Boundaries',
        legend_extent=[-173, 17, -65, 72]
    )

    nwm_example_map = MapView(
        height='100%',
        width='100%',
        layers=[arc_gis_layer2],
        basemap='OpenStreetMap',
        legend = True
    )

    medium_range_button = Button(
        display_text='Medium Range',
        name='medium-range-button',
        icon='glyphicon glyphicon-plus',
        style='success',
        href=reverse('nwm_example:medium_range')
    )

    short_range_button = Button(
        display_text='Short Range',
        name='short-range-button',
        icon='glyphicon glyphicon-plus',
        style='success',
        href=reverse('nwm_example:short_range')
    )

    context = {
        'nwm_example_map': nwm_example_map,
        'medium_range_button': medium_range_button,
        'short_range_button': short_range_button
    }

    return render(request, 'nwm_example/home.html', context)
def home(request, app_workspace):
    """
    Controller for the app home page.
    """

    # Get list of projects and create projects MVLayer:
    projects = get_all_projects()
    ww_features = []
    w_features = []
    sw_features = []
    fac_features = []
    golf_features = []
    transp_features = []
    lat_list = []
    lng_list = []

    for project in projects:
        if project.latitude != 0 and project.longitude != 0:
            lat_list.append(project.latitude)
            lng_list.append(project.longitude)

            project_feature = {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': [project.longitude, project.latitude],
                },
                'properties': {
                    'id': project.id,
                    'facility_id': project.facility_id,
                    'project': project.project,
                    'est_cost': project.est_cost,
                    'const_year': project.const_year,
                    'category': project.category,
                    'description': project.description,
                    'priority': project.priority,
                    'est_year': project.est_year,
                    'const_cost': project.const_cost
                }
            }

            if project.category == "Wastewater":
                ww_features.append(project_feature)
            elif project.category == "Stormwater":
                sw_features.append(project_feature)
            elif project.category == "Facilities":
                fac_features.append(project_feature)
            elif project.category == "Golf":
                golf_features.append(project_feature)
            elif project.category == "Transportation":
                fac_features.append(project_feature)
            else:
                w_features.append(project_feature)

    new_file_path = os.path.join(app_workspace.path, "icon.gif")
    print(app_workspace.path)

    # Define GeoJSON FeatureCollections
    sw_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': sw_features
    }
    w_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': w_features
    }
    ww_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': ww_features
    }
    fac_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': fac_features
    }
    golf_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': golf_features
    }
    transp_projects_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': transp_features
    }

    # sw_style = {'ol.style.Style': {
    #     'image': {'ol.style.RegularShape': {
    #         'radius': 10,
    #         'points': 4,
    #         'angle': np.pi / 4,
    #         'fill': {'ol.style.Fill': {
    #             'color':  '#03fc45'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}
    sw_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src': '/static/project_inventory/images/Stormwater.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }

    fac_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src': '/static/project_inventory/images/facilities.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }

    ww_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src': '/static/project_inventory/images/WW.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }
    w_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src': '/static/project_inventory/images/Water.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }
    golf_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src': '/static/project_inventory/images/Golf.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }
    transp_style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Icon': {
                    'src':
                    '/static/project_inventory/images/Transportation.png',
                    'scale': 0.09,
                    # 'points': 4,
                    # 'angle': np.pi / 4,
                    # 'fill': {'ol.style.Fill': {
                    #     'color': '#03fc45'
                    # }},
                    # 'stroke': {'ol.style.Stroke': {
                    #     'color': '#ffffff',
                    #     'width': 1
                }
            },
        }
    }
    # w_style = {'ol.style.Style': {
    #     'image': {'ol.style.Circle': {
    #         'radius': 10,
    #         'fill': {'ol.style.Fill': {
    #             'color': '#d84e1f'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}

    # ww_style = {'ol.style.Style': {
    #     'image': {'ol.style.RegularShape': {
    #         'radius': 10,
    #         'points': 3,
    #         'rotation': np.pi / 4,
    #         'angle': 0,
    #         'fill': {'ol.style.Fill': {
    #             'color': '#fc0303'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}

    # fac_style = {'ol.style.Style': {
    #     'image': {'ol.style.Circle': {
    #         'radius': 10,
    #         'fill': {'ol.style.Fill': {
    #             'color': '#fcba03'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}

    # golf_style = {'ol.style.Style': {
    #     'image': {'ol.style.Circle': {
    #         'radius': 10,
    #         'fill': {'ol.style.Fill': {
    #             'color': '#a6a49f'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}

    # transp_style = {'ol.style.Style': {
    #     'image': {'ol.style.Circle': {
    #         'radius': 10,
    #         'fill': {'ol.style.Fill': {
    #             'color': '#c000fa'
    #         }},
    #         'stroke': {'ol.style.Stroke': {
    #             'color': '#ffffff',
    #             'width': 1
    #         }}
    #     }}
    # }}

    # Create a Map View Layer
    sw_projects_layer = MVLayer(source='GeoJSON',
                                options=sw_projects_feature_collection,
                                legend_title='Stormwater Projects',
                                layer_options={'style': sw_style},
                                feature_selection=True)
    w_projects_layer = MVLayer(source='GeoJSON',
                               options=w_projects_feature_collection,
                               legend_title='Water Projects',
                               layer_options={'style': w_style},
                               feature_selection=True)
    ww_projects_layer = MVLayer(source='GeoJSON',
                                options=ww_projects_feature_collection,
                                legend_title='Wastewater Projects',
                                layer_options={'style': ww_style},
                                feature_selection=True)
    fac_projects_layer = MVLayer(source='GeoJSON',
                                 options=fac_projects_feature_collection,
                                 legend_title='Facilities Projects',
                                 layer_options={'style': fac_style},
                                 feature_selection=True)
    golf_projects_layer = MVLayer(
        source='GeoJSON',
        options=golf_projects_feature_collection,
        legend_title='Golf Projects',
        # legend_classes=[MVLegendClass('point', 'Golf Projects', fill='rgba(0,0,255,0.1)', stroke='blue')],
        layer_options={'style': golf_style},
        feature_selection=True)
    transp_projects_layer = MVLayer(source='GeoJSON',
                                    options=transp_projects_feature_collection,
                                    legend_title='Transportation Projects',
                                    layer_options={'style': transp_style},
                                    feature_selection=True)

    # Define view centered on project locations
    # try:
    #     view_center = [sum(lng_list) / float(len(lng_list)), sum(lat_list) / float(len(lat_list))]
    # except ZeroDivisionError:
    view_center = [-103.28, 47.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=12.5,
                          maxZoom=18,
                          minZoom=2)

    project_inventory_map = MapView(
        height='100%',
        width='100%',
        layers=[
            sw_projects_layer, w_projects_layer, ww_projects_layer,
            fac_projects_layer, golf_projects_layer, transp_projects_layer
        ],
        basemap=[
            'OpenStreetMap',
            # 'CartoDB',
            # {'CartoDB': {'style': 'dark'}},
            # 'Stamen',
            # 'ESRI'
        ],
        view=view_options,
        # legend=True
    )

    add_project_button = Button(display_text='Add Project',
                                name='add-project-button',
                                icon='glyphicon glyphicon-plus',
                                style='success',
                                href=reverse('project_inventory:add_project'))

    context = {
        'project_inventory_map': project_inventory_map,
        'add_project_button': add_project_button,
        # 'can_add_projects': has_permission(request, 'add_projects')
    }

    return render(request, 'project_inventory/home.html', context)
Ejemplo n.º 3
0
def home(request):
    """
    Controller for the app home page.
    """

    compute_button = Button(display_text='Calcular',
                            name='compute-button',
                            href=reverse('dr_water_allocation:results'),
                            attributes={"onclick": compute_water()})

    diversion_points_list = get_all_diversions()
    dam_list = get_all_dams()
    features = []
    features_dam = []

    for item in diversion_points_list:
        diversion_point_feature = {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [item.latitude, item.longitude],
            },
            'properties': {
                'point_name': item.name,
                'demand': item.demand,
                'efficiency': item.efficiency,
                'priority': item.priority,
                'type': 'diversion'
            }
        }
        features.append(diversion_point_feature)

    for item in dam_list:
        dam_point_feature = {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [item.latitude, item.longitude],
            },
            'properties': {
                'point_name': item.name,
                'output': item.output,
                'type': 'dam'
            }
        }
        features_dam.append(dam_point_feature)

    diversion_points_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features,
    }

    dam_points_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features_dam,
    }

    geojson_diversion_point_layer = MVLayer(
        source='GeoJSON',
        options=diversion_points_collection,
        legend_title="Diversion Points",
        feature_selection=True,
        layer_options={
            'style': {
                'image': {
                    'circle': {
                        'radius': 6,
                        'fill': {
                            'color': '#d84e1f'
                        },
                        'stroke': {
                            'color': '#ffffff',
                            'width': 1
                        },
                    }
                }
            }
        })

    geojson_dam_point_layer = MVLayer(source='GeoJSON',
                                      options=dam_points_collection,
                                      legend_title="Diversion Points",
                                      feature_selection=True,
                                      layer_options={
                                          'style': {
                                              'image': {
                                                  'circle': {
                                                      'radius': 6,
                                                      'fill': {
                                                          'color': '#f9f32f'
                                                      },
                                                      'stroke': {
                                                          'color': '#ffffff',
                                                          'width': 1
                                                      },
                                                  }
                                              }
                                          }
                                      })

    view_options = MVView(projection='EPSG:4326',
                          center=[-70.8, 18.56],
                          zoom=10,
                          maxZoom=18,
                          minZoom=2)

    map_view_options = MapView(
        height='100%',
        width='100%',
        controls=[
            'Rotate', 'FullScreen', {
                'MousePosition': {
                    'projection': 'EPSG:4326'
                }
            }, {
                'ZoomToExtent': {
                    'projection': 'EPSG:4326',
                    'extent': [-130, 22, -65, 54]
                }
            }
        ],
        layers=[geojson_diversion_point_layer, geojson_dam_point_layer],
        view=view_options,
        basemap='OpenStreetMap',
    )

    context = {
        'compute_button': compute_button,
        'map_view_options': map_view_options,
    }

    return render(request, 'dr_water_allocation/home.html', context)
Ejemplo n.º 4
0
def Datamap(request, app_workspace):
    """
    Controller for the background page.
    """
    waters = get_all_water(app_workspace.path)
    features = []
    lat_list = []
    lng_list = []

    # Define GeoJSON Features
    for water in waters:
        water_location = water.pop('location')
        lat_list.append(water_location['coordinates'][1])
        lng_list.append(water_location['coordinates'][0])

        water_feature = {
            'type': 'Feature',
            'geometry': {
                'type': water_location['type'],
                'coordinates': water_location['coordinates'],
            }
        }

        features.append(water_feature)

    # Define GeoJSON FeatureCollection
    water_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 10,
                    'fill': {
                        'ol.style.Fill': {
                            'color': '#d84e1f'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': '#ffffff',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    # Create a Map View Layer
    water_layer = MVLayer(source='GeoJSON',
                          options=water_feature_collection,
                          legend_title='Water Samples',
                          layer_options={'style': style})

    # Define view centered on dam locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-159.5, 22.07]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=11,
                          maxZoom=18,
                          minZoom=2)

    water_sample_map = MapView(height='100%',
                               width='100%',
                               layers=[water_layer],
                               basemap='OpenStreetMap',
                               view=view_options)

    add_sample_button = Button(display_text='Add Dam',
                               name='add-sample-button',
                               icon='glyphicon glyphicon-plus',
                               style='success',
                               href=reverse('waimea_flux:New_Data'))

    context = {
        'water_sample_map': water_sample_map,
        'add_sample_button': add_sample_button
    }

    return render(request, 'waimea_flux/Datamap.html', context)
Ejemplo n.º 5
0
def home(request, app_workspace):
    """
    Controller for the app home page.
    """
    # Get list of dams and create dams MVLayer:
    dams = get_all_dams(app_workspace.path)
    features = []
    lat_list = []
    lng_list = []

    # Define GeoJSON Features
    for dam in dams:
        dam_location = dam.pop('location')
        lat_list.append(dam_location['coordinates'][1])
        lng_list.append(dam_location['coordinates'][0])

        dam_feature = {
            'type': 'Feature',
            'geometry': {
                'type': dam_location['type'],
                'coordinates': dam_location['coordinates'],
            }
        }
        features.append(dam_feature)

    # Define GeoJSON FeatureCollection
    dams_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 10,
                    'fill': {
                        'ol.style.Fill': {
                            'color': '#d84e1f'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': '#ffffff',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    # Create a Map View Layer
    dams_layer = MVLayer(source='GeoJSON',
                         options=dams_feature_collection,
                         legend_title='Dams',
                         layer_options={'style': style})

    # Define view centered on dam locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=4.5,
                          maxZoom=18,
                          minZoom=2)

    dam_inventory_map = MapView(height='100%',
                                width='100%',
                                layers=[dams_layer],
                                basemap='OpenStreetMap',
                                view=view_options)

    add_dam_button = Button(display_text='Add Dam',
                            name='add-dam-button',
                            icon='glyphicon glyphicon-plus',
                            style='success',
                            href=reverse('dam_inventory:add_dam'))

    save_button = Button(display_text='',
                         name='save-button',
                         icon='glyphicon glyphicon-floppy-disk',
                         style='success',
                         attributes={
                             'data-toggle': 'tooltip',
                             'data-placement': 'top',
                             'title': 'Save'
                         })

    edit_button = Button(display_text='',
                         name='edit-button',
                         icon='glyphicon glyphicon-edit',
                         style='warning',
                         attributes={
                             'data-toggle': 'tooltip',
                             'data-placement': 'top',
                             'title': 'Edit'
                         })

    remove_button = Button(display_text='',
                           name='remove-button',
                           icon='glyphicon glyphicon-remove',
                           style='danger',
                           attributes={
                               'data-toggle': 'tooltip',
                               'data-placement': 'top',
                               'title': 'Remove'
                           })

    previous_button = Button(display_text='Previous',
                             name='previous-button',
                             attributes={
                                 'data-toggle': 'tooltip',
                                 'data-placement': 'top',
                                 'title': 'Previous'
                             })

    next_button = Button(display_text='Next',
                         name='next-button',
                         attributes={
                             'data-toggle': 'tooltip',
                             'data-placement': 'top',
                             'title': 'Next'
                         })

    context = {
        'save_button': save_button,
        'edit_button': edit_button,
        'remove_button': remove_button,
        'previous_button': previous_button,
        'next_button': next_button,
        'dam_inventory_map': dam_inventory_map,
        'add_dam_button': add_dam_button
    }

    return render(request, 'dam_inventory/home.html', context)
Ejemplo n.º 6
0
def home(request, app_workspace):
    """
    Controller for the app home page.
    """
    # Get list of places and create places MVLayer:
    places = get_all_places(app_workspace.path)
    features = []
    lat_list = []
    lng_list = []

    # Define GeoJSON Features
    for place in places:
        place_location = place.pop('location')
        lat_list.append(place_location['coordinates'][1])
        lng_list.append(place_location['coordinates'][0])

        place_feature = {
            'type': 'Feature',
            'geometry': {
                'type': place_location['type'],
                'coordinates': place_location['coordinates'],
            }
        }

        features.append(place_feature)

    # Define GeoJSON FeatureCollection
    places_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 10,
                    'fill': {
                        'ol.style.Fill': {
                            'color': '#d84e1f'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': '#ffffff',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    # Create a Map View Layer
    places_layer = MVLayer(source='GeoJSON',
                           options=places_feature_collection,
                           legend_title='Places',
                           layer_options={'style': style})

    # Define view centered on place locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-84.079149, 9.933149]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=8.5,
                          maxZoom=18,
                          minZoom=2)

    vacationeer_map = MapView(height='100%',
                              width='100%',
                              layers=[places_layer],
                              basemap='OpenStreetMap',
                              view=view_options)

    add_place_button = Button(display_text='Add place',
                              name='add-place-button',
                              icon='glyphicon glyphicon-plus',
                              style='success',
                              href=reverse('vacationeer:add_place'))

    context = {
        'vacationeer_map': vacationeer_map,
        'add_place_button': add_place_button
    }

    return render(request, 'vacationeer/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """
    # Get list of sensors and create sensors MVLayer:
    sensors = get_all_sensors()
    features = []
    lat_list = []
    lng_list = []

    if sensors is not None:
        for sensor in sensors:
            lat_list.append(sensor.latitude)
            lng_list.append(sensor.longitude)

            sensor_feature = {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': [sensor.longitude, sensor.latitude]
                },
                'properties': {
                    'id': sensor.id,
                    'latitude': sensor.latitude,
                    'longitude': sensor.longitude
                }
            }
            features.append(sensor_feature)

    # Define GeoJSON FeatureCollection
    sensors_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    # Create a Map View Layer
    sensors_layer = MVLayer(source='GeoJSON',
                            options=sensors_feature_collection,
                            legend_title='Sensors',
                            layer_options={
                                'style': {
                                    'image': {
                                        'circle': {
                                            'radius': 8,
                                            'fill': {
                                                'color': '#d84e1f'
                                            },
                                            'stroke': {
                                                'color': '#ffffff',
                                                'width': 1
                                            },
                                        }
                                    }
                                }
                            },
                            feature_selection=True)

    # Define view centered on sensor locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=4.5,
                          maxZoom=18,
                          minZoom=2)

    sensor_map = MapView(height='100%',
                         width='100%',
                         layers=[sensors_layer],
                         basemap='OpenStreetMap',
                         view=view_options)

    context = {
        'sensor_map': sensor_map,
    }

    return render(request, 'open_air/home.html', context)
Ejemplo n.º 8
0
def map_blooms(request, app_workspace):
    """
    Controller for the background page.
    """

    # Get list of blooms and create blooms MVLayer:
    blooms = get_all_blooms(app_workspace.path)
    features = []
    lat_list = []
    lng_list = []

    # Define GeoJSON Features
    for bloom in blooms:
        bloom_mapdraw = bloom.pop('mapdraw')
        lat_list.append(bloom_mapdraw['coordinates'][1])
        lng_list.append(bloom_mapdraw['coordinates'][0])

        bloom_feature = {
            'type': 'Feature',
            'geometry': {
                'type': bloom_mapdraw['type'],
                'coordinates': bloom_mapdraw['coordinates'],
            }
        }

        features.append(bloom_feature)

    # Define GeoJSON FeatureCollection
    blooms_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 10,
                    'fill': {
                        'ol.style.Fill': {
                            'color': '#d84e1f'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': '#ffffff',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    # Create a Map View Layer
    blooms_layer = MVLayer(source='GeoJSON',
                           options=blooms_feature_collection,
                           legend_title='Blooms',
                           layer_options={'style': style})

    # Define view centered on dam locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=7,
                          maxZoom=18,
                          minZoom=2)

    algal_bloom_map = MapView(
        height='100%',
        width='100%',
        layers=[blooms_layer],
        basemap='OpenStreetMap',
        view=view_options,
    )

    new_bloom_button = Button(display_text='New Bloom',
                              name='new_bloom-button',
                              icon='glyphicon glyphicon-plus',
                              style='success',
                              href=reverse('utah_algal_blooms:new_bloom'))

    context = {
        'algal_bloom_map': algal_bloom_map,
        'new_bloom_button': new_bloom_button
    }

    return render(request, 'utah_algal_blooms/map_blooms.html', context)
Ejemplo n.º 9
0
def home(request):
    """
    Controller for the app home page.
    """
    # Get list of dams and create dams MVLayer:
    dams = get_all_dams()
    features = []
    lat_list = []
    lng_list = []

    for dam in dams:
        lat_list.append(dam.latitude)
        lng_list.append(dam.longitude)

        dam_feature = {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [dam.longitude, dam.latitude],

            },
            'properties': {
                'id': dam.id,
                'name': dam.name,
                'owner': dam.owner,
                'river': dam.river,
                'date_built': dam.date_built
            }
        }
        features.append(dam_feature)

    # Define GeoJSON FeatureCollection
    dams_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    # Create a Map View Layer
    dams_layer = MVLayer(
        source='GeoJSON',
        options=dams_feature_collection,
        legend_title='Dams',
        layer_options={
            'style': {
                'image': {
                    'circle': {
                        'radius': 10,
                        'fill': {'color':  '#d84e1f'},
                        'stroke': {'color': '#ffffff', 'width': 1},
                    }
                }
            }
        }
    )

    # Define view centered on dam locations
    try:
        view_center = [sum(lng_list) / float(len(lng_list)), sum(lat_list) / float(len(lat_list))]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(
        projection='EPSG:4326',
        center=view_center,
        zoom=4.5,
        maxZoom=18,
        minZoom=2
    )

    dam_inventory_map = MapView(
        height='100%',
        width='100%',
        layers=[dams_layer],
        basemap='OpenStreetMap',
        view=view_options
    )

    add_dam_button = Button(
        display_text='Add Dam',
        name='add-dam-button',
        icon='glyphicon glyphicon-plus',
        style='success',
        href=reverse('dam_inventory:add_dam')
    )

    context = {
        'dam_inventory_map': dam_inventory_map,
        'add_dam_button': add_dam_button
    }

    return render(request, 'dam_inventory/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """

    data = getAllData(testingHomePage=True)
    features = []
    lat_list = []
    long_list = []

    for index, row in data.iterrows():
        lat_list.append(row['latitude'])
        long_list.append(row['longitude'])
        location_feature = {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [row['longitude'], row['latitude']],
            },
            'properties': {
                'location_id': row['location_id'],
                'latitude': row['latitude'],
                'longitude': row['longitude'],
                'county_state': row['county_state'],
                'prcp': row['prcp'],
                'tave': row['tave'],
                'tmin': row['tmin'],
                'tmax': row['tmax']
            }
        }
        features.append(location_feature)

    locations_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }
    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 1,
                    'fill': {
                        'ol.style.Fill': {
                            'color': 'rgba(255, 255, 0, 0.01)'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': 'rgba(255, 255, 0, 0.01)',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    locations_layer = MVLayer(source='GeoJSON',
                              options=locations_feature_collection,
                              legend_title='Locations',
                              layer_options={'style': style},
                              feature_selection=True)

    try:
        view_center = [
            sum(long_list) / float(len(long_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=4.5,
                          maxZoom=18,
                          minZoom=2)

    precip_by_location_map = MapView(height='100%',
                                     width='100%',
                                     layers=[locations_layer],
                                     basemap='OpenStreetMap',
                                     view=view_options)

    context = {
        'precip_by_location_map': precip_by_location_map,
    }

    return render(request, 'precip_by_location/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """
    # Get list of dams and create dams MVLayer:
    dams = get_all_dams()
    features = []
    lat_list = []
    lng_list = []

    for dam in dams:
        dam_location = dam.pop('location')
        lat_list.append(dam_location['coordinates'][1])
        lng_list.append(dam_location['coordinates'][0])

        dam_feature = {
            'type': 'Feature',
            'geometry': {
                'type': dam_location['type'],
                'coordinates': dam_location['coordinates'],
            }
        }

        features.append(dam_feature)

    dams_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    dams_layer = MVLayer(source='GeoJSON',
                         options=dams_feature_collection,
                         legend_title='Dams')

    # Define view centered on dam locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=6,
                          maxZoom=18,
                          minZoom=2)

    dam_inventory_map = MapView(height='100%',
                                width='100%',
                                layers=[dams_layer],
                                basemap='OpenStreetMap',
                                view=view_options)

    add_dam_button = Button(display_text='Add Dam',
                            name='add-dam-button',
                            icon='glyphicon glyphicon-plus',
                            style='success',
                            href=reverse('dam_inventory:add_dam'))

    context = {
        'dam_inventory_map': dam_inventory_map,
        'add_dam_button': add_dam_button
    }

    return render(request, 'dam_inventory/home.html', context)
Ejemplo n.º 12
0
def home(request):
    """
    Controller for the app home page.
    """
    # Get list of wells and create wells MVLayer:
    wells = get_all_wells()
    features = []
    lat_list = []
    lng_list = []

    for well in wells:
        lat_list.append(well.latitude)
        lng_list.append(well.longitude)

        well_feature = {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [well.longitude, well.latitude],
            },
            'properties': {
                'id': well.id,
                'name': well.name,
                'owner': well.owner,
                'river': well.river,
                'date_built': well.date_built
            }
        }

        features.append(well_feature)

    # Define GeoJSON FeatureCollection
    wells_feature_collection = {
        'type': 'FeatureCollection',
        'crs': {
            'type': 'name',
            'properties': {
                'name': 'EPSG:4326'
            }
        },
        'features': features
    }

    style = {
        'ol.style.Style': {
            'image': {
                'ol.style.Circle': {
                    'radius': 10,
                    'fill': {
                        'ol.style.Fill': {
                            'color': '#d84e1f'
                        }
                    },
                    'stroke': {
                        'ol.style.Stroke': {
                            'color': '#ffffff',
                            'width': 1
                        }
                    }
                }
            }
        }
    }

    # Create a Map View Layer
    wells_layer = MVLayer(source='GeoJSON',
                          options=wells_feature_collection,
                          legend_title='Wells',
                          layer_options={'style': style},
                          feature_selection=True)

    # Define view centered on well locations
    try:
        view_center = [
            sum(lng_list) / float(len(lng_list)),
            sum(lat_list) / float(len(lat_list))
        ]
    except ZeroDivisionError:
        view_center = [-98.6, 39.8]

    view_options = MVView(projection='EPSG:4326',
                          center=view_center,
                          zoom=4.5,
                          maxZoom=18,
                          minZoom=2)

    well_inventory_map = MapView(height='100%',
                                 width='100%',
                                 layers=[wells_layer],
                                 basemap='OpenStreetMap',
                                 view=view_options)

    add_well_button = Button(display_text='Add Well',
                             name='add-well-button',
                             icon='glyphicon glyphicon-plus',
                             style='success',
                             href=reverse('well_inventory:add_well'))

    context = {
        'well_inventory_map': well_inventory_map,
        'add_well_button': add_well_button,
        'can_add_wells': has_permission(request, 'add_wells')
    }

    return render(request, 'well_inventory/home.html', context)