Changeset 9196 for src/django_gheat
- Timestamp:
- May 13, 2011, 12:23:52 PM (14 years ago)
- Location:
- src/django_gheat/website
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/nodelist.py
r9186 r9196 16 16 import tempfile 17 17 18 def make_list(swlat,swlon,nelat,nelon): 19 import simplejson 18 def make_list(zoom,lat,lon): 19 20 maxlat = (lat + 0.01) 21 maxlon = (lon + 0.01) 22 minlat = (lat - 0.01) 23 minlon = (lon - 0.01) 20 24 21 25 filter = {} 22 26 filter.update({ 23 ' accespoint__ssid__contains' : 'WirelessLeiden',24 ' latitude__lt' : swlat,25 ' longitude__lt' : swlon,26 ' latitude__gt' : nelat,27 ' longitude__gt' : nelon27 'ssid__contains' : 'WirelessLeiden', 28 'meting__latitude__lt' : maxlat, 29 'meting__longitude__lt' : maxlon, 30 'meting__latitude__gt' : minlat, 31 'meting__longitude__gt' : minlon 28 32 }) 29 33 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') 34 objquery = Accespoint.objects.filter(**filter).distinct() 35 nodelist = serializers.serialize('json', objquery, fields=('fields','ssid')) 33 36 34 def serve_nodelist(request,swlat,swlon,nelat,nelon): 35 html = make_list(float(swlat),float(swlon),float(nelat),float(nelon)) 36 return HttpResponse(html) 37 return nodelist 37 38 39 def serve_nodelist(request,zoom,lat,lon,): 40 html = make_list(int(zoom), float(lat), float(lon)) 41 return HttpResponse(html, content_type = 'application/javascript; charset=utf8') 42 -
src/django_gheat/website/static/heatmap.js
r9190 r9196 21 21 map.events.register('click', map, GetMousePos); 22 22 function GetMousePos(pos) { 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); 23 var pix = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x,pos.xy.y)); 24 var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(pix.lon, pix.lat); 25 var zoomlevel = map.getZoom(); 26 getNodeList(zoom, mousepos); 29 27 } 30 28 … … 49 47 } 50 48 51 function getNodeList( sw, ne){49 function getNodeList(zoomlevel, mousepos){ 52 50 var nodelist; 53 51 if (window.XMLHttpRequest){ … … 62 60 nodelist.onreadystatechange=function(){ 63 61 if (nodelist.readyState==4 && nodelist.status==200){ 64 txt=nodelist.responseText 62 txt=nodelist.responseText; 65 63 document.getElementById('nodelist').innerHTML=txt; 66 64 } 67 65 } 68 66 69 nodelist.open("GET","/website/nodelist/" + sw.lat + "," + sw.lon + "," + ne.lat + "," + ne.lon,true);67 nodelist.open("GET","/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,true); 70 68 nodelist.send(); 71 69 } -
src/django_gheat/website/urls.py
r9189 r9196 31 31 urlpatterns += patterns('website.nodelist', 32 32 url( 33 regex = r'^nodelist/(?P< swlat>[0-9.]+),(?P<swlon>[0-9.]+),(?P<nelat>[0-9.]+),(?P<nelon>[0-9.]+)$',33 regex = r'^nodelist/(?P<zoom>\d+),(?P<lat>[0-9.]+),(?P<lon>[0-9.]+)$', 34 34 view = 'serve_nodelist', 35 35 name = 'serve_nodelist',
Note:
See TracChangeset
for help on using the changeset viewer.