diff --git a/ebdjango/urls.py b/ebdjango/urls.py index ffe5376da57cfe39de68c702882e62f20f0ba924..4781e2349633810962b44f166b42759f49f36479 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 68c82f27b1b963adedb948ccc591c7d702f82920..0000000000000000000000000000000000000000 --- 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 b2f2ce680c6c064cf8180abf77e30f129d5478c4..d4360f5d2fa38d5a2fd39e08b9cfcaea735fd97f 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,8 +10,11 @@ import pymongo from pymongo import MongoClient 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 +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)) @@ -20,11 +23,20 @@ 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', + } + 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): @@ -36,20 +48,39 @@ 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']) + data = arcgis(bld_id, city) + + if city == 'roc': + cursor = db.roc.find({"_id": int(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']) + + 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/nyc.html b/templates/nyc.html index 48bba436d2f9ba50e9e25a450a2b93768d7754c8..806ea1e664bed497df1f505b1937e06d64ce1333 100644 --- a/templates/nyc.html +++ b/templates/nyc.html @@ -33,8 +33,8 @@ diff --git a/templates/rochester.html b/templates/rochester.html index 8939f1dbc8cef9bb0b8cf5a55b766b76c8b5d8b4..a2eb11fe570671ba5b8d6fdf3da0d9303ad8c24b 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); +