Skip to content
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

Reduce size of roads layer at zooms 10 and 11 #1998

Closed
nvkelso opened this issue Nov 17, 2021 · 2 comments
Closed

Reduce size of roads layer at zooms 10 and 11 #1998

nvkelso opened this issue Nov 17, 2021 · 2 comments

Comments

@nvkelso
Copy link
Member

nvkelso commented Nov 17, 2021

There are a lot of random (orphaned) unclassified and residential road segments included at zooms 10 and 11 in dense cities. These seem to be "bike" related.

Fix in in 5 parts.

Zoom 10 in London (256px tile size or 512px at 10/511/340 for research):

image

Zoom 11 in London

image

Zoom 12 in London

image

Zoom 10 in Paris: (256px tile size):

image

Zoom 11 in Paris

image

Zoom 12 in Paris

image

Part of this stems from #1250 and #1462, which solved for the rural unclassified case where those are actually regional connectors. But in the process too many random tiny urban roads (especially in Europe see London and Paris) were added. That min_zoom of 11 should be reverted to 12, those tests updated, and documentation changed.

Specifically:

  • min_zoom: { clamp: { min: 0, max: 11, value: { call: { func: mz_calculate_path_major_route, args: [ { col: fid }, { col: meta.relations } ] } } } }
    min_zoom: { clamp: { min: 0, max: 12, value: { call: { func: mz_calculate_path_major_route, args: [ { col: fid }, { col: meta.relations } ] } } } }

Some of the other roads are bike or walking related, where they get promoted up a zoom or two depending on what type or bicycle or walking relation (international, national, regional, and local) it's a member of, via #1172 and #1198.

This was done for Walkabout map style at Mapzen, but introduces extra features for a general purpose map. Let's relax those a single zoom, per https://github.com/tilezen/vector-datasource/blob/master/docs/SEMANTIC-VERSIONING.md#minor-version-increments to keep with MINOR version change.

The code to change is:

  • CREATE OR REPLACE FUNCTION mz_calculate_path_major_route(osm_id BIGINT, dummy INTEGER)
    RETURNS SMALLINT AS $$
    BEGIN
    RETURN (
    SELECT
    MIN(
    CASE WHEN hstore(tags)->'network' IN ('icn', 'ncn') THEN 8
    WHEN hstore(tags)->'network' IN ('iwn', 'nwn') THEN 9
    WHEN hstore(tags)->'network' IN ('rcn') THEN 10
    WHEN hstore(tags)->'network' IN ('rwn') THEN 11
    WHEN hstore(tags)->'network' IN ('lcn') THEN 11
    WHEN hstore(tags)->'network' IN ('lwn') THEN 12
    ELSE NULL
    END
    )
    AS p
    FROM planet_osm_rels
    WHERE
    parts && ARRAY[osm_id] AND
    parts[way_off+1:rel_off] && ARRAY[osm_id] AND
    mz_is_path_major_route_relation(hstore(tags))
    );
    END;
    $$ LANGUAGE plpgsql STABLE;

Specifically:

            CASE WHEN hstore(tags)->'network' IN ('icn', 'ncn') THEN 8
                 WHEN hstore(tags)->'network' IN ('iwn', 'nwn') THEN 9
                 WHEN hstore(tags)->'network' IN ('rcn') THEN 11
                 WHEN hstore(tags)->'network' IN ('rwn') THEN 11
                 WHEN hstore(tags)->'network' IN ('lcn') THEN 12
                 WHEN hstore(tags)->'network' IN ('lwn') THEN 12

Additionally we should drop more feature properties at zoom 12, too (changing 12 to 13), to allow more feature merging at zoom 11 and 12:

Finally, we should drop surface tags from minor roads and paths at early zooms:

We do a transform here:

Right after that we should dup the logic for

And apply that to minor roads and paths until zoom 14.

 # drop these "detail" tags to get better merging at zoom < 14
  - fn: vectordatasource.transform.drop_properties
    params:
      source_layer: roads
      start_zoom: 0
      end_zoom: 14
      properties:
        - surface
      where: >-
        kind == 'minor_road' or 
        (kind == 'path' and zoom < 13)

We should drop more properties from all kinds of roads, too:

Something more like:

 - fn: vectordatasource.transform.drop_properties
    params:
      source_layer: roads
      start_zoom: 0
      end_zoom: 15
      properties:
        - network
        - shield_text
        - bicycle_shield_text
        - bus_shield_text
        - walking_shield_text
        - hgv_restriction_shield_text
      where: >-
        (kind_detail == 'motorway' and zoom <  7) or
        (kind_detail == 'trunk' and zoom <  9) or
        (kind_detail == 'primary' and zoom <  11) or
        (kind_detail == 'secondary' and zoom <  12) or
        (kind_detail == 'tertiary' and zoom <  13) or
        (kind_detail == 'motorway_link' and zoom <  13) or
        (kind_detail == 'trunk_link' and zoom <  13) or
        (kind_detail == 'primary_link' and zoom <  14) or
        (kind_detail == 'secondary_link' and zoom <  14) or
        (kind_detail == 'tertiary_link' and zoom <  14) or
        (kind == 'minor_road' and zoom < 15) or
        (kind == 'path' and zoom < 14) or
        (kind == 'rail' and zoom < 15)

- fn: vectordatasource.transform.drop_properties
    params:
      source_layer: roads
      start_zoom: 0
      end_zoom: 15
      # short-hand for "name" property in the list below means all name-like
      # properties.
      all_name_variants: true
      properties:
        - name
        - ref
        - all_networks
        - all_shield_texts
        - service
        - access
        - osm_relation
      where: >-
        (kind == 'highway' and zoom <  11) or    
        (kind_detail == 'trunk' and zoom <  12) or
        (kind_detail == 'primary' and zoom <  13) or
        (kind_detail == 'secondary' and zoom <  14) or
        (kind_detail == 'tertiary' and zoom <  14) or
        (kind_detail == 'motorway_link' and zoom <  14) or
        (kind_detail == 'trunk_link' and zoom <  14) or
        (kind_detail == 'primary_link' and zoom <  15) or
        (kind_detail == 'secondary_link' and zoom <  15) or
        (kind_detail == 'tertiary_link' and zoom <  15) or
        (kind == 'minor_road' and zoom < 15) or
        (kind == 'path' and zoom < 14) or
        (kind == 'rail' and zoom < 15)

 - fn: vectordatasource.transform.drop_properties
    params:
      source_layer: roads
      start_zoom: 0
      end_zoom: 15
      properties:
        - service
        - surface
        - cycleway
        - cycleway_right
        - cycleway_left
        - walking_shield_text
        - hgv
        - operator
      where: >-
        (kind == 'highway' and zoom <  12) or
        (kind == 'major_road' and zoom <  13) or
        (kind == 'minor_road' and zoom < 15) or
        (kind == 'path' and zoom < 14) or
        (kind == 'rail' and zoom < 15)
@nvkelso
Copy link
Member Author

nvkelso commented Nov 29, 2021

This will require changes to the original Mapzen house styes, like tangrams/bubble-wrap#279.

@nvkelso
Copy link
Member Author

nvkelso commented Dec 15, 2021

Closed via #2008.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant