Skip to content

Commit

Permalink
Allow landuse scalerank CSV to also output tier.
Browse files Browse the repository at this point in the history
CSVMatcher now uses the header key to determine if the column is an
output column - those with the prefix "output:" are used. This
allows the use of multiple outputs in the same CSV, and that is used
to output both the scalerank and tier from the landuse CSV.
  • Loading branch information
Matt Amos committed Aug 23, 2016
1 parent e2d2f73 commit 57aeb9c
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 148 deletions.
12 changes: 8 additions & 4 deletions integration-test/473-landuse-scalerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
# area 300363008
assert_has_feature(
16, 10818, 21900, 'landuse',
{ 'kind': 'national_park', 'id': 167274589, 'scalerank': 1 })
{ '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, 'scalerank': 1 })
{ 'kind': 'national_park', 'id': -921675, 'tier': 1,
'scalerank': 8 })
assert_has_feature(
7, 28, 57, 'landuse',
{ 'kind': 'national_park', 'id': -921675, 'scalerank': type(None) })
{ '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, 'scalerank': 2 })
{ '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
Loading

0 comments on commit 57aeb9c

Please sign in to comment.