1212from tilequeue .tile import calc_meters_per_pixel_dim
1313from tilequeue .tile import coord_to_mercator_bounds
1414from tilequeue .tile import normalize_geometry_type
15- from tilequeue .transform import mercator_point_to_lnglat
15+ from tilequeue .transform import mercator_point_to_lnglat , calc_max_padded_bounds
1616from tilequeue .transform import transform_feature_layers_shape
1717from tilequeue import utils
1818from zope .dottedname .resolve import resolve
@@ -518,7 +518,7 @@ def process_coord(coord, nominal_zoom, feature_layers, post_process_data,
518518 return all_formatted_tiles , extra_data
519519
520520
521- def convert_source_data_to_feature_layers (rows , layer_data , bounds , zoom ):
521+ def convert_source_data_to_feature_layers (rows , layer_data , unpadded_bounds , zoom ):
522522 # TODO we might want to fold in the other processing into this
523523 # step at some point. This will prevent us from having to iterate
524524 # through all the features again.
@@ -581,12 +581,9 @@ def convert_source_data_to_feature_layers(rows, layer_data, bounds, zoom):
581581 for layer_datum in layer_data :
582582 layer_name = layer_datum ['name' ]
583583 features = features_by_layer [layer_name ]
584- # TODO padded bounds
585- padded_bounds = dict (
586- polygon = bounds ,
587- line = bounds ,
588- point = bounds ,
589- )
584+ query_bounds_pad_fn = layer_datum ['query_bounds_pad_fn' ]
585+
586+ padded_bounds = query_bounds_pad_fn (unpadded_bounds , calc_meters_per_pixel_dim (zoom ))
590587 feature_layer = dict (
591588 name = layer_name ,
592589 features = features ,
@@ -748,24 +745,25 @@ def __init__(self, coord, metatile_zoom, fetch_fn, layer_data,
748745 self .cfg_tile_sizes = cfg_tile_sizes
749746 self .log_fn = None
750747
751- def fetch (self ):
752- unpadded_bounds = coord_to_mercator_bounds (self .coord )
748+ self .unpadded_bounds = coord_to_mercator_bounds (self .coord )
749+ meters_per_pixel_dim = calc_meters_per_pixel_dim (self .coord .zoom )
750+ self .max_padded_bounds = calc_max_padded_bounds (self .unpadded_bounds , meters_per_pixel_dim , self .buffer_cfg )
753751
752+ def fetch (self ):
754753 cut_coords_by_zoom = calculate_cut_coords_by_zoom (
755754 self .coord , self .metatile_zoom , self .cfg_tile_sizes , self .max_zoom )
756755 feature_layers_by_zoom = {}
757756
758757 for nominal_zoom , _ in cut_coords_by_zoom .items ():
759- source_rows = self .fetch_fn (nominal_zoom , unpadded_bounds )
758+ source_rows = self .fetch_fn (nominal_zoom , self . max_padded_bounds )
760759 feature_layers = convert_source_data_to_feature_layers (
761- source_rows , self .layer_data , unpadded_bounds , self .coord .zoom )
760+ source_rows , self .layer_data , self . unpadded_bounds , self .coord .zoom )
762761 feature_layers_by_zoom [nominal_zoom ] = feature_layers
763762
764763 self .cut_coords_by_zoom = cut_coords_by_zoom
765764 self .feature_layers_by_zoom = feature_layers_by_zoom
766765
767766 def process_tiles (self ):
768- unpadded_bounds = coord_to_mercator_bounds (self .coord )
769767
770768 all_formatted_tiles = []
771769 all_extra_data = {}
@@ -782,7 +780,7 @@ def log_fn(data):
782780 feature_layers = self .feature_layers_by_zoom [nominal_zoom ]
783781 formatted_tiles , extra_data = process_coord (
784782 self .coord , nominal_zoom , feature_layers ,
785- self .post_process_data , self .formats , unpadded_bounds ,
783+ self .post_process_data , self .formats , self . unpadded_bounds ,
786784 cut_coords , self .buffer_cfg , self .output_calc_mapping ,
787785 log_fn = log_fn ,
788786 )
0 commit comments