Skip to content

Commit

Permalink
Merge branch 'release/1.20.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadain committed Oct 17, 2017
2 parents 9e5f935 + e68c7be commit 8afa4c4
Show file tree
Hide file tree
Showing 31 changed files with 2,745 additions and 363 deletions.
10 changes: 5 additions & 5 deletions src/mmw/apps/bigcz/clients/cuahsi/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ def recursive_asdict(d):
return out


def filter_networkIDs(services, gridded=False):
def filter_networkIDs(services, exclude_gridded=False):
"""
Transforms list of services to list of ServiceIDs, with respect to
given options.
If gridded=False, then GRIDDED services will not be included.
If exclude_gridded=True, then GRIDDED services will not be included.
If no filters apply, we return an empty list to disable filtering.
"""
if not gridded:
if exclude_gridded:
return [str(s['ServiceID']) for s in services
if s['NetworkName'] not in GRIDDED]

Expand Down Expand Up @@ -272,7 +272,7 @@ def search(**kwargs):
bbox = kwargs.get('bbox')
to_date = kwargs.get('to_date')
from_date = kwargs.get('from_date')
gridded = 'gridded' in kwargs.get('options')
exclude_gridded = 'exclude_gridded' in kwargs.get('options')

if not bbox:
raise ValidationError({
Expand All @@ -281,7 +281,7 @@ def search(**kwargs):
world = BBox(-180, -90, 180, 90)

services = get_services_in_box(world)
networkIDs = filter_networkIDs(services, gridded)
networkIDs = filter_networkIDs(services, exclude_gridded)
series = get_series_catalog_in_box(bbox, from_date, to_date, networkIDs)
series = group_series_by_location(series)
results = sorted(parse_records(series, services),
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/bigcz/clients/hydroshare/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


CATALOG_NAME = 'hydroshare'
CATALOG_URL = 'https://playground.hydroshare.org/hsapi/resource/'
CATALOG_URL = 'https://www.hydroshare.org/hsapi/resource/'


def parse_date(value):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import ast
import json

from django.db import migrations


def fix_gis_data_serialization(apps, schema_editor):
Project = apps.get_model('modeling', 'Project')
for project in Project.objects.filter(gis_data__startswith='{u'):
project.gis_data = json.dumps(ast.literal_eval(project.gis_data))
project.save()


class Migration(migrations.Migration):

dependencies = [
('modeling', '0022_project_wkaoi'),
]

operations = [
migrations.RunPython(fix_gis_data_serialization,
migrations.RunPython.noop)
]
3 changes: 2 additions & 1 deletion src/mmw/apps/modeling/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Meta:
geo_field = 'area_of_interest'

user = UserSerializer(default=serializers.CurrentUserDefault())
gis_data = JsonField()
gis_data = JsonField(required=False, allow_null=True)
scenarios = ScenarioSerializer(many=True, read_only=True)


Expand All @@ -61,3 +61,4 @@ class Meta:

user = UserSerializer(default=serializers.CurrentUserDefault(),
read_only=True)
gis_data = JsonField(required=False, allow_null=True)
2 changes: 1 addition & 1 deletion src/mmw/js/src/analyze/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ var CatchmentWaterQualityTableView = Marionette.CompositeView.extend({
'nord', data.nord);
this.catchmentPolygon.addTo(map);
map.panInsideBounds(this.catchmentPolygon.getBounds());
var popUpLocationGeoJSON = utils.findCenterOfShapeIntersection(JSON.parse(geom), App.map.get('areaOfInterest'));
var popUpLocationGeoJSON = utils.findCenterOfShapeIntersection(geom, App.map.get('areaOfInterest'));
this.catchmentPolygon.openPopup(L.GeoJSON.coordsToLatLng(popUpLocationGeoJSON.geometry.coordinates));
},

Expand Down
92 changes: 92 additions & 0 deletions src/mmw/js/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,82 @@ function RestAPI() {
};
}

function adjustModelViewBeforeITSIScreenshot() {
toggleModelViewForITSIScreenshot(true);
}

function adjustModelViewAfterITSIScreenshot() {
toggleModelViewForITSIScreenshot(false);
}

function toggleModelViewForITSIScreenshot(adjustForScreenshot) {
var modelHeaderProject = '.project',
modelHeaderToolbar = '.toolbar',
modelToolbarContainer = '.toolbar-container',
itsiModelToolbar = 'itsi-model-toolbar';

if (adjustForScreenshot) {
$(modelHeaderProject).addClass(itsiModelToolbar);
$(modelHeaderToolbar).addClass(itsiModelToolbar);
$(modelToolbarContainer).addClass(itsiModelToolbar);
} else {
$(modelHeaderProject).removeClass(itsiModelToolbar);
$(modelHeaderToolbar).removeClass(itsiModelToolbar);
$(modelToolbarContainer).removeClass(itsiModelToolbar);
}
}

function adjustCompareViewBeforeITSIScreenshot() {
toggleCompareViewForITSIScreenshot(true);
}

function adjustCompareViewAfterITSIScreenshot() {
toggleCompareViewForITSIScreenshot(false);
}

function toggleCompareViewForITSIScreenshot(adjustForScreenshot) {
var itsiCompareDialog = 'itsi-compare-dialog',
itsiCompareModal = 'itsi-compare-modal',
itsiCompareRow = 'itsi-compare-row',
compareDialog = '#compare-new-dialog',
compareModalContent = '.compare-modal-content',
compareCloseButton = '.compare-close',
compareChartButton = '#compare-input-button-chart',
compareTableButton = '#compare-input-button-table',
compareChartRow = '.compare-chart-row',
compareTableRow = '.compare-table-row',
compareScenariosRow = '.compare-scenarios',
compareMapsRow = '.compare-scenario-row-content';

if (adjustForScreenshot) {
$(compareDialog).addClass(itsiCompareDialog);
$(compareModalContent).addClass(itsiCompareModal);
$(compareCloseButton).hide();
$(compareChartButton).hide();
$(compareTableButton).hide();
$(compareScenariosRow).addClass(itsiCompareRow);
$(compareMapsRow).addClass(itsiCompareRow);
if ($(compareChartRow).length) {
$(compareChartRow).addClass(itsiCompareRow);
} else if ($(compareTableRow).length) {
$(compareTableRow).addClass(itsiCompareRow);
}
} else {
$(compareDialog).removeClass(itsiCompareDialog);
$(compareModalContent).removeClass(itsiCompareModal);
$(compareCloseButton).show();
$(compareChartButton).show();
$(compareTableButton).show();
$(compareScenariosRow).removeClass(itsiCompareRow);
$(compareMapsRow).removeClass(itsiCompareRow);
if ($(compareChartRow)) {
$(compareChartRow).removeClass(itsiCompareRow);
} else if ($(compareTableRow).length) {
$(compareTableRow).removeClass(itsiCompareRow);
}
}
}

function initializeShutterbug() {
var googleTileLayerSelector = '#map > .leaflet-google-layer > div > div > div:nth-child(1) > div:nth-child(1)';

Expand Down Expand Up @@ -188,6 +264,14 @@ function initializeShutterbug() {
// '/' then to empty string, which leaves a '#' in the URL.
document.location.hash = '/';
document.location.hash = '';

if ($('#compare-new').length) {
adjustCompareViewBeforeITSIScreenshot();
}

if ($('.project')) {
adjustModelViewBeforeITSIScreenshot();
}
})
.on('shutterbug-asyouwere', function() {
// Reset after screenshot has been taken
Expand All @@ -210,6 +294,14 @@ function initializeShutterbug() {
top: '',
});
}

if ($('#compare-new').length) {
adjustCompareViewAfterITSIScreenshot();
}

if ($('.project')) {
adjustModelViewAfterITSIScreenshot();
}
});

