diff --git a/integration-test/1926-landuse-crop-kind-detail.py b/integration-test/1926-landuse-crop-kind-detail.py new file mode 100644 index 000000000..f7edd0fc4 --- /dev/null +++ b/integration-test/1926-landuse-crop-kind-detail.py @@ -0,0 +1,47 @@ +# -*- encoding: utf-8 -*- +from . import FixtureTest + + +class FarmlandCropTest(FixtureTest): + + def test_crop(self): + import dsl + + z, x, y = (16, 10631, 25149) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/145660534 + dsl.way(145660534, dsl.tile_box(z, x, y), { + 'landuse': u'farmland', + 'crop': u'rice', + 'source': u'openstreetmap.org', + }), + ) + + self.assert_has_feature( + z, x, y, 'landuse', { + 'id': 145660534, + 'kind': 'farmland', + 'kind_detail': 'rice', + }) + + def test_crop_remap_sugarcane(self): + import dsl + + z, x, y = (16, 10631, 25149) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/145660534 + dsl.way(145660534, dsl.tile_box(z, x, y), { + 'landuse': u'farmland', + 'crop': u'cana-de-a\u00e7\u00facar', + 'source': u'openstreetmap.org', + }), + ) + + self.assert_has_feature( + z, x, y, 'landuse', { + 'id': 145660534, + 'kind': 'farmland', + 'kind_detail': 'sugarcane', + }) diff --git a/queries.yaml b/queries.yaml index 49b17d5f5..6d37c9359 100644 --- a/queries.yaml +++ b/queries.yaml @@ -1000,7 +1000,7 @@ post_process: source_layer: landuse start_zoom: 4 end_zoom: 13 - properties: [name, sport, religion, surface] + properties: [name, sport, religion, surface, crop] where: >- pixel_area > area geom_types: [Polygon, MultiPolygon] diff --git a/vectordatasource/meta/python.py b/vectordatasource/meta/python.py index af2ccaad0..e5ee393af 100644 --- a/vectordatasource/meta/python.py +++ b/vectordatasource/meta/python.py @@ -171,6 +171,8 @@ def parse_mul(ast_state, orig): def ast_value(ast_state, val): if isinstance(val, str): return ast.Str(val) + elif isinstance(val, unicode): + return ast.Str(val.encode('utf8')) elif isinstance(val, dict): if val.keys() == ['col']: return ast_column(ast_state, val['col']) diff --git a/yaml/landuse.yaml b/yaml/landuse.yaml index 7ad5db573..d683816a9 100644 --- a/yaml/landuse.yaml +++ b/yaml/landuse.yaml @@ -32,7 +32,51 @@ global: args: - {col: building} - {col: "building:part"} - + - &crop_kind_detail + kind_detail: + case: + - when: + crop: + - rice + - grape + - grass + - corn + - cereal + - tea + - hop + - sugarcane + - market_gardening + - field_cropland + - wheat + - soy + - forage + - barley + - vegetable + - rape + - native_pasture + - fast_growing_wood + - coffee + - lavender + - beet + - cotton + - tobacco + - sugar_beet + - sunflower + - hay + - betel + then: {col: crop} + - when: + crop: 'cana-de-açúcar' + then: sugarcane + - when: + crop: 'vegetables' + then: vegetable + - when: + crop: 'cana-de-açucar' + then: sugarcane + - when: + crop: 'maize' + then: corn - &tier1_min_zoom lookup: key: { col: way_area } @@ -567,6 +611,7 @@ filters: <<: *output_properties kind: farmland tier: 2 + <<: *crop_kind_detail ############################################################ # NO TIER