Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0))
elif 'bbox' in geometry and 'geom' in geometry:
geom_bbox = geometry['bbox'].wkt
geom = geometry['geom'].wkt
filters.append( # in bbox
geo_func.ST_DWithin(
geo_func.ST_Intersection(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']),
type_coerce(geom_bbox, Geography)), Pois.geom, 0))
elif 'bbox' not in geometry and 'geom' in geometry:
geom = geometry['geom'].wkt
filters.append( # buffer around geom
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0)
)
return filters, geom
def generate_geom_filters(geometry, Pois):
filters, geom = [], None
if 'bbox' in geometry and 'geom' not in geometry:
geom = geometry['bbox'].wkt
filters.append(
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0))
elif 'bbox' in geometry and 'geom' in geometry:
geom_bbox = geometry['bbox'].wkt
geom = geometry['geom'].wkt
filters.append( # in bbox
geo_func.ST_DWithin(
geo_func.ST_Intersection(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']),
type_coerce(geom_bbox, Geography)), Pois.geom, 0))
elif 'bbox' not in geometry and 'geom' in geometry:
geom = geometry['geom'].wkt
filters.append( # buffer around geom
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0)
)
def refine_with_user_area(query):
"""Takes a query and refines it with a spatial constraint
based on user setting"""
if 'lon' and 'lat' and 'radius' in session:
return query.filter(ST_DWithin(
cast(Task.location, Geography),
cast(from_shape(Point(session["lon"], session["lat"])), Geography),
session["radius"]))
else:
return query
def generate_geom_filters(geometry, Pois):
filters, geom = [], None
if 'bbox' in geometry and 'geom' not in geometry:
geom = geometry['bbox'].wkt
filters.append(
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0))
elif 'bbox' in geometry and 'geom' in geometry:
geom_bbox = geometry['bbox'].wkt
geom = geometry['geom'].wkt
filters.append( # in bbox
geo_func.ST_DWithin(
geo_func.ST_Intersection(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']),
type_coerce(geom_bbox, Geography)), Pois.geom, 0))
elif 'bbox' not in geometry and 'geom' in geometry:
geom = geometry['geom'].wkt
filters.append( # buffer around geom
geo_func.ST_DWithin(geo_func.ST_Buffer(type_coerce(geom, Geography), geometry['buffer']), Pois.geom, 0)
)
return filters, geom