diff --git a/scripts/aws/setupdb.sh b/scripts/aws/setupdb.sh
index 7a837514a..e40e8bdc4 100755
--- a/scripts/aws/setupdb.sh
+++ b/scripts/aws/setupdb.sh
@@ -22,7 +22,7 @@ file_to_load=
load_stream=false
load_mapshed=false
-while getopts ":hbsdmf:" opt; do
+while getopts ":hbsdpmf:" opt; do
case $opt in
h)
echo -e $usage
@@ -33,6 +33,8 @@ while getopts ":hbsdmf:" opt; do
load_stream=true ;;
d)
load_drb_streams=true ;;
+ p)
+ load_dep=true ;;
m)
load_mapshed=true ;;
f)
@@ -74,6 +76,16 @@ if [ ! -z "$file_to_load" ] ; then
download_and_load $FILES
fi
+if [ "$load_dep" = "true" ] ; then
+ # Fetch DEP layers
+ FILES=("dep_urban_areas.sql.gz" "dep_municipalities.sql.gz")
+ PATHS=("dep_urbanareas" "dep_municipalities")
+
+ download_and_load $FILES
+ purge_tile_cache $PATHS
+fi
+
+
if [ "$load_boundary" = "true" ] ; then
# Fetch boundary layer sql files
FILES=("boundary_county.sql.gz" "boundary_school_district.sql.gz" "boundary_district.sql.gz" "boundary_huc12.sql.gz" "boundary_huc10.sql.gz" "boundary_huc08.sql.gz")
diff --git a/src/mmw/apps/modeling/tasks.py b/src/mmw/apps/modeling/tasks.py
index 92d62029a..516065ad9 100644
--- a/src/mmw/apps/modeling/tasks.py
+++ b/src/mmw/apps/modeling/tasks.py
@@ -149,11 +149,10 @@ def aoi_resolution(area_of_interest):
def format_quality(model_output):
- measures = ['Biochemical Oxygen Demand',
- 'Total Suspended Solids',
+ measures = ['Total Suspended Solids',
'Total Nitrogen',
'Total Phosphorus']
- codes = ['bod', 'tss', 'tn', 'tp']
+ codes = ['tss', 'tn', 'tp']
def fn(input):
measure, code = input
diff --git a/src/mmw/apps/water_balance/templates/home_page/index.html b/src/mmw/apps/water_balance/templates/home_page/index.html
index c6f2f6eeb..381eea8f7 100644
--- a/src/mmw/apps/water_balance/templates/home_page/index.html
+++ b/src/mmw/apps/water_balance/templates/home_page/index.html
@@ -210,84 +210,84 @@
0.0 cm
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -302,29 +302,29 @@ 0.0 cm
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
diff --git a/src/mmw/js/src/compare/views.js b/src/mmw/js/src/compare/views.js
index 576462b4d..c50d34637 100644
--- a/src/mmw/js/src/compare/views.js
+++ b/src/mmw/js/src/compare/views.js
@@ -234,6 +234,7 @@ var CompareModelingView = Marionette.LayoutView.extend({
ResultView = modelingViews.getResultView(modelPackage, resultModel.get('name'));
this.resultRegion.show(new ResultView({
+ areaOfInterest: this.projectModel.get('area_of_interest'),
model: resultModel,
scenario: this.model,
compareMode: true
diff --git a/src/mmw/js/src/core/utils.js b/src/mmw/js/src/core/utils.js
index c3659d323..04cee6444 100644
--- a/src/mmw/js/src/core/utils.js
+++ b/src/mmw/js/src/core/utils.js
@@ -234,6 +234,10 @@ var utils = {
}
},
+ filterOutOxygenDemand: function(element) {
+ return element.measure !== "Biochemical Oxygen Demand";
+ },
+
// Reverse sorting of a Backbone Collection.
// Taken from http://stackoverflow.com/a/12220415/2053314
reverseSortBy: function(sortByFunction) {
diff --git a/src/mmw/js/src/core/views.js b/src/mmw/js/src/core/views.js
index 3a7575011..9d1f96c00 100644
--- a/src/mmw/js/src/core/views.js
+++ b/src/mmw/js/src/core/views.js
@@ -405,7 +405,7 @@ var MapView = Marionette.ItemView.extend({
} else if (!layer.empty) {
var tileUrl = (layer.url.match(/png/) === null ?
layer.url + '.png' : layer.url),
- zIndex = layer.overlay ? 1 : 0;
+ zIndex = determineZIndex(layer);
_.defaults(layer, {
zIndex: zIndex,
@@ -425,6 +425,21 @@ var MapView = Marionette.ItemView.extend({
layers[layer['display']] = leafletLayer;
});
+ function determineZIndex(layer) {
+ // ZIndex rules to keep coverages under the boundary lines
+ // basemaps: 0
+ // overlay::raster: 1
+ // overlay::vector: 2
+
+ if (!layer.overlay) {
+ return 0;
+ } else if (layer.raster) {
+ return 1;
+ } else {
+ return 2;
+ }
+ }
+
function actOnUI(datum, bool) {
var code = datum.code,
$el = $('#overlays-layer-list #' + code);
diff --git a/src/mmw/js/src/main_water_balance.js b/src/mmw/js/src/main_water_balance.js
index 77caca923..cc5c94bd7 100644
--- a/src/mmw/js/src/main_water_balance.js
+++ b/src/mmw/js/src/main_water_balance.js
@@ -130,10 +130,10 @@ var initBootstrap = function() {
$('[data-toggle="popover"]').each(function(i, popover) {
var $popover = $(popover),
- nlcd = $popover.data('nlcd') || 'default',
+ category = $popover.data('category') || 'default',
template = '',
entry = modificationConfig[$popover.data('name')],
options = {
diff --git a/src/mmw/js/src/modeling/controllers.js b/src/mmw/js/src/modeling/controllers.js
index 9ec16648e..8d2a1d8e8 100644
--- a/src/mmw/js/src/modeling/controllers.js
+++ b/src/mmw/js/src/modeling/controllers.js
@@ -59,6 +59,8 @@ var ModelingController = {
// Send URL to parent if in embed mode
updateItsiFromEmbedMode();
+
+ setPageTitle();
});
})
.fail(function() {
@@ -67,6 +69,8 @@ var ModelingController = {
console.log("[ERROR] Could not load project.");
App.currentProject = null;
});
+
+ App.state.set('current_page_title', 'Modeling');
} else {
if (App.currentProject && settings.get('activityMode')) {
project = App.currentProject;
@@ -85,6 +89,7 @@ var ModelingController = {
var lock = $.Deferred();
if (!App.currentProject) {
+
project = reinstateProject(App.projectNumber, lock);
App.currentProject = project;
@@ -99,9 +104,8 @@ var ModelingController = {
finishProjectSetup(project, lock);
}
+ setPageTitle();
}
-
- App.state.set('current_page_title', 'Model');
},
makeNewProject: function(modelPackage) {
@@ -120,6 +124,7 @@ var ModelingController = {
updateUrl();
}
App.rootView.showCollapsable();
+ setPageTitle();
},
projectCleanUp: function() {
@@ -162,6 +167,8 @@ var ModelingController = {
if (project.get('is_activity')) {
settings.set('activityMode', true);
}
+
+ setPageTitle();
})
.fail(function() {
App.currentProject = null;
@@ -227,6 +234,14 @@ function finishProjectSetup(project, lock) {
});
}
+function setPageTitle() {
+ var modelPackageName = App.currentProject.get('model_package'),
+ modelPackages = settings.get('model_packages'),
+ modelPackageDisplayName = _.find(modelPackages, {name: modelPackageName}).display_name;
+
+ App.state.set('current_page_title', modelPackageDisplayName);
+}
+
function projectCleanUp() {
App.rootView.hideCollapsable();
if (App.currentProject) {
@@ -323,6 +338,7 @@ function reinstateProject(number, lock) {
'areaOfInterest': project.get('area_of_interest'),
'areaOfInterestName': project.get('area_of_interest_name')
});
+ setPageTitle();
lock.resolve();
});
diff --git a/src/mmw/js/src/modeling/tr55/models.js b/src/mmw/js/src/modeling/tr55/models.js
index 38115b318..d9f08c7bb 100644
--- a/src/mmw/js/src/modeling/tr55/models.js
+++ b/src/mmw/js/src/modeling/tr55/models.js
@@ -28,6 +28,12 @@ var AoiVolumeModel = Backbone.Model.extend({
adjust: function(depth) {
// Adjusted runoff is depth (cm) -> meters * the AoI area (m2)
return (depth / 100) * this.get('aoiArea');
+ },
+
+ getLoadingRate: function(load) {
+ // The loadingRate is the load per hectare.
+ // The aoiArea is in m^2, so we divide by 10000 to get hectares.
+ return load / (this.get('aoiArea') / 10000);
}
});
diff --git a/src/mmw/js/src/modeling/tr55/quality/templates/table.html b/src/mmw/js/src/modeling/tr55/quality/templates/table.html
index ad936e656..e46ad014d 100644
--- a/src/mmw/js/src/modeling/tr55/quality/templates/table.html
+++ b/src/mmw/js/src/modeling/tr55/quality/templates/table.html
@@ -3,6 +3,7 @@
Quality Measure |
Load (kg) |
+ Loading Rate (kg/ha) |
Average Concentration (mg/L) |
diff --git a/src/mmw/js/src/modeling/tr55/quality/templates/tableRow.html b/src/mmw/js/src/modeling/tr55/quality/templates/tableRow.html
index 5862ef3b2..163fabbec 100644
--- a/src/mmw/js/src/modeling/tr55/quality/templates/tableRow.html
+++ b/src/mmw/js/src/modeling/tr55/quality/templates/tableRow.html
@@ -1,3 +1,4 @@
{{ measure }} |
{{ load|round(3)|toLocaleString(3) }} |
+{{ loadingRate|round(3)|toLocaleString(3) }} |
{{ concentration|round(1)|toLocaleString(1) }} |
diff --git a/src/mmw/js/src/modeling/tr55/quality/views.js b/src/mmw/js/src/modeling/tr55/quality/views.js
index 3a1da4cfb..14228bb7f 100644
--- a/src/mmw/js/src/modeling/tr55/quality/views.js
+++ b/src/mmw/js/src/modeling/tr55/quality/views.js
@@ -9,7 +9,8 @@ var $ = require('jquery'),
barChartTmpl = require('../../../core/templates/barChart.html'),
resultTmpl = require('./templates/result.html'),
tableRowTmpl = require('./templates/tableRow.html'),
- tableTmpl = require('./templates/table.html');
+ tableTmpl = require('./templates/table.html'),
+ utils = require('../../../core/utils.js');
var ResultView = Marionette.LayoutView.extend({
className: 'tab-pane',
@@ -46,12 +47,14 @@ var ResultView = Marionette.LayoutView.extend({
if (this.model.get('result')) {
if (this.compareMode) {
this.chartRegion.show(new CompareChartView({
- model: this.model
+ model: this.model,
+ aoiVolumeModel: this.aoiVolumeModel
}));
} else {
var dataCollection = new Backbone.Collection(
- this.model.get('result').quality
- );
+ this.model.get('result').quality.filter(
+ utils.filterOutOxygenDemand
+ ));
this.tableRegion.show(new TableView({
aoiVolumeModel: this.aoiVolumeModel,
@@ -59,6 +62,7 @@ var ResultView = Marionette.LayoutView.extend({
}));
this.chartRegion.show(new ChartView({
+ aoiVolumeModel: this.aoiVolumeModel,
model: this.model,
collection: dataCollection
}));
@@ -75,9 +79,11 @@ var TableRowView = Marionette.ItemView.extend({
var load = this.model.get('load'),
runoff = this.model.get('runoff'),
adjustedRunoff = this.options.aoiVolumeModel.adjust(runoff),
+ loadingRate = this.options.aoiVolumeModel.getLoadingRate(load),
concentration = adjustedRunoff ? load / adjustedRunoff : 0;
return {
+ loadingRate: loadingRate,
concentration: concentration * 1000 // g -> mg
};
}
@@ -113,14 +119,16 @@ var ChartView = Marionette.ItemView.extend({
addChart: function() {
var chartEl = this.$el.find('.bar-chart').get(0),
+ aoiVolumeModel = this.options.aoiVolumeModel,
data = this.collection.map(function(model) {
+ var load = model.attributes.load;
return {
x: model.attributes.measure,
- y: model.attributes.load
+ y: aoiVolumeModel.getLoadingRate(load)
};
}),
chartOptions = {
- yAxisLabel: 'Load (kg)',
+ yAxisLabel: 'Loading Rate (kg/ha)',
abbreviateTicks: true
};
@@ -148,12 +156,13 @@ var CompareChartView = Marionette.ItemView.extend({
addChart: function() {
function getData(result, seriesDisplayNames) {
return _.map(seriesDisplayNames, function(seriesDisplayName, seriesInd) {
+ var load = result[seriesInd].load;
return {
key: seriesDisplayName,
values: [
{
x: '',
- y: result[seriesInd].load
+ y: aoiVolumeModel.getLoadingRate(load),
}
]
};
@@ -161,22 +170,21 @@ var CompareChartView = Marionette.ItemView.extend({
}
var chartEl = this.$el.find('.bar-chart').get(0),
- result = this.model.get('result').quality,
- seriesDisplayNames = ['Oxygen Demand',
- 'Suspended Solids',
+ result = this.model.get('result').quality.filter(utils.filterOutOxygenDemand),
+ aoiVolumeModel = this.options.aoiVolumeModel,
+ seriesDisplayNames = ['Suspended Solids',
'Nitrogen',
'Phosphorus'],
data,
chartOptions;
$(chartEl).empty();
-
if (result) {
data = getData(result, seriesDisplayNames);
chartOptions = {
- seriesColors: ['#1589ff', '#4aeab3', '#4ebaea', '#329b9c'],
- yAxisLabel: 'Load (kg)',
- yAxisUnit: 'kg',
+ seriesColors: ['#4aeab3', '#4ebaea', '#329b9c'],
+ yAxisLabel: 'Loading Rate (kg/ha)',
+ yAxisUnit: 'kg/ha',
margin: {top: 20, right: 0, bottom: 40, left: 60},
reverseLegend: this.compareMode,
disableToggle: true,
diff --git a/src/mmw/mmw/settings/data/pa_perimeter.json b/src/mmw/mmw/settings/data/pa_perimeter.json
new file mode 100644
index 000000000..33aa13f26
--- /dev/null
+++ b/src/mmw/mmw/settings/data/pa_perimeter.json
@@ -0,0 +1 @@
+{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-75.11352539062499,42.0125705565935],[-79.7607421875,42.01665183556825],[-79.78271484375,42.27730877423709],[-80.5352783203125,41.97174336327968],[-80.52978515625,39.690280594818034],[-75.43212890625,39.740986355883564],[-74.7509765625,40.16208338164619],[-75.04486083984375,40.84913799774759],[-74.68505859374999,41.42625319507272],[-75.0146484375,41.68932225997044],[-75.11352539062499,42.0125705565935]]]}}
diff --git a/src/mmw/mmw/settings/layer_settings.py b/src/mmw/mmw/settings/layer_settings.py
index b625f3fca..00368cfc6 100644
--- a/src/mmw/mmw/settings/layer_settings.py
+++ b/src/mmw/mmw/settings/layer_settings.py
@@ -21,6 +21,11 @@
drb_perimeter_file = open(drb_perimeter_path)
drb_perimeter = json.load(drb_perimeter_file)
+# Simplified perimeter of PA, used for DEP specific layers
+pa_perimeter_path = join(dirname(abspath(__file__)), 'data/pa_perimeter.json')
+pa_perimeter_file = open(pa_perimeter_path)
+pa_perimeter = json.load(pa_perimeter_file)
+
LAYERS = [
{
'code': 'huc8',
@@ -205,6 +210,28 @@
'googleType': 'TERRAIN', # SATELLITE, ROADMAP, HYBRID, or TERRAIN
'maxZoom': 20,
'basemap': True,
+ },
+ {
+ 'code': 'municipalities',
+ 'table_name': 'dep_municipalities',
+ 'display': 'PA Municipalities',
+ 'short_display': 'PA Municipalities',
+ 'vector': True,
+ 'overlay': True,
+ 'minZoom': 7,
+ 'perimeter': pa_perimeter,
+ },
+ {
+ 'code': 'urban_areas',
+ 'table_name': 'dep_urban_areas',
+ 'display': 'PA Urbanized Areas',
+ 'short_display': 'PA Urbanized Areas',
+ 'raster': True,
+ 'overlay': True,
+ 'minZoom': 7,
+ 'opacity': 0.618,
+ 'has_opacity_slider': True,
+ 'perimeter': pa_perimeter,
}
]
diff --git a/src/mmw/sass/base/_map.scss b/src/mmw/sass/base/_map.scss
index 7a78ec8cc..4c2fe5eab 100644
--- a/src/mmw/sass/base/_map.scss
+++ b/src/mmw/sass/base/_map.scss
@@ -77,7 +77,7 @@
height: 100%;
}
-#overlay-subclass-vector .disabled {
+#overlay-subclass-vector .disabled, #overlay-subclass-raster .disabled {
color: $black-54;
}
@@ -102,7 +102,7 @@
float: right;
}
-.leaflet-top {
+.leaflet-control-container .leaflet-top {
top: 45px;
}
diff --git a/src/mmw/sass/pages/_water-balance.scss b/src/mmw/sass/pages/_water-balance.scss
index 8fca05074..eaf37c6d5 100644
--- a/src/mmw/sass/pages/_water-balance.scss
+++ b/src/mmw/sass/pages/_water-balance.scss
@@ -414,6 +414,7 @@
&:after {
background-color: $nlcd-71;
+ color: #333;
}
}
@@ -422,6 +423,7 @@
&:after {
background-color: $nlcd-81;
+ color: #333;
}
}
@@ -438,6 +440,41 @@
&:after {
background-color: $nlcd-90;
+ color: #333;
+ }
+ }
+
+ &.soil-a {
+ border-color: $soil-a;
+
+ &:after {
+ background-color: $soil-a;
+ color: #333;
+ }
+ }
+
+ &.soil-b {
+ border-color: $soil-b;
+
+ &:after {
+ background-color: $soil-b;
+ color: #333;
+ }
+ }
+
+ &.soil-c {
+ border-color: $soil-c;
+
+ &:after {
+ background-color: $soil-c;
+ }
+ }
+
+ &.soil-d {
+ border-color: $soil-d;
+
+ &:after {
+ background-color: $soil-d;
}
}
}
@@ -533,6 +570,24 @@
background-color: $nlcd-90;
color: #333;
}
+
+ &.soil-a {
+ background-color: $soil-a;
+ color: #333;
+ }
+
+ &.soil-b {
+ background-color: $soil-b;
+ color: #333;
+ }
+
+ &.soil-c {
+ background-color: $soil-c;
+ }
+
+ &.soil-d {
+ background-color: $soil-d;
+ }
}
.popover-content {
diff --git a/src/tiler/server.js b/src/tiler/server.js
index 0a9528813..d9fcf608a 100644
--- a/src/tiler/server.js
+++ b/src/tiler/server.js
@@ -34,7 +34,9 @@ var interactivity = {
huc10: 'boundary_huc10',
huc12: 'boundary_huc12',
'drb_streams': 'drb_streams_50',
- stream: 'nhdflowline'
+ stream: 'nhdflowline',
+ municipalities: 'dep_municipalities',
+ urban_areas: 'dep_urban_areas'
},
shouldCacheRequest = function(req) {
// Caching can happen if the bucket to write to is defined
diff --git a/src/tiler/styles.mss b/src/tiler/styles.mss
index f914db6c3..80df458a2 100644
--- a/src/tiler/styles.mss
+++ b/src/tiler/styles.mss
@@ -7,7 +7,8 @@
#boundary_school_district,
#boundary_huc08,
#boundary_huc10,
-#boundary_huc12 {
+#boundary_huc12,
+#dep_municipalities {
::case {
line-color: #FFF;
line-opacity: 0.5;
@@ -24,6 +25,16 @@
}
}
+#dep_urban_areas {
+ ::case {
+ line-color: #7F7F7F;
+ line-width: 1;
+ }
+ ::fill {
+ polygon-fill: #ccc;
+ }
+}
+
@zoomBase: 0.5;
#drb_streams_50,