near distance using buffer intersection

This commit is contained in:
Christian Quest 2016-05-09 14:13:34 +02:00
parent 48a18584c3
commit 0537b09e47

View file

@ -77,7 +77,7 @@ class EventResource(object):
event_dist = ""
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'])).decode("utf-8")
event_bbox = cur.mogrify(" AND ST_Intersects(geom, ST_Buffer(st_setsrid(st_makepoint(%s,%s),4326)::geography,%s)::geometry) ",tuple(req.params['near'])).decode("utf-8")
event_dist = cur.mogrify(", 'distance', ST_Length(ST_ShortestLine(geom, st_setsrid(st_makepoint(%s,%s),4326))::geography) ",(req.params['near'][0], req.params['near'][1])).decode("utf-8")
else:
event_bbox = ""