Changeset 9166 for src


Ignore:
Timestamp:
May 8, 2011, 8:59:15 PM (14 years ago)
Author:
rick
Message:

Some nice hacks to do filtered dynamic views and alternating colours if needed.

Location:
src/django_gheat/website
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/static/OpenStreetMap.js

    r9147 r9166  
    158158    initialize: function(name, options) {
    159159        var url = [
    160             "/website/tile/${z}/${x},${y}.png"
     160            "/website/tile/${z}/${x},${y}.png?colour=255,0,0"
    161161        ];
    162162        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     
    167167    CLASS_NAME: "OpenLayers.Layer.Overlay2"
    168168});
     169
     170OpenLayers.Layer.OSM.Overlay3 = OpenLayers.Class(OpenLayers.Layer.OSM, {
     171    initialize: function(name, options) {
     172        var url = [
     173            "/website/tile/${z}/${x},${y}.png?colour=0,0,255&accespoint__ssid__icontains=WirelessLeiden"
     174        ];
     175        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     176        var newArguments = [name, url, options];
     177        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
     178    },
     179
     180    CLASS_NAME: "OpenLayers.Layer.Overlay3"
     181});
  • src/django_gheat/website/static/heatmap.js

    r9147 r9166  
    2424        map.addLayer(layerHeatmap);
    2525
    26         layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("Overlay 2", {isBaseLayer: false, visibility: false});
     26        layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: false});
    2727        map.addLayer(layerHeatmap2);
     28
     29        layerHeatmap3 = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Only", {isBaseLayer: false, visibility: true});
     30        map.addLayer(layerHeatmap3);
    2831       
    2932        var lon   = 4.48907;
  • src/django_gheat/website/tile.py

    r9152 r9166  
    144144
    145145
    146 def make_tile(x,y,z):
     146def make_tile(x,y,z,filter={},colour=(255,0,0)):
    147147  """
    148148  Crude attempt to generate tiles, by placing a gradient circle on a
     
    187187  lat_max = 0
    188188  lon_max = 0
    189  
     189
     190  filter.update({
     191    'latitude__lte' : nw_deg.lat,
     192    'latitude__gte' : se_deg.lat,
     193    'longitude__lte' : se_deg.lon,
     194    'longitude__gte' : nw_deg.lon
     195  })
    190196  # TODO: This is currently hard-coded to display _all_ metingen
    191   metingen = Meting.objects.select_related().filter(
    192      latitude__lte=nw_deg.lat,latitude__gte=se_deg.lat,
    193      longitude__lte=se_deg.lon,longitude__gte=nw_deg.lon)
     197  metingen = Meting.objects.select_related().filter(**filter)
    194198
    195199  # XXX: Signal is not normalized in the database making it unknown when a
     
    232236    # http://stackoverflow.com/questions/3104781/inverse-distance-weighted-idw-interpolation-with-python
    233237    signal_normalized = MAX_RANGE - (MAX_SIGNAL - meting.signaal)
    234     im.add_circle((xcoord,ycoord),float(signal_normalized) / meters_per_pixel,(255,0,0), MAX_SIGNAL - meting.signaal)
     238    im.add_circle((xcoord,ycoord),float(signal_normalized) / meters_per_pixel,colour, MAX_SIGNAL - meting.signaal)
    235239 
    236240  log.info("BoundingBox NW: %s" % nw_deg)
     
    248252# Create your views here.
    249253def serve_tile(request,zoom,x,y):
    250   im = make_tile(int(x),int(y),int(zoom))
     254  filter = {}
     255  colour = (255,0,0)
     256  for key, value in request.GET.iteritems():
     257    if key == 'colour':
     258      colour = tuple(map(int,value.split(',')))
     259    else:
     260      filter[key] = value
     261  im = make_tile(int(x),int(y),int(zoom),filter=filter,colour=colour)
    251262  response = HttpResponse(mimetype="image/png")
    252263  im.write(response,'png')
Note: See TracChangeset for help on using the changeset viewer.