From bc8a99c2630ca58ee462e5f2e14a38d1159aeb64 Mon Sep 17 00:00:00 2001 From: markAking Date: Wed, 31 Aug 2016 12:33:04 -0400 Subject: [PATCH] updats for py3.4 --- .elasticbeanstalk/config.yml | 6 ++++-- maps/views.py | 13 ++++++++----- static/src/blocmaps.js | 11 ++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml index 6032f1d..6fe227a 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 cf82a13..3d50e99 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 5bb43d8..c34e173 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; -- GitLab