Skip to content

Commit

Permalink
Merge branch 'master' into hydroshare_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
krashby4 authored Sep 22, 2020
2 parents 4b4ad4a + f3d68ba commit aa1ab76
Show file tree
Hide file tree
Showing 10 changed files with 821 additions and 312 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name=release_package,
version='1.0.0',
version='1.1.0',
description='Interfaces with the GEOGloWS ECMWF Streamflow model developed by the BYU Hydroinformatics lab.',
long_description='Contains an interactive map interface for retrieving data using the ESRI Dynamic Mapping Service '
'retrieved from the Living Atlas. Includes tools for extracting a subset of the delineated '
Expand Down
4 changes: 4 additions & 0 deletions tethysapp/geoglows_hydroviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def url_maps(self):
UrlMap(name='home',
url=f'{self.root_url}',
controller=f'{self.package}.controllers.home'),

UrlMap(name='hydroshare_view',
url=f'{self.root_url}/hydroshare',
controller=f'{self.package}.controllers.hydroshare_view'),

# handles the requests to get the various plots in the app modals
UrlMap(name='get_streamflow',
Expand Down
63 changes: 63 additions & 0 deletions tethysapp/geoglows_hydroviewer/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,69 @@ def home(request):

return render(request, 'geoglows_hydroviewer/geoglows_hydroviewer.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,

'watersheds_select_input': watersheds_select_input,
}

return render(request, 'geoglows_hydroviewer/hydroshare_view.html', context)


def get_streamflow(request):
reach_id = request.GET['reach_id']
Expand Down
15 changes: 14 additions & 1 deletion tethysapp/geoglows_hydroviewer/public/js/drawBoundaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ function getWatershedComponent(layername) {
opacity: .5,
})
}

function getDrainageLine(layername) {
let region = layername.replace('-drainageline','');
return L.tileLayer.wms('https://geoserver.hydroshare.org/geoserver/wms', {
version: '1.1.0',
layers: 'HS-' + watersheds_hydroshare_ids[region] + ':' + layername + ' ' + layername,
useCache: true,
crossOrigin: false,
format: 'image/png',
transparent: true,
opacity: 1,
})
}
let listlayers = [];
let ctrllayers = {};
let boundary_layer;
Expand Down Expand Up @@ -142,7 +155,7 @@ $("#watersheds_select_input").change(function () {
}
boundary_layer = getWatershedComponent(waterselect + '-boundary').addTo(mapObj);
catchment_layer = getWatershedComponent(waterselect + '-catchment');
drainage_layer = getWatershedComponent(waterselect + '-drainageline');
drainage_layer = getDrainageLine(waterselect + '-drainageline');
ctrllayers = {
'Watershed Boundary': boundary_layer,
'Catchment Boundaries': catchment_layer,
Expand Down
Loading

0 comments on commit aa1ab76

Please sign in to comment.