Changeset 9596


Ignore:
Timestamp:
Aug 28, 2011, 3:08:38 PM (13 years ago)
Author:
rick
Message:
  • Fixed the color and the URL locations references, to be more dynamic/logical.
  • Make the Organization do a catchall for the time beeing.
Location:
src/django_gheat/wlheatmap
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/wlheatmap/feature.py

    r9594 r9596  
    1313        "properties": {
    1414          'name' : node.name,
     15          'color' : 'rgb(0,255,0)',
    1516        },
    1617        "geometry": {
  • src/django_gheat/wlheatmap/filters.py

    r9592 r9596  
    2020      # Get list if accespoints found in the specific 'Meting', and make this is list.
    2121      wirelessleiden_ssid = Meting.objects.filter(meetrondje=mr,
    22         accespoint__organization__name='WirelessLeiden').\
     22        accespoint__organization__name__startswith='Wireless').\
    2323        values_list('accespoint__ssid',flat=True).\
    2424        order_by('accespoint__ssid').distinct()
  • src/django_gheat/wlheatmap/nodelist.py

    r9592 r9596  
    4040  filter = {}
    4141  filter.update({
    42     'organization__name' : 'WirelessLeiden',
     42    'organization__name__startswith' : 'Wireless',
    4343    'meting__latitude__lt' : maxlat,
    4444    'meting__longitude__lt' : maxlon,
  • src/django_gheat/wlheatmap/static/heatmap.js

    r9594 r9596  
    6969  //map.addLayer(layerHeatmap);
    7070
    71   // create the layer styleMap by giving the default style a context
    72   var colors = ["red", "green", "blue"];
    73   var context = {
    74       getSize: function(feature) {
    75         var resolution = map.getResolution();
    76         var scale = map.getZoom();
    77         var base = 1;
    78         if (scale > 16) {
    79           base = 5;
    80         } else if (scale > 14) {
    81           base = 20;
    82         } else {
    83           base = 50;
    84         }
    85         return (base / map.getResolution());
    86       }
    87   };
    88   var template = {
    89       pointRadius: "${getSize}", // using context.getSize(feature)
    90       fillColor: "lightgreen", // using context.getColor(feature)
    91       strokeWidth: 0.5,
    92   };
    93   var style = new OpenLayers.Style(template, {context: context});
    94   var geojson = new OpenLayers.Layer.GML("GeoJSON", "feature/nodes.json", {
    95     projection: new OpenLayers.Projection("EPSG:4326"),
    96     styleMap: new OpenLayers.StyleMap(style),
    97     format: OpenLayers.Format.GeoJSON
    98       });
    99   map.addLayer(geojson);
    100 
     71  var nodesLayer = new OpenLayers.Layer.GML.NodesOverlay("Node Locations", "feature/nodes.json", {isBaseLayer: false, visibility: true});
     72  map.addLayer(nodesLayer);
    10173
    10274  var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
     
    11789  $("#default").append("<span id=\"" + layerHeatmap3.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap3.colour + ")' /><input type=checkbox id=togglelayer checked/><font>" + layerHeatmap3.name + " </font><br /></span>");
    11890
     91  $("#features").append("<span id=\"" + nodesLayer.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + nodesLayer.colour + ")' /><input type=checkbox id=togglelayer checked/><font>" + nodesLayer.name + " </font><br /></span>");
     92
    11993}
  • src/django_gheat/wlheatmap/templates/js/LayerBase.js

    r9592 r9596  
    184184    initialize: function(name, options) {
    185185        var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
    186           '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization__name=WirelessLeiden');
     186          '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization__name__startswith=Wireless');
    187187        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    188188        var newArguments = [name, url, options];
     
    207207  CLASS_NAME: "OpenLayers.Layer.Overlay"
    208208});
     209
     210var foo;
     211
     212// create the layer styleMap by giving the default style a context
     213var context = {
     214    getSize: function(feature) {
     215      var resolution = map.getResolution();
     216      var scale = map.getZoom();
     217      var base = 1;
     218      if (scale > 16) {
     219        base = 5;
     220      } else if (scale > 14) {
     221        base = 20;
     222      } else {
     223        base = 50;
     224      }
     225      return (base / map.getResolution());
     226    },
     227    getColor: function(feature) {
     228      return feature.attributes.color;
     229
     230    }
     231};
     232var template = {
     233    pointRadius: "${getSize}", // using context.getSize(feature)
     234    fillColor: "${getColor}", // using context.getColor(feature)
     235    strokeWidth: 0.5,
     236};
     237var nodesStyle = new OpenLayers.Style(template, {context: context});
     238
     239OpenLayers.Layer.GML.NodesOverlay = OpenLayers.Class(OpenLayers.Layer.GML, {
     240    initialize: function(name, options) {
     241        var url = "{% url wlheatmap.feature.nodes_json %}";
     242        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     243        var newArguments = [name, url, options];
     244        OpenLayers.Layer.GML.prototype.initialize.apply(this, newArguments);
     245    },
     246    colour: '0,255,0',
     247    projection: new OpenLayers.Projection("EPSG:4326"),
     248    styleMap: new OpenLayers.StyleMap(nodesStyle),
     249    format: OpenLayers.Format.GeoJSON,
     250    CLASS_NAME: "OpenLayers.Layer.Overlay"
     251});
     252
Note: See TracChangeset for help on using the changeset viewer.