Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Address points in buildings layer sometimes missing min_zoom #2023

Closed
nvkelso opened this issue Dec 5, 2021 · 2 comments
Closed

Address points in buildings layer sometimes missing min_zoom #2023

nvkelso opened this issue Dec 5, 2021 · 2 comments
Milestone

Comments

@nvkelso
Copy link
Member

nvkelso commented Dec 5, 2021

Occasionally the address points exported in the buildings layer are missing min_zoom props.

Besides the vanilla address nodes in OSM, Tilezen harvests address points in queries.yaml off ways as well via this transform.py logic:

  • def generate_address_points(ctx):
    """
    Generates address points from building polygons where there is an
    addr:housenumber tag on the building. Removes those tags from the
    building.
    """
    feature_layers = ctx.feature_layers
    zoom = ctx.nominal_zoom
    source_layer = ctx.params.get('source_layer')
    assert source_layer, 'generate_address_points: missing source_layer'
    start_zoom = ctx.params.get('start_zoom', 0)
    if zoom < start_zoom:
    return None
    layer = _find_layer(feature_layers, source_layer)
    if layer is None:
    return None
    new_features = []
    for feature in layer['features']:
    shape, properties, fid = feature
    # We only want to create address points for polygonal
    # buildings with address tags.
    if shape.geom_type not in ('Polygon', 'MultiPolygon'):
    continue
    addr_housenumber = properties.get('addr_housenumber')
    # consider it an address if the name of the building
    # is just a number.
    name = properties.get('name')
    if name is not None and digits_pattern.match(name):
    if addr_housenumber is None:
    addr_housenumber = properties.pop('name')
    # and also suppress the name if it's the same as
    # the address.
    elif name == addr_housenumber:
    properties.pop('name')
    # if there's no address, then keep the feature as-is,
    # no modifications.
    if addr_housenumber is None:
    continue
    label_point = shape.representative_point()
    # we're only interested in a very few properties for
    # address points.
    label_properties = dict(
    addr_housenumber=addr_housenumber,
    kind='address')
    source = properties.get('source')
    if source is not None:
    label_properties['source'] = source
    addr_street = properties.get('addr_street')
    if addr_street is not None:
    label_properties['addr_street'] = addr_street
    oid = properties.get('id')
    if oid is not None:
    label_properties['id'] = oid
    label_feature = label_point, label_properties, fid
    new_features.append(label_feature)
    layer['features'].extend(new_features)
    return layer
        # we're only interested in a very few properties for
        # address points.
        label_properties = dict(
            addr_housenumber=addr_housenumber,
            kind='address')

We need to also set min_zoom=17 in that section, like:

        # we're only interested in a very few properties for
        # address points.
        label_properties = dict(
            addr_housenumber=addr_housenumber,
            min_zoom=17,
            kind='address')
@nvkelso
Copy link
Member Author

nvkelso commented Dec 15, 2021

PR is #2032.

@nvkelso
Copy link
Member Author

nvkelso commented Dec 15, 2021

Relates to tilezen/tilequeue#402.

@nvkelso nvkelso closed this as completed Apr 29, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant