From 6e63276f6099b52de0136d3b0209d1ef1dd2db8f Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Wed, 19 Dec 2018 12:37:21 +0000 Subject: [PATCH] Fix fixture name allocation logic to match the PostgreSQL query logic and RAWR tile processing logic. --- tilequeue/query/fixture.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tilequeue/query/fixture.py b/tilequeue/query/fixture.py index d2d37eb9..400edde5 100644 --- a/tilequeue/query/fixture.py +++ b/tilequeue/query/fixture.py @@ -166,6 +166,10 @@ def __call__(self, zoom, unpadded_bounds): # whether to clip to a padded box has_water_layer = False + # tracking which layers claim this feature, as this is important to + # figure out which layer will be assigned the name. + claims_feature_at_some_zoom = set() + for layer_name, info in self.layers.items(): if not info.allows_shape_type(shape): continue @@ -186,6 +190,10 @@ def __call__(self, zoom, unpadded_bounds): if min_zoom is None: continue + # make a note that this feature is claimed at some zoom by this + # layer, which is important for name processing. + claims_feature_at_some_zoom.add(layer_name) + # reject anything which isn't in the current zoom range # note that this is (zoom+1) because things with a min_zoom of # (e.g) 14.999 should still be in the zoom 14 tile. @@ -242,9 +250,15 @@ def __call__(self, zoom, unpadded_bounds): names[k] = props[k] if names: for layer_name in ('pois', 'landuse', 'buildings'): - props_name = '__%s_properties__' % layer_name - if props_name in read_row: - read_row[props_name].update(names) + if layer_name in claims_feature_at_some_zoom: + props_name = '__%s_properties__' % layer_name + if props_name in read_row: + read_row[props_name].update(names) + # break regardless of whether or not we managed to + # update the row - sometimes a feature is claimed + # in one layer at a min_zoom higher than another + # layer's min_zoom. so the feature is visible + # before it gets labelled. break read_row['__id__'] = fid