From 9a5a99268a07c00ea062b40668b3588958937661 Mon Sep 17 00:00:00 2001 From: markAking Date: Wed, 7 Sep 2016 15:22:12 -0400 Subject: [PATCH 1/9] Google Analytics inserted - note will not insert on local builds. Controls added --- README.md | 1 + ebdjango/custom_processors.py | 11 +++ ebdjango/settings-dev.py | 131 ++++++++++++++++++++++++++++++++++ ebdjango/settings.py | 5 ++ manage.py | 2 +- static/src/blocmaps.js | 27 +++++++ static/styles/RotateLeft.png | Bin 0 -> 2109 bytes static/styles/RotateRight.png | Bin 0 -> 2123 bytes static/styles/ZoomIn.png | Bin 0 -> 594 bytes static/styles/ZoomOut.png | Bin 0 -> 570 bytes static/styles/blocmaps.css | 79 +++++++++++++++++++- templates/nyc.html | 44 +++++++++--- 12 files changed, 285 insertions(+), 15 deletions(-) create mode 100644 ebdjango/custom_processors.py create mode 100644 ebdjango/settings-dev.py create mode 100644 static/styles/RotateLeft.png create mode 100644 static/styles/RotateRight.png create mode 100644 static/styles/ZoomIn.png create mode 100644 static/styles/ZoomOut.png diff --git a/README.md b/README.md index 1c207bf..b35feab 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ## Running Locally - python manage.py runserver + - Note: Running locally will not insert google analytics. - rest calls: http://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/MAPPLUTO/FeatureServer/0/query?where=LandUse=5%20AND%20Borough=%27SI%27&outFields=*&outSR=4326&f=geojson diff --git a/ebdjango/custom_processors.py b/ebdjango/custom_processors.py new file mode 100644 index 0000000..f40dac8 --- /dev/null +++ b/ebdjango/custom_processors.py @@ -0,0 +1,11 @@ +from django.conf import settings + +def google_analytics(request): + ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_KEY', False) + ga_domain = getattr(settings, 'GOOGLE_ANALYTICS_DOMAIN', False) + if ga_prop_id and ga_domain: + return { + 'GOOGLE_ANALYTICS_KEY': ga_prop_id, + 'GOOGLE_ANALYTICS_DOMAIN': ga_domain, + } + return {} \ No newline at end of file diff --git a/ebdjango/settings-dev.py b/ebdjango/settings-dev.py new file mode 100644 index 0000000..c7dd0f6 --- /dev/null +++ b/ebdjango/settings-dev.py @@ -0,0 +1,131 @@ +""" +Django settings for blocmaps project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +import os + +SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__)) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +#SECRET_KEY = os.environ['SECRET_KEY'] +SECRET_KEY = 'cs&36x94f3ek57l(*k(cl#-1xqir0njs4g6@%ncn!a*_@a5n$s' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + #'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'ebdjango.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(SETTINGS_PATH, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + 'ebdjango.custom_processors.google_analytics', + ], + }, + }, +] + +WSGI_APPLICATION = 'ebdjango.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases +# http://petrkout.com/programming/setting-up-django-with-mongodb/ +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.dummy' + } +} + +# Password validation +# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.10/topics/i18n/ + +LANGUAGE_CODE = 'en-us' +TIME_ZONE = 'UTC' +USE_I18N = True +USE_L10N = True +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_ROOT = '' +STATIC_URL = '/static/' +STATICFILES_DIRS = ( os.path.join('static'), ) + +# Google Analytics +# GOOGLE_ANALYTICS_KEY = 'UA-67611405-2' +# GOOGLE_ANALYTICS_DOMAIN = 'auto' + +# AWS +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html +DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' +AWS_ACCESS_KEY_ID = 'AKIAIXRNGH4WE3GBSZYQ' +AWS_SECRET_ACCESS_KEY = '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' +AWS_STORAGE_BUCKET_NAME = 'blocmaps-assets' \ No newline at end of file diff --git a/ebdjango/settings.py b/ebdjango/settings.py index a301cde..caba42a 100644 --- a/ebdjango/settings.py +++ b/ebdjango/settings.py @@ -65,6 +65,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'ebdjango.custom_processors.google_analytics', ], }, }, @@ -118,6 +119,10 @@ STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join('static'), ) +# Google Analytics +GOOGLE_ANALYTICS_KEY = 'UA-67611405-2' +GOOGLE_ANALYTICS_DOMAIN = 'auto' + # AWS # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' diff --git a/manage.py b/manage.py index 19fddd0..2621a08 100644 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ebdjango.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ebdjango.settings-dev") try: from django.core.management import execute_from_command_line except ImportError: diff --git a/static/src/blocmaps.js b/static/src/blocmaps.js index adebbb1..1544a33 100644 --- a/static/src/blocmaps.js +++ b/static/src/blocmaps.js @@ -69,6 +69,31 @@ function startOSMB(position, bounds) { $('.close_details').on('click', function(e){ closeDetails(); }); + + var controlButtons = document.querySelectorAll('.control button'); + + for (var i = 0, il = controlButtons.length; i < il; i++) { + controlButtons[i].addEventListener('click', function(e) { + var button = this, + parentClassList = button.parentNode.classList, + direction = button.classList.contains('inc') ? 1 : -1, + increment, + property; + + + if (parentClassList.contains('rotation')) { + property = 'Rotation'; + increment = direction*10; + } + if (parentClassList.contains('zoom')) { + property = 'Zoom'; + increment = direction*1; + } + if (property) { + osmb['set'+ property](osmb['get'+ property]()+increment); + } + }); + } } function closeDetails(){ @@ -113,6 +138,8 @@ function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; + + /* * ## Key codes for object positioning ## * Cursor keys: move diff --git a/static/styles/RotateLeft.png b/static/styles/RotateLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..268e0aacf43fe41eaa2542a9341bffb91db4bc08 GIT binary patch literal 2109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oa_Fm^5LaxVTv5~BwSVh^#=!wOQT^(x-L9AT4 zQmtFJ&f9qD=jzY9y1JS#T)5DSu}QF4hHlba6%Y(tgv`uL&G%eud}+gm4XUuPP{qc^ zTDF<`=T4nE#XTD~%mPLNSes@5!&qQX!hS_oUcE5ibG8e?629ke?Af#DZ_MXXKrs4j z(!^+BXm$cfPfyq0RJ-Hw5B7_Hf=GT15)5NTGRd1w3Z>cB_C_d^@jb>2$_Kv=P6Knh zpFOal&bipbMv|~XkMG>M^GE1lZJ}itGbR^dOu4wya;=FF%^W;<@H=D>*CK9(5R9a? zH;cTwBemN}cj8OoXDBKJzXi?!(+z?5_96wQxw-idDEN-cL1M+6&N?-QqNf`V=@iRD zT|q&?57^zj4*_f~X_Yas6ghLy;-;4ziW&FWvu7(Iv=saycr`c^ya*ihc0IRSZT~H( zFMQZxAK$xoZv~W=fIk4|f(3{^V52Z@P2qq+`}kL0Uf!3`z^r)}{02A!OpDk9f(O{k z+O`Z@f%aXyc9rAtPr0s^%h-(b{FBrEZ{>lE|LS-=()7;p2Y&m-LXw88G z2bwXJ>B_3gY$5ZSStG$}nK_teBFk)I^NjDK&bqp~#`5y=KN}kxnI%-n3=uE_f^|en zz4R$Ty(pg3D2590{lkCuC*iVT{JY-=H}pYq$FXC_T2VKsjBiV21R`MMTv`HsL9@NLL6FIQCx=bH);f}vtE&&3h~!nRu=!$5RXA6VXm0?AY$U<43Bk$KH~ z1gvibLv9_vCp;j|8JnZ+X)|M@N-E7xurjz`xs~=m089Y?=T7002ovPDHLkV1mTy B>4yLS literal 0 HcmV?d00001 diff --git a/static/styles/ZoomIn.png b/static/styles/ZoomIn.png new file mode 100644 index 0000000000000000000000000000000000000000..f6b9f6b9e83cdaf1416d1ffc97bd4e8edfc5f7fc GIT binary patch literal 594 zcmV-Y0X00001b5ch_0Itp) z=>Px%3`s;mR9Fe^SHWt+KoFhOR52b3IkX-`JoX@nP!GNO3I3S>;Jr{3{ECWyAc7zj zp_q&HplRo&*$|VB*=8e!l7VqIv$OBLoprNHR9I1gzpa3gLNCVAhWjbgE)IYBqiDl@ z=_FGc{Rs+DH~biO5f_3lK%5N;L1^8GBTTGD#95=!sO`G$ho-LBbYKD-96lE~l|&*5TaVS*j^n(>&~pj^8yr3t zIAa2#I%?qxRxQhVjwa;w>|={U49F*s9Vxl;JNXyD`AuzTgOiHr(d``33 zj24SUQi?2okt<1{3@A0m?=~+-w5bym612Z#{4OJGEo`^jdF^_=rgFJVhG9^%*`!J( z`&pB1Aw=Wo-?2aNJNeCHP52lNhk-CzN~hDI!C)X8@?yM*C+=W{4*Mtjkv%Z&3ikVb zS}vC!;A*v^?RHD8R*P)g_A1!zb_2339c_WA5F9q0PCbFWUXR*sT(kO?>mkvX6GzBZ zV589>zF(;M1& literal 0 HcmV?d00001 diff --git a/static/styles/ZoomOut.png b/static/styles/ZoomOut.png new file mode 100644 index 0000000000000000000000000000000000000000..beae87e1b3e16809b7e13e7dfb4dfc38d75adf28 GIT binary patch literal 570 zcmV-A0>%A_P)X00001b5ch_0Itp) z=>Px$^hrcPR9Fe^m(5PXKoo^r@t4N-`x^}wkVA(;}4!Gu*YtXfWg?5r; z(RRD-b-Uf9YjLe@%xg3nUcFvl__n=p7Ra7F9*?bc5jdSrt|ohJ*ABSmXRX1Ri06o+=+(7IR({OAsAY@WByig6^`32syYR)_e94W- zT(lg!I2F}|n^voJKN^h&I^FHm;DnnRaV=^tANl0489~Rwm2fTGHJifSa1sUNW0N0tjX_j0$7qT+=;r zTsjCZT|^kLc254eWpx2RQ*EaEK-a*C%X<42vep%@N@uevK09p4cZ0(wlPyhe`07*qo IM6N<$g6c*Fod5s; literal 0 HcmV?d00001 diff --git a/static/styles/blocmaps.css b/static/styles/blocmaps.css index aeeee72..ec271bb 100644 --- a/static/styles/blocmaps.css +++ b/static/styles/blocmaps.css @@ -4,7 +4,9 @@ url("MuseoSansRounded-500.otf") format('opentype'); font-weight: normal; } - +* { + outline: none; +} html, body { margin: 0; padding: 0; @@ -35,7 +37,6 @@ header > div{ width: 1140px; margin: auto; position: relative; - overflow: hidden; } #logo{ width:200px; @@ -71,7 +72,7 @@ header > div{ margin-left: 0; } .top-menu a { - color: #585858; + color: #2f9c79; display: block; font-size: 16px; } @@ -82,6 +83,7 @@ header > div{ .selectType{ float: left; padding: 0 30px; + margin-top: -20px; } .selectType label{ display: block; @@ -90,6 +92,8 @@ header > div{ } #selectType{ font-size: 16px; + padding: 8px; + border-radius: 4px; } #map { width: 100%; @@ -298,4 +302,73 @@ header > div{ } #detail_list{ display: none; +} + +.map_controls{ + position: absolute; + width: 70px; + height: 136px; + bottom: 30px; + left: 30px; +} +.map_controls button{ + background: none; + border: none; + float: left; +} +.zoom{ + width: 40px; + margin: 0 auto; + overflow: hidden; +} +.zoom button{ + width: 40px; + height: 30px; +} +.zoom .inc{ + background: url('ZoomIn.png'); +} +.zoom .dec{ + background: url('ZoomOut.png'); +} +.rotation{ + width: 70px; + height: 76px; +} +.rotation button{ + width: 35px; + height: 76px; +} +.rotation .inc{ + background: url('RotateLeft.png'); +} +.rotation .dec{ + background: url('RotateRight.png'); +} + +/* Media Querys */ +@media screen and (max-width:479px){ + #main-menu, + .selectType, + .map_controls, + .map_legend{ + display: none; + } + header{ + height: 75px; + } + .wrapper{ + width: 320px; + } + #logo{ + height: auto; + } + #map, + #details{ + top: 75px; + } + #details{ + width: 100%; + right: -100%; + } } \ No newline at end of file diff --git a/templates/nyc.html b/templates/nyc.html index 138a1e1..3ddd5e1 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -18,22 +18,23 @@ Blocpower
- +
@@ -49,6 +50,17 @@
Very Effiencient
+
+
+ + +
+
+ + +
+
+

