diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml index 6032f1d92b958a76f212b99b993d6e40b33869ca..6fe227ac605aa835a3a2189c5aa2a22cd7d05e12 100644 --- a/.elasticbeanstalk/config.yml +++ b/.elasticbeanstalk/config.yml @@ -1,8 +1,10 @@ branch-defaults: master: - environment: blocmaps-env + environment: blocmaps-prod + staging: + environment: blocmaps-dev global: - application_name: research-development + application_name: Blocmaps default_ec2_keyname: RnD default_platform: 64bit Amazon Linux 2016.03 v2.1.3 running Python 2.7 default_region: us-east-1 diff --git a/maps/views.py b/maps/views.py index cf82a1365822c237729d3c21700e6f4c85732968..3d50e99b6b6c4e15d6c4c41f9f8de665816e03f7 100644 --- a/maps/views.py +++ b/maps/views.py @@ -1,7 +1,8 @@ from django.shortcuts import render from django.http import HttpResponse from django.template import loader -import urllib2 +from urllib.request import urlopen +import codecs import json import pymongo from pymongo import MongoClient @@ -10,8 +11,9 @@ from django.http import JsonResponse def arcgis(building_id): url = 'http://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/MAPPLUTO/FeatureServer/0/query?where=1=1&objectIds=%s&outFields=*&outSR=4326&f=geojson' % building_id - response = urllib2.urlopen(url) - return json.load(response) + response = urlopen(url) + reader = codecs.getreader("utf-8") + return json.load(reader(response)) def openMongo(): client = MongoClient("mongodb://blocpower:h3s.w8^8@ds013916.mlab.com:13916/blocmaps") @@ -30,10 +32,11 @@ def building_detail(request): cursor = db.nyc.find({"_id": int(bld_id)}) data = arcgis(bld_id) for document in cursor: - if document['properties'].has_key('ped_energy'): + if 'ped_energy' in document['properties']: data['features'][0]['properties'][u'ped_energy'] = document['properties']['ped_energy'] - if document['properties'].has_key('ecm'): + if 'ecm' in document['properties']: data['features'][0]['properties'][u'ecm'] = document['properties']['ecm'] + return JsonResponse(data['features'][0]['properties']) diff --git a/static/src/blocmaps.js b/static/src/blocmaps.js index 5bb43d887ec3a3ec6c132a674373f85c4af8d902..c34e173f03b27669f6a4642ec272d47d1d16b593 100644 --- a/static/src/blocmaps.js +++ b/static/src/blocmaps.js @@ -54,15 +54,20 @@ function startOSMB(map) { buildings = []; osmb.dataGrid.destroy(); osmb.addGeoJSONTiles('/static/tile/{z}/{x}/{y}.json', {modifier: mapSetup}); + closeDetails(); }); $('.close_details').on('click', function(e){ - $('#details').removeClass('show'); - $('.map_legend').removeClass('show'); - $('.current_pointer').hide(); + closeDetails(); }); } +function closeDetails(){ + $('#details').removeClass('show'); + $('.map_legend').removeClass('show'); + $('.current_pointer').hide(); +}; + function mapSetup(id, properties) { if(buildingType == '00' || properties.LandUse == buildingType ){ properties.height = parseFloat(properties.NumFloors )* 3.5;