Changeset b9c26fc in osmose-frontend


Ignore:
Timestamp:
Feb 10, 2013 6:30:24 PM (7 years ago)
Author:
Frédéric Rodrigo <frodrigo@…>
Branches:
master
Children:
944011b
Parents:
fbd8970
Message:

Use tool query in heatmap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • map.py

    r36d7234 rb9c26fc  
    159159    x1,y2 = num2deg(x+1,y+1,z) 
    160160 
    161     item     = request.params.get('item') 
    162     source   = request.params.get('source', default='') 
    163     classs   = request.params.get('class', default='') 
    164     username = utils.pg_escape(unicode(request.params.get('username', default=''))) 
    165     level    = request.params.get('level', default='1') 
    166  
    167     COUNT=32 
    168  
    169     items = errors._build_where_item(item, "dynpoi_item") 
     161    params = query._params() 
     162    params.bbox = [int(x1*10e5), int(y1*10e5), int(x2*10e5), int(y2*10e5)] 
     163    items = query._build_where_item(params.item, "dynpoi_item") 
    170164 
    171165    db.execute(""" 
     
    183177        max = 0 
    184178 
    185     join, where = errors._build_param(source, item, level, username, classs) 
    186  
    187     db.execute(""" 
     179    join, where = query._build_param(params.bbox, params.source, params.item, params.level, params.username, params.classs, params.country, params.active, params.status) 
     180 
     181    COUNT=32 
     182 
     183    sql = """ 
    188184SELECT 
    189185    COUNT(*), 
     
    191187    (((lat-%(x1)s))*%(count)s/(%(x2)s-%(x1)s)-0.5)::int AS lonn 
    192188FROM 
    193     marker 
    194189""" + join + """ 
    195190WHERE 
    196 """ + where + """ AND 
    197     lat>%(x1)s::int AND 
    198     lon>%(y1)s::int AND 
    199     lat<%(x2)s::int AND 
    200     lon<%(y2)s::int 
     191""" + where + """ 
    201192GROUP BY 
    202193    latn, 
    203194    lonn 
    204 """, {"x1":x1*10e5, "y1":y1*10e5, "x2":x2*10e5, "y2":y2*10e5, "count":COUNT}) 
     195""" 
     196    db.execute(sql, {"x1":x1*10e5, "y1":y1*10e5, "x2":x2*10e5, "y2":y2*10e5, "count":COUNT}) 
    205197    im = Image.new("RGB", (256,256), "#ff0000") 
    206198    draw = ImageDraw.Draw(im) 
Note: See TracChangeset for help on using the changeset viewer.