shutterbug.enable('body');
Expand Down
4 changes: 2 additions & 2 deletions src/mmw/js/src/compare/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ function copyProject(project, aoi_census) {
});
}

// Adds special 100% Forest Cover Scenario for the Compare View
// Adds special Predominantly Forested Scenario for the Compare View
function addForestCoverScenario(aoi_census) {
var project = App.currentProject,
forestCoverScenario = new modelingModels.ScenarioModel({}),
currentConditions = project.get('scenarios').findWhere({ is_current_conditions: true });

forestCoverScenario.set({
name: '100% Forest Cover',
name: 'Predominantly Forested',
is_current_conditions: false,
is_pre_columbian: true,
modifications: currentConditions.get('modifications'),
Expand Down
33 changes: 16 additions & 17 deletions src/mmw/js/src/compare/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var _ = require('lodash'),

var CHART = 'chart',
TABLE = 'table',
MIN_VISIBLE_SCENARIOS = 3,
MIN_VISIBLE_SCENARIOS = 5,
CHART_AXIS_WIDTH = 82,
COMPARE_COLUMN_WIDTH = 134;

Expand Down Expand Up @@ -43,6 +43,16 @@ var ChartRowsCollection = Backbone.Collection.extend({
this.scenarios.forEach(function(scenario) {
scenario.get('results').on('change', update);
});
},

getScenarioResults: function(typeKey) {
return this.scenarios.map(function(scenario) {
var resultKey = coreUtils.getTR55ResultKey(scenario),
result = scenario.get('results')
.findWhere({ name: typeKey })
.get('result');
return result[typeKey][resultKey];
});
}
});

Expand All @@ -52,23 +62,17 @@ var Tr55RunoffCharts = ChartRowsCollection.extend({
.get('inputs')
.findWhere({ name: 'precipitation' }),
precipitation = coreUtils.convertToMetric(precipitationInput.get('value'), 'in'),
results = this.scenarios.map(function(scenario) {
return scenario.get('results')
.findWhere({ name: 'runoff' })
.get('result');
});
results = this.getScenarioResults('runoff');

this.forEach(function(chart) {
var key = chart.get('key'),
values = [];

if (key === 'combined') {
values = _.map(results, function(result) {
return result.runoff.modified;
});
values = results;
} else {
values = _.map(results, function(result) {
return result.runoff.modified[key];
return result[key];
});
}

Expand All @@ -83,17 +87,12 @@ var Tr55RunoffCharts = ChartRowsCollection.extend({
var Tr55QualityCharts = ChartRowsCollection.extend({
update: function() {
var aoivm = this.aoiVolumeModel,
results = this.scenarios.map(function(scenario) {
return scenario.get('results')
.findWhere({ name: 'quality' })
.get('result');
});
results = this.getScenarioResults('quality');

this.forEach(function(chart) {
var name = chart.get('name'),
values = _.map(results, function(result) {
var measures = result.quality.modified,
load = _.find(measures, { measure: name }).load;
var load = _.find(result, { measure: name }).load;

return aoivm.getLoadingRate(load);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{% if is_pre_columbian %}
<h3 class="compare-no-mod-title">{{name}}</h3>
<p>
Lorem ipsum this scenario shows the tr55 model results under pre columbian conditions...
Model simulation of a pre-development landscape, where forest replaces all agricultural and urban landcover.
</p>
{% elif is_current_conditions %}
<h3 class="compare-no-mod-title">{{name}}</h3>
<p>
Lorem ipsum this is the model run under current conditions
Model results based on 2011 NLCD land and 2016 gSSURGO soil datasets.
</p>
{% else %}
<h3 class="compare-no-mod-title">No modifications</h3>
<p>
To add modifications, close this modal and select "Land cover" or "Conservation practices" lorem ipsum dolor sit
To add modifications, close this modal and select "Land cover" or "Conservation practices".
</p>
{% endif %}
5 changes: 0 additions & 5 deletions src/mmw/js/src/compare/templates/compareInputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@
<button id="compare-input-button-chart" class="{{ 'active' if mode == 'chart' }}"><i class="fa fa-bar-chart"></i></button>
<button id="compare-input-button-table" class="{{ 'active' if mode == 'table' }}"><i class="fa fa-table"></i></button>
</div>
<div class="compare-download compare-input">
<button>
<i class="fa fa-download"></i>
</button>
</div>
44 changes: 24 additions & 20 deletions src/mmw/js/src/compare/templates/compareWindow2.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<div class="compare-scenario-gradient"></div>
<div class="compare-header">
<div class="compare-title">
<h1>Compare</h1>
</div>
<div class="spinner hidden"></div>
<div class="compare-close">
<button>
<i class="fa fa-times"></i>
</button>
</div>
<div class="compare-actions">
<div class="compare-tabs">
<div id="compare-new-dialog" class="modal-dialog">
<div class="modal-content compare-modal-content">
<div class="compare-header">
<div class="compare-title">
<h1>Compare</h1>
</div>
<div class="spinner hidden"></div>
<div class="compare-close">
<button>
<i class="fa fa-times"></i>
</button>
</div>
<div class="compare-actions">
<div class="compare-tabs">
</div>
<div class="compare-inputs">
</div>
</div>
</div>
<div class="compare-inputs">
</div>
</div>
</div>
<div class="compare-scenarios">
<div class="compare-scenario-gradient"></div>
<div class="compare-scenarios">
<div class="compare-scenario-row-description">
<h2>Scenarios</h2>
</div>
Expand All @@ -30,6 +32,8 @@ <h2>Scenarios</h2>
<i class="fa fa-arrow-right"></i>
</button>
</div>
</div>
<div class="compare-sections polling">
</div>
<div class="compare-sections polling">
</div>
</div>
</div>
Loading

0 comments on commit 8afa4c4

Please sign in to comment.