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

Cull features from places layer based on grid #1999

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

Cull features from places layer based on grid #1999

nvkelso opened this issue Nov 17, 2021 · 5 comments
Assignees
Milestone

Comments

@nvkelso
Copy link
Member

nvkelso commented Nov 17, 2021

  • What did you see? There are a ton of locality points in the places layer starting at zoom 8 when they come in from OSM until around zoom 13. We source those from OSM and they have kind_detail values (eg city, town, village) which we map to min_zoom, and most have population values. But there are sometimes hundreds when just a handful can end up being labeled. We can't select by population ranked via zoom because that would leave the more rural areas of the map looking empty. So instead we need to cull features based on a grid that roughly matches how many features we could actually label in a given tile.
  • What did you expect to see? A smaller number of features based on visual layout of what can be labeled. At zoom 8 this might be ~12 features total (for visual layout reasons not just tile size reasons), then zoom 9 to 24 features, zoom 10+ to 36 features? And by zoom 13 no more culling? Maybe this is accomplished with different grid cell sizes at different zooms, too?
  • What map location are you having problems with? Tile 8/227/100 in 256px coordinates
  • Screenshot? This tile from OSM.org shows Tokyo, which has tons of locality points at that zoom.
    image

That same area via Overpass Turbo:

image

Helpful queries:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“place=town and population=*”
*/
[out:json][timeout:250];
// gather results
(
  // query part for: “place=town and population=*”
  node["place"="city"]({{bbox}});
  way["place"="city"]({{bbox}});
  relation["place"="city"]({{bbox}});
  node["place"="town"]({{bbox}});
  way["place"="town"]({{bbox}});
  relation["place"="town"]({{bbox}});
);
// print results
out body;
>;
out skel qt;



/*
This has been generated by the overpass-turbo wizard.
The original search was:
“place=town and population=*”
[out:json][timeout:250];
// gather results
(
  // query part for: “place=town and population=*”
  node["place"="city"]["population"](if:t["population"]<5000)({{bbox}});
  way["place"="city"]["population"](if:t["population"]<5000)({{bbox}});
  relation["place"="city"]["population"](if:t["population"]<5000)({{bbox}});
  node["place"="town"]["population"](if:t["population"]<5000)({{bbox}});
  way["place"="town"]["population"](if:t["population"]<5000)({{bbox}});
  relation["place"="town"]["population"](if:t["population"]<5000)({{bbox}});
);
// print results
out body;
>;
out skel qt;
*/
@nvkelso nvkelso added this to the v1.9.0 milestone Nov 17, 2021
@nvkelso
Copy link
Member Author

nvkelso commented Nov 17, 2021

This can be implemented as a post processing step, similar to what we do here to "keep_n_features" station from the pois layer:

  • vector-datasource/queries.yaml

    Lines 1415 to 1422 in 15a8fb3

    # only keep all stations below z12, then cut it down to the top few.
    - fn: vectordatasource.transform.keep_n_features
    params:
    source_layer: transit
    start_zoom: 9
    end_zoom: 12
    items_matching: { kind: station }
    max_items: 20

That function is implemented here:

I recommend duplicating that function and adding grid logic to it, with the grid spacing configurable. If it goes well we could later migrate the existing "keep_n_features" transfoms in queries.yaml to the new functions.

@nvkelso
Copy link
Member Author

nvkelso commented Nov 17, 2021

This zoom 7/113/50 parent tile of the example above at 512 pixel size has 724 places features, of which all but 8 are locality points.

50.mvt.zip

It should only have a few dozen features total.

image

@nvkelso
Copy link
Member Author

nvkelso commented Nov 17, 2021

GeoJSON from Overpass for approximately the same area to use for tests (most of those properties don't need to be kept):

@nvkelso
Copy link
Member Author

nvkelso commented Dec 15, 2021

Closed via #2001.

@nvkelso nvkelso closed this as completed Dec 15, 2021
@nvkelso
Copy link
Member Author

nvkelso commented Jan 4, 2022

Followup in #2040.

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

2 participants