Changeset 9186


Ignore:
Timestamp:
May 12, 2011, 12:56:07 PM (14 years ago)
Author:
dennisw
Message:

Nodelist progress. Shows nodes around mouse when you click on map. Next; fix boundaries per zoomlevel and nodelist display.

Location:
src/django_gheat/website
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/nodelist.py

    r9177 r9186  
    99from django.db.models import Max
    1010from django.http import HttpResponse
     11from django.core import serializers
    1112from gheat.models import *
    1213import logging
     
    1516import tempfile
    1617
     18def make_list(swlat,swlon,nelat,nelon):
     19  import simplejson
    1720
    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
     34def serve_nodelist(request,swlat,swlon,nelat,nelon):
     35  html = make_list(float(swlat),float(swlon),float(nelat),float(nelon))
    2236  return HttpResponse(html)
     37
  • src/django_gheat/website/static/heatmap.js

    r9177 r9186  
    2121        map.events.register('click', map, GetMousePos);
    2222        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);
    2729        }
    2830
     
    4648}
    4749
    48 function loadNodeList(mousepos){
     50function getNodeList(sw, ne){
    4951  var nodelist;
    5052  if (window.XMLHttpRequest){
     
    5961  nodelist.onreadystatechange=function(){
    6062    if (nodelist.readyState==4 && nodelist.status==200){
    61       txt=eval("("+nodelist.responseText+")")
     63      txt=nodelist.responseText
    6264      document.getElementById('nodelist').innerHTML=txt;
    6365    }
    6466  }
    6567
    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);
    6769  nodelist.send();
    6870}
  • src/django_gheat/website/urls.py

    r9177 r9186  
    2222urlpatterns += patterns('website.nodelist',
    2323    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.]+)$',
    2525        view = 'serve_nodelist',
    2626        name = 'serve_nodelist',
Note: See TracChangeset for help on using the changeset viewer.