This commit is contained in:
Christian Quest 2016-05-06 22:25:45 +02:00
parent be0f5a958f
commit 304250fa7c

View file

@ -59,25 +59,25 @@ class EventResource(object):
if 'bbox' in req.params:
# limit search with bbox (E,S,W,N)
event_bbox = cur.mogrify(" AND geom && ST_SetSRID(ST_MakeBox2D(ST_Point(%s,%s),ST_Point(%s,%s)),4326) ",tuple(req.params['bbox']))
event_bbox = str(cur.mogrify(" AND geom && ST_SetSRID(ST_MakeBox2D(ST_Point(%s,%s),ST_Point(%s,%s)),4326) ",tuple(req.params['bbox'])))
elif 'near' in req.params:
# limit search with location+distance (long, lat, distance in meters)
event_bbox = cur.mogrify(" AND geom && st_expand(st_buffer(st_setsrid(st_makepoint(%s,%s),4326)::geography,%s)::geometry,0) ",tuple(req.params['near']))
event_bbox = str(cur.mogrify(" AND geom && st_expand(st_buffer(st_setsrid(st_makepoint(%s,%s),4326)::geography,%s)::geometry,0) ",tuple(req.params['near'])))
else:
event_bbox = ""
if 'when' in req.params:
# limit search with fixed time
event_when = cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['when'],req.params['when']))
event_when = str(cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['when'],req.params['when'])))
elif 'start' in req.params and 'stop' in req.params:
# limit search with fixed time
event_when = cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['start'],req.params['stop']))
event_when = str(cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['start'],req.params['stop'])))
else:
event_when = """tstzrange(now(),now(),'[]')"""
if 'what' in req.params:
# limit search based on "what"
event_what = cur.mogrify(" AND events_what LIKE %s ",(req.params['what']+"%",))
event_what = str(cur.mogrify(" AND events_what LIKE %s ",(req.params['what']+"%",)))
else:
event_what = ""