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

Tile size: water only changes #2010

Merged
merged 10 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions integration-test/1730-further-water-layer-name-dropping.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,11 @@ def test_label_lake_athabasca_z5(self):
}),
)

# we should get a label placement point, and its zoom should have been
# adjusted. we should also have all the names at this point.
# we should also have all the names at this point.
self.assert_has_feature(
z, x, y, 'water', {
'kind': 'lake',
'label_placement': True,
'min_zoom': 5,
'min_zoom': 2, # min_zoom changed at https://github.com/tilezen/vector-datasource/pull/2010/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the 'label_placement': True point should have names at this early zoom, and the min_zoom on that should probably be a different value besides 2 (like 7)?

'name': str,
'name:de': str,
})
6 changes: 3 additions & 3 deletions integration-test/1838-too-many-bays.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def _bay(osm_id, area, name):
)

with self.features_in_tile_layer(z, x, y, 'water') as features:
# should only have top 10 features
self.assertEqual(10, len(features))
# should only have top 2 features
self.assertEqual(2, len(features))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At zoom 8 our area threshold for labels is 500,000,000 (was 200,000,000) and for polygons it's still 20000000.

Under the earlier system 5 meet the area threshold, but after only 2 do. So the changes here make sense to me.


# check that they're in order
ranks = [f['properties']['kind_tile_rank'] for f in features]
self.assertEqual(range(1, 11), ranks)
self.assertEqual(range(1, 3), ranks)
87 changes: 73 additions & 14 deletions queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,29 @@ post_process:
where: >-
kind == 'lake'

# remove names per kind for a given zoom
# before generating any label placements
- fn: vectordatasource.transform.drop_properties
params:
source_layer: water
start_zoom: 0
end_zoom: 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclusive

# short-hand for "name" property in the list below means all name-like
# properties.
all_name_variants: true
properties:
- name
where: >-
(kind == 'sea' and zoom < 4) or
(kind == 'lake' and zoom < 5) or
(kind == 'river' and zoom < 12) or
(kind == 'canal' and zoom < 13) or
(kind == 'dam' and zoom < 14) or
(kind == 'stream' and zoom < 14) or
(kind == 'ditch' and zoom < 15) or
(kind == 'drain' and zoom < 15) or
(properties is not None and properties.get('is_tunnel') is True)
nvkelso marked this conversation as resolved.
Show resolved Hide resolved

- fn: vectordatasource.transform.handle_label_placement
params:
layers:
Expand Down Expand Up @@ -822,22 +845,58 @@ post_process:
# table.
min_zoom: >-
[min_zoom for min_zoom, area_threshold in [
(4, 40000000000),
(5, 10000000000),
(6, 5000000000),
(7, 400000000),
(8, 200000000),
(9, 100000000),
(10, 10000000),
(11, 4000000),
(12, 750000),
(13, 100000),
(14, 50000),
(15, 10000),
(16, None),
(1, 1000000000000),
(2, 500000000000),
(3, 250000000000),
(4, 120000000000),
(5, 80000000000),
(6, 40000000000),
(7, 10000000000),
(8, 500000000),
(9, 200000000),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The larger range of min_zoom remappings is working for features are in the allowlist, woot!

(10, 40000000),
(11, 8000000),
(12, 1000000),
(13, 500000),
(14, 50000),
(15, 10000),
(16, None),
] if area >= area_threshold][0]
where: >-
kind == 'lake' and label_placement
kind in ['lake','bay','water','riverbank','reservoir'] and label_placement
Copy link
Member Author

@nvkelso nvkelso Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing basin and dock label points very early still in London, and strait along the English Channel.

The full list of water kinds is:

basin, bay, canal, ditch, dock, drain, fjord, fountain, lake, playa, reef, river, riverbank, strait, stream, swimming_pool, water

But perhaps it's too brittle to have a full list (since values will come and go), when the measure should just be that we generated a label_placement for it at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps:

      where: >-
        (properties is not None and properties.get('label_placement') is True)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.


# now that we have the label points
# drop most water properties at lower zooms
# this is for lines and polygons
- fn: vectordatasource.transform.drop_properties
params:
source_layer: water
start_zoom: 8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be for low zoom tiles as well, so 8 > 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.

end_zoom: 15
properties:
- id
- area
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could add boundary and osm_relation, too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.

- layer
- wikidata_id
- kind_tile_rank
- label_placement
nvkelso marked this conversation as resolved.
Show resolved Hide resolved
where: >-
Copy link
Member Author

@nvkelso nvkelso Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also drop boundary which randomly appears when a river is also forms part of an administrative boundary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This where clause doesn't seem to work.

There's another pattern we can switch to, like:

  # no lake labels at zoom 0-3:
  # https://github.com/tilezen/vector-datasource/issues/1730
  - fn: vectordatasource.transform.drop_names
    params:
      source_layer: water
      start_zoom: 0
      end_zoom: 4
      geom_types: [Polygon, MultiPolygon]
      where: >-
        kind == 'lake'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.

geom_type in ('LineString', 'MultiLineString', 'Polygon', 'MultiPolygon')

# now that we have the label points
# drop water names at lower zooms for polys only
- fn: vectordatasource.transform.drop_properties
params:
source_layer: water
start_zoom: 8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low zoom too, so 8 > 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.

end_zoom: 15
# short-hand for "name" property in the list below means all name-like
# properties.
all_name_variants: true
properties:
- name
where: >-
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: old_name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.

geom_type in ('Polygon', 'MultiPolygon')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same where clause switch as above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 77e663c.


- fn: vectordatasource.transform.handle_label_placement
params:
Expand Down
10 changes: 8 additions & 2 deletions yaml/water.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ globals:
key: { col: way_area }
op: '>='
table:
# OSM data starts at z8, but we should include some stuff at z7 so that
# OSM data starts at z8, but we should include some stuff at earlier so
# the transition doesn't have a gap in it.
- [ 7, 160000000 ]
- [ 1, 20000000000 ]
- [ 2, 10000000000 ]
- [ 3, 5000000000 ]
- [ 4, 2000000000 ]
- [ 5, 500000000 ]
- [ 6, 200000000 ]
- [ 7, 50000000 ]
- [ 8, 20000000 ]
- [ 9, 5000000 ]
- [ 10, 1000000 ]
Expand Down