@@ -187,7 +199,17 @@ // START OSMB - in blocmaps.js // startOSMB(position, bounds, pointerdown); - + +{% if GOOGLE_ANALYTICS_KEY %} + +{% endif %} \ No newline at end of file -- GitLab From 986ca31df2dd20055311df66573b15d1582fb81d Mon Sep 17 00:00:00 2001 From: Steven Walker Date: Fri, 9 Sep 2016 11:21:45 -0400 Subject: [PATCH 2/9] giving map controls cursor pointer --- static/styles/blocmaps.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/styles/blocmaps.css b/static/styles/blocmaps.css index ec271bb..a4d442f 100644 --- a/static/styles/blocmaps.css +++ b/static/styles/blocmaps.css @@ -308,13 +308,14 @@ header > div{ position: absolute; width: 70px; height: 136px; - bottom: 30px; - left: 30px; + bottom: 40px; + left: 40px; } .map_controls button{ background: none; border: none; float: left; + cursor: pointer; } .zoom{ width: 40px; -- GitLab From 214ff6696226515256e776f1f83f9d87b4c70ed4 Mon Sep 17 00:00:00 2001 From: Steven Walker Date: Fri, 9 Sep 2016 11:25:19 -0400 Subject: [PATCH 3/9] changing copy for map filter --- templates/nyc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/nyc.html b/templates/nyc.html index 3ddd5e1..b0bc18f 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -18,10 +18,10 @@ Blocpower
- +
- + -->
-- GitLab From 5c06c72e353c58c97e9bd8145a1e561b0e321738 Mon Sep 17 00:00:00 2001 From: markAking Date: Mon, 12 Sep 2016 13:35:26 -0400 Subject: [PATCH 5/9] adding city of rochester back on to the maps. add new route patterens for handling different cities --- ebdjango/urls.py | 5 +- maps/urls.py | 7 -- maps/views.py | 73 +++++++++++++----- templates/nyc.html | 4 +- templates/rochester.html | 156 ++++++++++++++++++++++++--------------- 5 files changed, 155 insertions(+), 90 deletions(-) delete mode 100644 maps/urls.py diff --git a/ebdjango/urls.py b/ebdjango/urls.py index ffe5376..4781e23 100644 --- a/ebdjango/urls.py +++ b/ebdjango/urls.py @@ -19,7 +19,8 @@ from maps import views urlpatterns = [ url(r'^$', views.index, name='index'), - url(r'^tile/15/(?P[0-9]+)/(?P[0-9]+)/$', views.tile, name='tile'), - url(r'^nyc/', include('maps.urls')), + url(r'^(?P[\w-]+)/$', views.index, name='index'), + url(r'^(?P[\w-]+)/building_detail/', views.building_detail, name='building_detail'), + url(r'^tile/15/(?P[0-9]+)/(?P[0-9]+)/$', views.tile, name='tile') # url(r'^admin/', admin.site.urls), ] diff --git a/maps/urls.py b/maps/urls.py deleted file mode 100644 index 68c82f2..0000000 --- a/maps/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.conf.urls import url -from . import views - -urlpatterns = [ - url(r'^$', views.index, name='index'), - url(r'^building_detail/', views.building_detail, name='building_detail') -] \ No newline at end of file diff --git a/maps/views.py b/maps/views.py index b2f2ce6..408cae2 100644 --- a/maps/views.py +++ b/maps/views.py @@ -10,21 +10,33 @@ import pymongo from pymongo import MongoClient from django.http import JsonResponse -def arcgis(building_id): +def arcgis_nyc(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 = urlopen(url) reader = codecs.getreader("utf-8") return json.load(reader(response)) +def arcgis_roc(building_id): + url = 'http://maps.cityofrochester.gov/arcgis/rest/services/App_PropertyInformation/ROC_Parcel_Query_SDE/MapServer/0/query??where=1=1&objectIds=%s&outFields=*&f=pjson' % building_id + response = urlopen(url) + reader = codecs.getreader("utf-8") + return json.load(reader(response)) + def openMongo(): client = MongoClient(settings.MONGO_DB_URI) return client['blocmaps'] -def index(request): - template = loader.get_template('nyc.html') - context = { - 'City': 'NYC', - } +def index(request, city = 'nyc'): + if city == 'nyc': + template = loader.get_template('nyc.html') + context = { + 'City': 'NYC', + } + if city == 'roc': + template = loader.get_template('rochester.html') + context = { + 'City': 'Rochester', + } return HttpResponse(template.render(context, request)) def tile(request, tile_x, tile_y): @@ -36,20 +48,41 @@ def tile(request, tile_x, tile_y): else: return HttpResponse('') -def building_detail(request): +def building_detail(request, city = 'nyc'): bld_id = request.POST['id'] db = openMongo() - cursor = db.nyc.find({"_id": int(bld_id)}) - data = arcgis(bld_id) - for document in cursor: - if 'prediction' in document['properties']: - data['features'][0]['properties'][u'prediction'] = document['properties']['prediction'] - - if 'ped_energy' in document['properties']: - data['features'][0]['properties'][u'ped_energy'] = document['properties']['ped_energy'] - - if 'ecm' in document['properties']: - data['features'][0]['properties'][u'ecm'] = document['properties']['ecm'] - - return JsonResponse(data['features'][0]['properties']) + if city == 'nyc': + cursor = db.nyc.find({"_id": int(bld_id)}) + data = arcgis_nyc(bld_id) + + for document in cursor: + if 'prediction' in document['properties']: + data['features'][0]['properties'][u'prediction'] = document['properties']['prediction'] + + if 'ped_energy' in document['properties']: + data['features'][0]['properties'][u'ped_energy'] = document['properties']['ped_energy'] + + if 'ecm' in document['properties']: + data['features'][0]['properties'][u'ecm'] = document['properties']['ecm'] + + return JsonResponse(data['features'][0]['properties']) + + if city == 'roc': + cursor = db.roc.find({"_id": int(bld_id)}) + data = arcgis_roc(bld_id) + + for document in cursor: + data['features'][0]['attributes'][u'sqft'] = document['properties']['sqft'] + data['features'][0]['attributes'][u'age'] = document['properties']['age'] + data['features'][0]['attributes'][u'NumFloors'] = document['properties']['NumFloors'] + if 'prediction' in document['properties']: + data['features'][0]['attributes'][u'prediction'] = document['properties']['prediction'] + + if 'ped_energy' in document['properties']: + data['features'][0]['attributes'][u'ped_energy'] = document['properties']['ped_energy'] + + if 'ecm' in document['properties']: + data['features'][0]['attributes'][u'ecm'] = document['properties']['ecm'] + + return JsonResponse(data['features'][0]['attributes']) diff --git a/templates/nyc.html b/templates/nyc.html index 48bba43..806ea1e 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -33,8 +33,8 @@ diff --git a/templates/rochester.html b/templates/rochester.html index 8939f1d..4b17a5e 100644 --- a/templates/rochester.html +++ b/templates/rochester.html @@ -10,18 +10,18 @@ - -
+
@@ -36,7 +36,38 @@
Very Effiencient
- +
+
+

+ +
+
+

+

+
+
+

Projected Energy Consumption

+

20,000kwh

+

Type 33% less efficient than similar buildings in this area.

+
+
+

Energy Conservation Measures

+

ECM's are the recommended energy saving measures this building can take in order to dramatically conserve energy.

+
+
    +

    We can help retrofit this building, just drop us a line!

    + Contact Blocpower +
    +
    +

    We haven't generated any ECM's for this building yet, but we can. if you're the owner or manager of this building email us at info@blocpower.org +

    +
    +
    +

    Building Details

    +
    +
    +

    Do you manage or own this building?

    +
    @@ -44,66 +75,73 @@ - + // START OSMB - in blocmaps.js // + startOSMB(position, bounds, pointerdown); + -- GitLab From f300f3d41d8ce45a5fa1db5bb14fa4bbf90b29f5 Mon Sep 17 00:00:00 2001 From: markAking Date: Mon, 12 Sep 2016 14:57:19 -0400 Subject: [PATCH 6/9] merging current into mapControls --- ebdjango/settings-dev.py | 19 ++++++++++++------- templates/nyc.html | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ebdjango/settings-dev.py b/ebdjango/settings-dev.py index c7dd0f6..e4c10c2 100644 --- a/ebdjango/settings-dev.py +++ b/ebdjango/settings-dev.py @@ -22,12 +22,14 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -#SECRET_KEY = os.environ['SECRET_KEY'] -SECRET_KEY = 'cs&36x94f3ek57l(*k(cl#-1xqir0njs4g6@%ncn!a*_@a5n$s' +SECRET_KEY = os.environ['SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +if os.environ['ENVIRONMENT'] == 'local': + DEBUG = True + ALLOWED_HOSTS = [] @@ -120,12 +122,15 @@ STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join('static'), ) # Google Analytics -# GOOGLE_ANALYTICS_KEY = 'UA-67611405-2' -# GOOGLE_ANALYTICS_DOMAIN = 'auto' +GOOGLE_ANALYTICS_KEY = 'UA-67611405-2' +GOOGLE_ANALYTICS_DOMAIN = 'auto' # AWS # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' -AWS_ACCESS_KEY_ID = 'AKIAIXRNGH4WE3GBSZYQ' -AWS_SECRET_ACCESS_KEY = '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' -AWS_STORAGE_BUCKET_NAME = 'blocmaps-assets' \ No newline at end of file +AWS_ACCESS_KEY_ID = os.environ['S3_ACCESS_KEY'] +AWS_SECRET_ACCESS_KEY = os.environ['S3_SECRET_KEY'] +AWS_STORAGE_BUCKET_NAME = 'blocmaps-assets' + +# MongoDB +MONGO_DB_URI = os.environ['MONGO_DB_URI'] \ No newline at end of file diff --git a/templates/nyc.html b/templates/nyc.html index 050033d..9d9cfd0 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -33,9 +33,8 @@ -- GitLab From 39b926826f2bf463afbad2afa6ef7b73ae957f5c Mon Sep 17 00:00:00 2001 From: markAking Date: Tue, 13 Sep 2016 12:02:25 -0400 Subject: [PATCH 7/9] fixing code for PR comments --- maps/views.py | 52 +++++++++++++++++++--------------------- templates/rochester.html | 2 +- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/maps/views.py b/maps/views.py index 408cae2..d4360f5 100644 --- a/maps/views.py +++ b/maps/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from django.template import loader from django.conf import settings from django.core.files.storage import default_storage @@ -10,14 +10,11 @@ import pymongo from pymongo import MongoClient from django.http import JsonResponse -def arcgis_nyc(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 = urlopen(url) - reader = codecs.getreader("utf-8") - return json.load(reader(response)) - -def arcgis_roc(building_id): - url = 'http://maps.cityofrochester.gov/arcgis/rest/services/App_PropertyInformation/ROC_Parcel_Query_SDE/MapServer/0/query??where=1=1&objectIds=%s&outFields=*&f=pjson' % building_id +def arcgis(building_id, city): + if city == 'roc': + url = 'http://maps.cityofrochester.gov/arcgis/rest/services/App_PropertyInformation/ROC_Parcel_Query_SDE/MapServer/0/query??where=1=1&objectIds=%s&outFields=*&f=pjson' % building_id + else: + 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 = urlopen(url) reader = codecs.getreader("utf-8") return json.load(reader(response)) @@ -32,11 +29,14 @@ def index(request, city = 'nyc'): context = { 'City': 'NYC', } - if city == 'roc': + elif city == 'roc': template = loader.get_template('rochester.html') context = { 'City': 'Rochester', } + else: + return HttpResponseRedirect('/nyc/') + return HttpResponse(template.render(context, request)) def tile(request, tile_x, tile_y): @@ -51,26 +51,10 @@ def tile(request, tile_x, tile_y): def building_detail(request, city = 'nyc'): bld_id = request.POST['id'] db = openMongo() - if city == 'nyc': - cursor = db.nyc.find({"_id": int(bld_id)}) - data = arcgis_nyc(bld_id) - - for document in cursor: - if 'prediction' in document['properties']: - data['features'][0]['properties'][u'prediction'] = document['properties']['prediction'] - - if 'ped_energy' in document['properties']: - data['features'][0]['properties'][u'ped_energy'] = document['properties']['ped_energy'] - - if 'ecm' in document['properties']: - data['features'][0]['properties'][u'ecm'] = document['properties']['ecm'] - - return JsonResponse(data['features'][0]['properties']) + data = arcgis(bld_id, city) if city == 'roc': cursor = db.roc.find({"_id": int(bld_id)}) - data = arcgis_roc(bld_id) - for document in cursor: data['features'][0]['attributes'][u'sqft'] = document['properties']['sqft'] data['features'][0]['attributes'][u'age'] = document['properties']['age'] @@ -86,3 +70,17 @@ def building_detail(request, city = 'nyc'): return JsonResponse(data['features'][0]['attributes']) + else: + cursor = db.nyc.find({"_id": int(bld_id)}) + for document in cursor: + if 'prediction' in document['properties']: + data['features'][0]['properties'][u'prediction'] = document['properties']['prediction'] + + if 'ped_energy' in document['properties']: + data['features'][0]['properties'][u'ped_energy'] = document['properties']['ped_energy'] + + if 'ecm' in document['properties']: + data['features'][0]['properties'][u'ecm'] = document['properties']['ecm'] + + return JsonResponse(data['features'][0]['properties']) + diff --git a/templates/rochester.html b/templates/rochester.html index 4b17a5e..a2eb11f 100644 --- a/templates/rochester.html +++ b/templates/rochester.html @@ -20,7 +20,7 @@ -- GitLab From a41d6559fa313793db9f95483848cc7381eed00c Mon Sep 17 00:00:00 2001 From: markAking Date: Tue, 13 Sep 2016 13:16:42 -0400 Subject: [PATCH 8/9] cleanup for google analytics --- .gitignore | 1 + ebdjango/custom_processors.py | 2 + ebdjango/settings-dev.py | 136 ---------------------------------- ebdjango/settings.py | 5 +- manage.py | 2 +- templates/nyc.html | 2 +- templates/rochester.html | 2 +- 7 files changed, 10 insertions(+), 140 deletions(-) delete mode 100644 ebdjango/settings-dev.py diff --git a/.gitignore b/.gitignore index f1a9e68..786c7e9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ _scratch crap eb-virt +accounts blocmaps.zip processed_tile.json *.pyc diff --git a/ebdjango/custom_processors.py b/ebdjango/custom_processors.py index f40dac8..96c0ee1 100644 --- a/ebdjango/custom_processors.py +++ b/ebdjango/custom_processors.py @@ -1,10 +1,12 @@ from django.conf import settings def google_analytics(request): + ga_show = getattr(settings, 'GOOGLE_ANALYTICS', False) ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_KEY', False) ga_domain = getattr(settings, 'GOOGLE_ANALYTICS_DOMAIN', False) if ga_prop_id and ga_domain: return { + 'GOOGLE_ANALYTICS': ga_show, 'GOOGLE_ANALYTICS_KEY': ga_prop_id, 'GOOGLE_ANALYTICS_DOMAIN': ga_domain, } diff --git a/ebdjango/settings-dev.py b/ebdjango/settings-dev.py deleted file mode 100644 index e4c10c2..0000000 --- a/ebdjango/settings-dev.py +++ /dev/null @@ -1,136 +0,0 @@ -""" -Django settings for blocmaps project. - -Generated by 'django-admin startproject' using Django 1.10. - -For more information on this file, see -https://docs.djangoproject.com/en/1.10/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.10/ref/settings/ -""" - -import os - -SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__)) - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = os.environ['SECRET_KEY'] - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -if os.environ['ENVIRONMENT'] == 'local': - DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - #'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'ebdjango.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(SETTINGS_PATH, 'templates')], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - 'ebdjango.custom_processors.google_analytics', - ], - }, - }, -] - -WSGI_APPLICATION = 'ebdjango.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases -# http://petrkout.com/programming/setting-up-django-with-mongodb/ -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.dummy' - } -} - -# Password validation -# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ - -LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' -USE_I18N = True -USE_L10N = True -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.10/howto/static-files/ - -STATIC_ROOT = '' -STATIC_URL = '/static/' -STATICFILES_DIRS = ( os.path.join('static'), ) - -# Google Analytics -GOOGLE_ANALYTICS_KEY = 'UA-67611405-2' -GOOGLE_ANALYTICS_DOMAIN = 'auto' - -# AWS -# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html -DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' -AWS_ACCESS_KEY_ID = os.environ['S3_ACCESS_KEY'] -AWS_SECRET_ACCESS_KEY = os.environ['S3_SECRET_KEY'] -AWS_STORAGE_BUCKET_NAME = 'blocmaps-assets' - -# MongoDB -MONGO_DB_URI = os.environ['MONGO_DB_URI'] \ No newline at end of file diff --git a/ebdjango/settings.py b/ebdjango/settings.py index 9d644ba..a7ed8ec 100644 --- a/ebdjango/settings.py +++ b/ebdjango/settings.py @@ -25,10 +25,13 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = os.environ['SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False +GOOGLE_ANALYTICS = True if os.environ['ENVIRONMENT'] == 'local': DEBUG = True + GOOGLE_ANALYTICS = False + ALLOWED_HOSTS = [] diff --git a/manage.py b/manage.py index 2621a08..19fddd0 100644 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ebdjango.settings-dev") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ebdjango.settings") try: from django.core.management import execute_from_command_line except ImportError: diff --git a/templates/nyc.html b/templates/nyc.html index c7131fa..0d5e145 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -200,7 +200,7 @@ startOSMB(position, bounds, pointerdown); -{% if GOOGLE_ANALYTICS_KEY %} +{% if GOOGLE_ANALYTICS %} -{% if GOOGLE_ANALYTICS_KEY %} +{% if GOOGLE_ANALYTICS %}