-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makes queries per-table #227
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,3 +443,104 @@ def process_coord(coord, nominal_zoom, feature_layers, post_process_data, | |
unpadded_bounds, cut_coords, buffer_cfg, extra_data, scale) | ||
|
||
return all_formatted_tiles, extra_data | ||
|
||
|
||
def convert_source_data_to_feature_layers(rows, layer_data, bounds, zoom): | ||
# TODO we might want to fold in the other processing into this | ||
# step at some point. This will prevent us from having to iterate | ||
# through all the features again. | ||
|
||
layers = ( | ||
'boundaries', | ||
'buildings', | ||
'earth', | ||
'landuse', | ||
'places', | ||
'pois', | ||
'roads', | ||
'transit', | ||
'water', | ||
) | ||
|
||
features_by_layer = {} | ||
for layer in layers: | ||
features_by_layer[layer] = [] | ||
|
||
for row in rows: | ||
|
||
fid = row.pop('__id__') | ||
|
||
geometry = row.pop('__geometry__', None) | ||
label_geometry = row.pop('__label__', None) | ||
boundaries_geometry = row.pop('__boundaries_geometry__', None) | ||
assert geometry or boundaries_geometry | ||
|
||
common_props = row.pop('__properties__', None) or {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the same thing as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see... the way it is at the moment handles the case where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just confused myself too, so I expanded it out and added a comment in da19aa0. |
||
|
||
row_props_by_layer = dict( | ||
boundaries=row.pop('__boundaries_properties__', None), | ||
buildings=row.pop('__buildings_properties__', None), | ||
earth=row.pop('__earth_properties__', None), | ||
landuse=row.pop('__landuse_properties__', None), | ||
places=row.pop('__places_properties__', None), | ||
pois=row.pop('__pois_properties__', None), | ||
roads=row.pop('__roads_properties__', None), | ||
transit=row.pop('__transit_properties__', None), | ||
water=row.pop('__water_properties__', None), | ||
) | ||
|
||
# TODO at first pass, simulate the structure that we're | ||
# expecting downstream in the process_coord function | ||
for layer in layers: | ||
layer_props = row_props_by_layer[layer] | ||
if layer_props is not None: | ||
props = common_props.copy() | ||
props.update(layer_props) | ||
|
||
min_zoom = props.get('min_zoom', None) | ||
assert min_zoom is not None, \ | ||
'Missing min_zoom in layer %s' % layer | ||
|
||
# a feature can belong to more than one layer | ||
# this check ensures that it only appears in the | ||
# layers it should | ||
if min_zoom is None: | ||
continue | ||
# TODO would be better if 16 wasn't hard coded here | ||
if zoom < 16 and min_zoom >= zoom + 1: | ||
continue | ||
|
||
query_props = dict( | ||
__properties__=props, | ||
__id__=fid, | ||
) | ||
|
||
if boundaries_geometry and layer == 'boundaries': | ||
geom = boundaries_geometry | ||
else: | ||
geom = geometry | ||
query_props['__geometry__'] = geom | ||
if label_geometry: | ||
query_props['__label__'] = label_geometry | ||
|
||
features_by_layer[layer].append(query_props) | ||
|
||
feature_layers = [] | ||
for layer_datum in layer_data: | ||
layer = layer_datum['name'] | ||
features = features_by_layer[layer] | ||
# TODO padded bounds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support the MVT Buffered format or something additional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly. |
||
padded_bounds = dict( | ||
polygon=bounds, | ||
line=bounds, | ||
point=bounds, | ||
) | ||
feature_layer = dict( | ||
name=layer, | ||
features=features, | ||
layer_datum=layer_datum, | ||
padded_bounds=padded_bounds, | ||
) | ||
feature_layers.append(feature_layer) | ||
|
||
return feature_layers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a note for the glorious future or for the current sprint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would have been a performance improvement, if we find that when we run it on dev it's too slow. If it's unnecessary, it might be better to hold off on this since it might change with phase 3 anyway.