Changeset 9186 for src/django_gheat/website
- Timestamp:
- May 12, 2011, 12:56:07 PM (14 years ago)
- Location:
- src/django_gheat/website
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/nodelist.py
r9177 r9186 9 9 from django.db.models import Max 10 10 from django.http import HttpResponse 11 from django.core import serializers 11 12 from gheat.models import * 12 13 import logging … … 15 16 import tempfile 16 17 18 def make_list(swlat,swlon,nelat,nelon): 19 import simplejson 17 20 18 def serve_nodelist(request,lat,lon): 19 import simplejson as json 20 s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4 * ' ') 21 html = '\n'.join([l.rstrip() for l in s.splitlines()]) 21 filter = {} 22 filter.update({ 23 'accespoint__ssid__contains' : 'WirelessLeiden', 24 'latitude__lt' : swlat, 25 'longitude__lt' : swlon, 26 'latitude__gt' : nelat, 27 'longitude__gt' : nelon 28 }) 29 30 html = Meting.objects.filter(**filter).values('accespoint__ssid').distinct() 31 nodelist = simplejson.dumps(list(html)) 32 return HttpResponse(nodelist, content_type = 'application/javascript; charset=utf8') 33 34 def serve_nodelist(request,swlat,swlon,nelat,nelon): 35 html = make_list(float(swlat),float(swlon),float(nelat),float(nelon)) 22 36 return HttpResponse(html) 37 -
src/django_gheat/website/static/heatmap.js
r9177 r9186 21 21 map.events.register('click', map, GetMousePos); 22 22 function GetMousePos(pos) { 23 var pixel = new OpenLayers.Pixel(pos.xy.x,pos.xy.y); 24 var lonlat = map.getLonLatFromPixel(pixel); 25 var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon, lonlat.lat); 26 loadNodeList(mousepos); 23 var pixbuffer = 100; 24 var sw = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x+pixbuffer,pos.xy.y-pixbuffer)); 25 var ne = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x-pixbuffer,pos.xy.y+pixbuffer)); 26 var pointsw = OpenLayers.Layer.SphericalMercator.inverseMercator(sw.lon, sw.lat); 27 var pointne = OpenLayers.Layer.SphericalMercator.inverseMercator(ne.lon, ne.lat); 28 getNodeList(pointsw, pointne); 27 29 } 28 30 … … 46 48 } 47 49 48 function loadNodeList(mousepos){50 function getNodeList(sw, ne){ 49 51 var nodelist; 50 52 if (window.XMLHttpRequest){ … … 59 61 nodelist.onreadystatechange=function(){ 60 62 if (nodelist.readyState==4 && nodelist.status==200){ 61 txt= eval("("+nodelist.responseText+")")63 txt=nodelist.responseText 62 64 document.getElementById('nodelist').innerHTML=txt; 63 65 } 64 66 } 65 67 66 nodelist.open("GET","/website/nodelist/" + mousepos.lat + "," + mousepos.lon,true);68 nodelist.open("GET","/website/nodelist/" + sw.lat + "," + sw.lon + "," + ne.lat + "," + ne.lon,true); 67 69 nodelist.send(); 68 70 } -
src/django_gheat/website/urls.py
r9177 r9186 22 22 urlpatterns += patterns('website.nodelist', 23 23 url( 24 regex = r'^nodelist/(?P< lat>[0-9.]+),(?P<lon>[0-9.]+)$',24 regex = r'^nodelist/(?P<swlat>[0-9.]+),(?P<swlon>[0-9.]+),(?P<nelat>[0-9.]+),(?P<nelon>[0-9.]+)$', 25 25 view = 'serve_nodelist', 26 26 name = 'serve_nodelist',
Note:
See TracChangeset
for help on using the changeset viewer.