distance is now optional in 'near' search (defaults to 1m)
This commit is contained in:
parent
a2125a74ba
commit
08bee9d947
2 changed files with 6 additions and 2 deletions
|
@ -77,7 +77,11 @@ class EventResource(object):
|
||||||
event_dist = ""
|
event_dist = ""
|
||||||
elif 'near' in req.params:
|
elif 'near' in req.params:
|
||||||
# limit search with location+distance (long, lat, distance in meters)
|
# limit search with location+distance (long, lat, distance in meters)
|
||||||
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")
|
if len(req.params['near'])<3:
|
||||||
|
dist = 1
|
||||||
|
else:
|
||||||
|
dist = req.params['near'][2]
|
||||||
|
event_bbox = cur.mogrify(" AND ST_Intersects(geom, ST_Buffer(st_setsrid(st_makepoint(%s,%s),4326)::geography,%s)::geometry) ",(req.params['near'][0], req.params['near'][1], dist)).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")
|
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:
|
else:
|
||||||
event_bbox = ""
|
event_bbox = ""
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
{
|
{
|
||||||
"name": "near",
|
"name": "near",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"description": "Event search by distance (long, lat, distance in meters)",
|
"description": "Event search by distance (long, lat, optional distance in meters)",
|
||||||
"required": false,
|
"required": false,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-example": "2.5,48.8,500"
|
"x-example": "2.5,48.8,500"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue