Skip to content

Commit

Permalink
Merge pull request #118 from tilezen/zerebubuth/add-overlaps-bbox-filter
Browse files Browse the repository at this point in the history
Add bbox overlaps filter.
  • Loading branch information
zerebubuth authored Nov 2, 2016
2 parents e09249a + 8d37ba4 commit 3c442a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tilequeue/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from tilequeue.query import jinja_filter_bbox_padded_intersection
from tilequeue.query import jinja_filter_bbox
from tilequeue.query import jinja_filter_geometry
from tilequeue.query import jinja_filter_bbox_overlaps
from tilequeue.queue import make_sqs_queue
from tilequeue.tile import coord_int_zoom_up
from tilequeue.tile import coord_marshall_int
Expand Down Expand Up @@ -372,6 +373,7 @@ def parse_layer_data(query_cfg, buffer_cfg, template_path, reload_templates,
environment.filters['bbox_padded_intersection'] = (
jinja_filter_bbox_padded_intersection)
environment.filters['bbox'] = jinja_filter_bbox
environment.filters['bbox_overlaps'] = jinja_filter_bbox_overlaps

for layer_name, layer_config in layers_config.items():
template_name = layer_config['template']
Expand Down
11 changes: 11 additions & 0 deletions tilequeue/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ def jinja_filter_bbox(bounds, srid=3857):
return bbox


def jinja_filter_bbox_overlaps(bounds, geometry_col_name, srid=3857):
min_point = 'ST_MakePoint(%.12f, %.12f)' % (bounds[0], bounds[1])
max_point = 'ST_MakePoint(%.12f, %.12f)' % (bounds[2], bounds[3])
bbox_no_srid = 'ST_MakeBox2D(%s, %s)' % (min_point, max_point)
bbox = 'ST_SetSrid(%s, %d)' % (bbox_no_srid, srid)
bbox_filter = \
'((%(col)s && %(bbox)s) AND st_overlaps(%(col)s, %(bbox)s))' \
% dict(col=geometry_col_name, bbox=bbox)
return bbox_filter


def build_feature_queries(unpadded_bounds, layer_data, zoom):
meters_per_pixel_dim = calc_meters_per_pixel_dim(zoom)
queries_to_execute = []
Expand Down

0 comments on commit 3c442a3

Please sign in to comment.