Skip to content

Commit

Permalink
Merge branch 'release/1.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Castro committed Oct 5, 2016
2 parents df28c64 + 20c3b95 commit 589db94
Show file tree
Hide file tree
Showing 61 changed files with 5,806 additions and 1,468 deletions.
4 changes: 2 additions & 2 deletions deployment/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ postgresql_database: mmw
postgresql_version: "9.4"
postgresql_package_version: "9.4.*.pgdg14.04+1"
postgresql_support_repository_channel: "main"
postgresql_support_libpq_version: "9.5.*.pgdg14.04+1"
postgresql_support_libpq_version: "9.6.*.pgdg14.04+1"
postgresql_support_psycopg2_version: "2.6"
postgis_version: "2.1"
postgis_package_version: "2.1.*.pgdg14.04+1"
Expand All @@ -32,7 +32,7 @@ nodejs_npm_version: 2.1.17

apache_version: "2.4.7-*"

java_version: "7u101-*"
java_version: "7u111-*"

graphite_carbon_version: "0.9.13-pre1"
graphite_whisper_version: "0.9.13-pre1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exec /usr/bin/docker run \
--volume {{ geop_home }}:{{ geop_home }} \
--volume {{ sjs_data_dir }}:{{ sjs_data_dir }} \
--log-driver syslog \
{{ sjs_container_image }} --driver-memory {{ sjs_driver_memory }}
{{ sjs_container_image }} --driver-memory {{ sjs_driver_memory }} --driver-java-options "-Xss5m -Dlog4j.configuration=file:log4j.properties"

post-stop script
/usr/bin/docker kill spark-jobserver || true
Expand Down
3 changes: 2 additions & 1 deletion scripts/aws/setupdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ fi

if [ "$load_mapshed" = "true" ] ; then
# Fetch map shed specific vector features
FILES=("ms_weather.sql.gz" "ms_weather_station.sql.gz" "ms_pointsource.sql.gz" "ms_county_animals.sql.gz")
FILES=("ms_weather.sql.gz" "ms_weather_station.sql.gz" "ms_pointsource.sql.gz"
"ms_pointsource_drb.sql.gz" "ms_county_animals.sql.gz")

download_and_load $FILES
fi
3 changes: 0 additions & 3 deletions src/mmw/apps/core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
</div>

<div id="sidebar">
<button class="btn btn-primary tab-content-toggle" type="button" title="Show/Hide results sidebar">
<i class="fa fa-angle-right"></i>
</button>
<div id="sidebar-content"></div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/mmw/apps/core/templates/patterns.html
Original file line number Diff line number Diff line change
Expand Up @@ -3184,8 +3184,8 @@
</g>
</g>
</pattern>
<!-- Detention Basin aka Vegitation Infill Basin aka Infiltration Trench-->
<pattern id="fill-infiltration_trench" overflow="visible" patternUnits="userSpaceOnUse" width="72" height="72">
<!-- Detention Basin aka Vegitation Infill Basin aka Infiltration Basin-->
<pattern id="fill-infiltration_basin" overflow="visible" patternUnits="userSpaceOnUse" width="72" height="72">
<polygon points="0.305,-71.606 71.911,-71.606 71.911,0 0.305,0 " transform="matrix(1.0055023,0,0,1.0055023,-0.3066782,71.999998)" style="fill:#b1c4a1" />
<path d="M 70.301,19.757998 C 70.241,19.757998 70.171,19.726998 70.121,19.677998 70.081,19.636998 70.051,19.576998 70.051,19.507998 70.051,19.437998 70.081,19.366998 70.131,19.326998 70.211,19.236998 70.381,19.236998 70.482,19.326998 70.532,19.376998 70.551,19.436998 70.551,19.507998 70.551,19.566998 70.531,19.636998 70.482,19.677998 70.432,19.726998 70.372,19.757998 70.301,19.757998 z" style="fill:#231f20" />
<path d="M 11.051,18.507998 C 10.982,18.507998 10.921,18.476998 10.871,18.427998 10.831,18.386998 10.801,18.316998 10.801,18.257998 10.801,18.187998 10.831,18.126998 10.871,18.076998 10.972,17.986998 11.131,17.986998 11.222,18.076998 11.282,18.126998 11.301,18.196998 11.301,18.257998 11.301,18.316998 11.272,18.386998 11.232,18.427998 11.182,18.476998 11.112,18.507998 11.051,18.507998 z" style="fill:#231f20" />
Expand Down
1 change: 1 addition & 0 deletions src/mmw/apps/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def get_client_settings(request):
'map_controls': settings.MAP_CONTROLS,
'vizer_urls': settings.VIZER_URLS,
'model_packages': get_model_packages(),
'mapshed_max_area': settings.GWLFE_CONFIG['MaxAoIArea']
}),
'google_maps_api_key': settings.GOOGLE_MAPS_API_KEY,
}
Expand Down
94 changes: 94 additions & 0 deletions src/mmw/apps/modeling/calcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import

from django.contrib.gis.geos import GEOSGeometry

from django.conf import settings
from django.db import connection

from apps.modeling.mapshed.calcs import (animal_energy_units,
get_point_source_table)

DRB = settings.DRB_PERIMETER

ANIMAL_DISPLAY_NAMES = {
'sheep': 'Sheep',
'horses': 'Horses',
'turkeys': 'Turkeys',
'layers': 'Chickens, Layers',
'beef_cows': 'Cows, Beef',
'hogs': 'Pigs/Hogs/Swine',
'dairy_cows': 'Cows, Dairy',
'broilers': 'Chickens, Broilers',
}


def animal_population(geojson):
"""
Given a GeoJSON shape, call MapShed's `animal_energy_units` method
to calculate the area-weighted county animal population. Returns a
dictionary to append to the outgoing JSON for analysis results.
"""
geom = GEOSGeometry(geojson, srid=4326)
aeu_for_geom = animal_energy_units(geom)[2]
aeu_return_values = []

for animal, aeu_value in aeu_for_geom.iteritems():
aeu_return_values.append({
'type': ANIMAL_DISPLAY_NAMES[animal],
'aeu': int(aeu_value),
})

return {
'displayName': 'Animals',
'name': 'animals',
'categories': aeu_return_values
}


def point_source_pollution(geojson):
"""
Given a GeoJSON shape, retrieve point source pollution data
from the `ms_pointsource` or `ms_pointsource_drb table to display
in the Analyze tab.
Returns a dictionary to append to the outgoing JSON for analysis
results.
"""
geom = GEOSGeometry(geojson, srid=4326)
drb = geom.within(DRB)
table_name = get_point_source_table(drb)
sql = '''
SELECT city, state, npdes_id, mgd, kgn_yr, kgp_yr, latitude,
longitude, {facilityname}
FROM {table_name}
WHERE ST_Intersects(geom, ST_SetSRID(ST_GeomFromText(%s), 4326))
'''.format(facilityname='facilityname' if drb else 'null',
table_name=table_name)

with connection.cursor() as cursor:
cursor.execute(sql, [geom.wkt])

if cursor.rowcount != 0:
columns = [col[0] for col in cursor.description]
point_source_results = [
dict(zip(columns,
[row[0], row[1], row[2],
float(row[3]) if row[3] else None,
float(row[4]) if row[4] else None,
float(row[5]) if row[5] else None,
float(row[6]) if row[6] else None,
float(row[7]) if row[7] else None,
row[8]]))
for row in cursor.fetchall()
]
else:
point_source_results = []

return {
'displayName': 'Point Source',
'name': 'pointsource',
'categories': point_source_results
}
Loading

0 comments on commit 589db94

Please sign in to comment.