12
12
from tilequeue .tile import calc_meters_per_pixel_dim
13
13
from tilequeue .tile import coord_to_mercator_bounds
14
14
from 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
16
16
from tilequeue .transform import transform_feature_layers_shape
17
17
from tilequeue import utils
18
18
from zope .dottedname .resolve import resolve
@@ -518,7 +518,7 @@ def process_coord(coord, nominal_zoom, feature_layers, post_process_data,
518
518
return all_formatted_tiles , extra_data
519
519
520
520
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 ):
522
522
# TODO we might want to fold in the other processing into this
523
523
# step at some point. This will prevent us from having to iterate
524
524
# through all the features again.
@@ -581,12 +581,9 @@ def convert_source_data_to_feature_layers(rows, layer_data, bounds, zoom):
581
581
for layer_datum in layer_data :
582
582
layer_name = layer_datum ['name' ]
583
583
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 ))
590
587
feature_layer = dict (
591
588
name = layer_name ,
592
589
features = features ,
@@ -748,24 +745,25 @@ def __init__(self, coord, metatile_zoom, fetch_fn, layer_data,
748
745
self .cfg_tile_sizes = cfg_tile_sizes
749
746
self .log_fn = None
750
747
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 )
753
751
752
+ def fetch (self ):
754
753
cut_coords_by_zoom = calculate_cut_coords_by_zoom (
755
754
self .coord , self .metatile_zoom , self .cfg_tile_sizes , self .max_zoom )
756
755
feature_layers_by_zoom = {}
757
756
758
757
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 )
760
759
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 )
762
761
feature_layers_by_zoom [nominal_zoom ] = feature_layers
763
762
764
763
self .cut_coords_by_zoom = cut_coords_by_zoom
765
764
self .feature_layers_by_zoom = feature_layers_by_zoom
766
765
767
766
def process_tiles (self ):
768
- unpadded_bounds = coord_to_mercator_bounds (self .coord )
769
767
770
768
all_formatted_tiles = []
771
769
all_extra_data = {}
@@ -782,7 +780,7 @@ def log_fn(data):
782
780
feature_layers = self .feature_layers_by_zoom [nominal_zoom ]
783
781
formatted_tiles , extra_data = process_coord (
784
782
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 ,
786
784
cut_coords , self .buffer_cfg , self .output_calc_mapping ,
787
785
log_fn = log_fn ,
788
786
)
0 commit comments