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

Tiers for landuse #980

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ _TIP: Some `landuse` features only exist as point features in OpenStreetMap. Fin

* `protect_class`: Common values include `1`, `2`, `3`, `4`, `5`, `6`. See [OSM wiki](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area#Protect_classes_for_various_countries) for more information.
* `operator`: e.g. `United States National Park Service`, `United States Forest Service`, `National Parks & Wildlife Service NSW`.
* `scalerank`: A positive integer zoom level, usually in the range 0 to 16. If this property is set on a feature at a particular zoom then it indicates that this feature is an appropriate size to display at this zoom. Features without this property set may be too small, or missing "importance raising" properties.
* `tier`: An integer between 1 and 6, with 1 being "more important" and 6 being "less important".

#### Landuse kind values:

Expand Down
26 changes: 26 additions & 0 deletions integration-test/473-landuse-scalerank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# http://www.openstreetmap.org/way/167274589
# area 300363008
assert_has_feature(
16, 10818, 21900, 'landuse',
{ 'kind': 'national_park', 'id': 167274589, 'tier': 1,
'scalerank': 3 })


# http://www.openstreetmap.org/relation/921675
# area 30089300
assert_has_feature(
16, 14579, 29651, 'landuse',
{ 'kind': 'national_park', 'id': -921675, 'tier': 1,
'scalerank': 8 })
assert_has_feature(
7, 28, 57, 'landuse',
{ 'kind': 'national_park', 'id': -921675,
'tier': type(None), 'scalerank': type(None) })

# this is USFS, so demoted to scalerank 2 :-(
# http://www.openstreetmap.org/way/34416231
# area 86685400
assert_has_feature(
16, 18270, 25157, 'landuse',
{ 'kind': 'national_park', 'id': 34416231,
'tier': 2, 'scalerank': 8 })
22 changes: 0 additions & 22 deletions queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ post_process:
path: spreadsheets/sort_key/landuse.csv
params:
source_layer: landuse
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -214,7 +213,6 @@ post_process:
path: spreadsheets/sort_key/roads.csv
params:
source_layer: roads
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -223,7 +221,6 @@ post_process:
path: spreadsheets/sort_key/earth.csv
params:
source_layer: earth
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -232,7 +229,6 @@ post_process:
path: spreadsheets/sort_key/boundaries.csv
params:
source_layer: boundaries
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -241,7 +237,6 @@ post_process:
path: spreadsheets/sort_key/buildings.csv
params:
source_layer: buildings
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -250,7 +245,6 @@ post_process:
path: spreadsheets/sort_key/transit.csv
params:
source_layer: transit
target_value_type: int
# this needs to run before the water sort_key csv matcher
- fn: vectordatasource.transform.exterior_boundaries
params:
Expand All @@ -273,7 +267,6 @@ post_process:
path: spreadsheets/sort_key/water.csv
params:
source_layer: water
target_value_type: int

# assign `scalerank` to features
- fn: vectordatasource.transform.csv_match_properties
Expand All @@ -284,7 +277,6 @@ post_process:
path: spreadsheets/scalerank/water.csv
params:
source_layer: water
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -293,7 +285,6 @@ post_process:
path: spreadsheets/scalerank/earth.csv
params:
source_layer: earth
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -302,7 +293,6 @@ post_process:
path: spreadsheets/scalerank/places.csv
params:
source_layer: places
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -311,7 +301,6 @@ post_process:
path: spreadsheets/scalerank/landuse.csv
params:
source_layer: landuse
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -320,7 +309,6 @@ post_process:
path: spreadsheets/scalerank/roads.csv
params:
source_layer: roads
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -329,7 +317,6 @@ post_process:
path: spreadsheets/scalerank/buildings.csv
params:
source_layer: buildings
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -338,7 +325,6 @@ post_process:
path: spreadsheets/scalerank/pois.csv
params:
source_layer: pois
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -347,7 +333,6 @@ post_process:
path: spreadsheets/scalerank/boundaries.csv
params:
source_layer: boundaries
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -356,7 +341,6 @@ post_process:
path: spreadsheets/scalerank/transit.csv
params:
source_layer: transit
target_value_type: int

# add minimum pixel thresholds per layer
# this should run after all the `scalerank`s have been assigned to features
Expand All @@ -370,7 +354,6 @@ post_process:
path: spreadsheets/mz_min_pixels/water.csv
params:
source_layer: water
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -379,7 +362,6 @@ post_process:
path: spreadsheets/mz_min_pixels/earth.csv
params:
source_layer: earth
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -388,7 +370,6 @@ post_process:
path: spreadsheets/mz_min_pixels/landuse.csv
params:
source_layer: landuse
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -397,7 +378,6 @@ post_process:
path: spreadsheets/mz_min_pixels/buildings.csv
params:
source_layer: buildings
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -406,7 +386,6 @@ post_process:
path: spreadsheets/mz_min_pixels/boundaries.csv
params:
source_layer: boundaries
target_value_type: int
- fn: vectordatasource.transform.csv_match_properties
resources:
matcher:
Expand All @@ -415,7 +394,6 @@ post_process:
path: spreadsheets/mz_min_pixels/transit.csv
params:
source_layer: transit
target_value_type: int

# drop all polygonal features that don't meet the minimum area
# threshold. this depends on the mz_min_pixels property to be set on
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/boundaries.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/buildings.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/earth.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/landuse.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/transit.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/mz_min_pixels/water.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalerank::int,mz_min_pixels
scalerank::int,output:mz_min_pixels::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/boundaries.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/buildings.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
area::int,height::float,volume::int,landuse_kind,scalerank
area::int,height::float,volume::int,landuse_kind,output:scalerank::int
>=100000,*,*,*,1
*,>=250,*,*,1
*,*,>=300000,*,1
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/earth.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
77 changes: 76 additions & 1 deletion spreadsheets/scalerank/landuse.csv
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
kind,scalerank
kind,operator,zoom::int,area::int,output:tier::int,output:scalerank::int
national_park;battlefield,!United States Forest Service,>=3,>=300000000,1,3
national_park;battlefield,!United States Forest Service,>=4,>=300000000,1,4
national_park;battlefield,!United States Forest Service,>=5,>=150000000,1,5
national_park;battlefield,!United States Forest Service,>=6,>=150000000,1,6
national_park;battlefield,!United States Forest Service,>=7,>=100000000,1,7
national_park;battlefield,!United States Forest Service,>=8,>=10000000,1,8
national_park;battlefield,!United States Forest Service,>=9,>=5000000,1,9
national_park;battlefield,!United States Forest Service,>=10,>=1000000,1,10
national_park;battlefield,!United States Forest Service,>=11,>=500000,1,11
national_park;battlefield,!United States Forest Service,>=12,>=500000,1,12
national_park;battlefield,!United States Forest Service,>=13,>=100000,1,13
national_park;battlefield,!United States Forest Service,>=14,>=50000,1,14
national_park;battlefield,!United States Forest Service,>=15,>=2000,1,15
national_park;battlefield,!United States Forest Service,>=16,+,1,16
park;national_park,!United States National Park Service,>=4,>=1000000000,2,4
park;national_park,!United States National Park Service,>=5,>=1000000000,2,5
park;national_park,!United States National Park Service,>=6,>=150000000,2,6
park;national_park,!United States National Park Service,>=7,>=100000000,2,7
park;national_park,!United States National Park Service,>=8,>=10000000,2,8
park;national_park,!United States National Park Service,>=9,>=5000000,2,9
park;national_park,!United States National Park Service,>=10,>=1000000,2,10
park;national_park,!United States National Park Service,>=11,>=500000,2,11
park;national_park,!United States National Park Service,>=12,>=250000,2,12
park;national_park,!United States National Park Service,>=13,>=100000,2,13
park;national_park,!United States National Park Service,>=14,>=50000,2,14
park;national_park,!United States National Park Service,>=15,>=2000,2,15
park;national_park,!United States National Park Service,>=16,+,2,16
forest;wood;natural_forest;natural_wood,United States Forest Service,>=6,>=150000000,2,6
forest;wood;natural_forest;natural_wood,United States Forest Service,>=7,>=100000000,2,7
forest;wood;natural_forest;natural_wood,United States Forest Service,>=8,>=10000000,2,8
forest;wood;natural_forest;natural_wood,United States Forest Service,>=9,>=5000000,2,9
conservation;protected_area;nature_reserve;urban;rural;residential,,>=4,>=1000000000,2,4
Copy link
Member

Choose a reason for hiding this comment

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

Paired with https://github.com/tilezen/vector-datasource/pull/980/files#r76012452, to make this work better outside of United States the filter needs to be expanded to include kinds of national_park and NOT several protected_class values:

            conservation:
                filter:
                    all:
                        - $zoom: { min: 4 }
                        - kind: [conservation, protected_area, nature_reserve, national_park]
                        - not: { protect_class: ['2','3','5'] }

Copy link
Member

Choose a reason for hiding this comment

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

(Most national US National Forests draw using protect_class of 6, so that still needs to come thru, but really any value not 2,3,5 needs to come thru so other things like Wilderness Areas can come thru with values like 1,1a,1b.)

conservation;protected_area;nature_reserve;urban;rural;residential,,>=5,>=1000000000,2,5
conservation;protected_area;nature_reserve;urban;rural;residential,,>=6,>=150000000,2,6
conservation;protected_area;nature_reserve;urban;rural;residential,,>=7,>=100000000,2,7
conservation;protected_area;nature_reserve;urban;rural;residential,,>=8,>=10000000,2,8
conservation;protected_area;nature_reserve;urban;rural;residential,,>=9,>=5000000,2,9
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=10,>=1000000,2,10
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=11,>=500000,2,11
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=12,>=250000,2,12
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=13,>=100000,2,13
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=14,>=50000,2,14
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=15,>=2000,2,15
conservation;protected_area;nature_reserve;urban;rural;residential;forest;wood;natural_forest;natural_wood;farm;farmland,,>=16,+,2,16
aerodrome;military;university;college,,>=8,>=10000000,3,8
aerodrome;military;university;college,,>=9,>=5000000,3,9
aerodrome;military;university;college,,>=10,>=1000000,3,10
aerodrome;military;university;college,,>=11,>=500000,3,11
aerodrome;military;university;college,,>=12,>=500000,3,12
aerodrome;military;university;college,,>=13,>=100000,3,13
aerodrome;military;university;college,,>=14,>=50000,3,14
aerodrome;military;university;college,,>=15,>=2000,3,15
aerodrome;military;university;college,,>=16,+,3,16
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=10,>=1000000,4,10
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=11,>=500000,4,11
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=12,>=500000,4,12
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=13,>=100000,4,13
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=14,>=50000,4,14
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=15,>=2000,4,15
"cemetery;commercial;golf_course;hospital;industrial;plant;generator;substation;railway;sports_centre;recreation_ground;retail;stadium;zoo;wildlife_park;winter_sports;pier;wastewater_plant,works;bridge;tower;breakwater;water_works;groyne;dike;cutline",,>=16,+,4,16
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=10,>=1000000,5,10
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=11,>=400000,5,11
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=12,>=200000,5,12
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=13,>=50000,5,13
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=14,>=20000,5,14
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=15,>=2000,5,15
theme_park;resort;aquarium;winery;maze;beach;glacier,,>=16,+,5,16
garden;allotments;pedestrian;common;pitch;place_of_worship;playground;school;attraction;artwork;wilderness_hut;hanami;tree_row;hedge,,>=12,>=500000,6,12
garden;allotments;pedestrian;common;pitch;place_of_worship;playground;school;attraction;artwork;wilderness_hut;hanami;tree_row;hedge,,>=13,>=100000,6,13
garden;allotments;pedestrian;common;pitch;place_of_worship;playground;school;attraction;artwork;wilderness_hut;hanami;tree_row;hedge,,>=14,>=50000,6,14
garden;allotments;pedestrian;common;pitch;place_of_worship;playground;school;attraction;artwork;wilderness_hut;hanami;tree_row;hedge,,>=15,>=2000,6,15
garden;allotments;pedestrian;common;pitch;place_of_worship;playground;school;attraction;artwork;wilderness_hut;hanami;tree_row;hedge,,>=16,+,6,16
parking,,>=14,>=50000,6,14
Copy link
Member

Choose a reason for hiding this comment

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

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 filter one level up says min: 50000, so the 10000 limit is not enforced in practice.

parking,,>=15,>=5000,6,15
parking,,>=16,+,6,16
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/places.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/pois.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/roads.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/transit.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/scalerank/water.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kind,scalerank
kind,output:scalerank::int
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/boundaries.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kind,sort_key
kind,output:sort_key::int
municipality,252
county,254
Admin-1 boundary,256
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/buildings.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kind,sort_key
kind,output:sort_key::int
*,475
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/earth.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kind,sort_key
kind,output:sort_key::int
cliff,227
arete,228
earth,10
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/landuse.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kind,geometrytype,sort_key
kind,geometrytype,output:sort_key::int
fence,*,269
snow_fence,*,268
retaining_wall,*,267
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/roads.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zoom::int,layer::int,kind,kind_detail,service,is_bridge,is_tunnel,sort_key
zoom::int,layer::int,kind,kind_detail,service,is_bridge,is_tunnel,output:sort_key::int
>=15,7,*,*,*,*,*,447
>=15,6,*,*,*,*,*,447
>=15,5,*,*,*,*,*,447
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/transit.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kind,sort_key
kind,output:sort_key::int
light_rail,418
tram,417
funicular,416
Expand Down
2 changes: 1 addition & 1 deletion spreadsheets/sort_key/water.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kind,boundary,sort_key
kind,boundary,output:sort_key::int
river,,201
canal,,201
stream,,201
Expand Down
Loading