From cfbbf7c1e6535fe20c9b23958621c3068d2b886e Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Mon, 30 Sep 2019 11:48:15 +0200 Subject: [PATCH 01/15] Add crop to landuse --- yaml/landuse.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/yaml/landuse.yaml b/yaml/landuse.yaml index 6c2ad2586..e7ba619df 100644 --- a/yaml/landuse.yaml +++ b/yaml/landuse.yaml @@ -21,6 +21,7 @@ global: zoo: {col: zoo} barrier: {col: barrier} fence_type: {col: fence_type} + crop: {col: crop} min_zoom: case: - when: { meta.source: ne } From a8bae6f71368484990ce52252d1570f40848a42f Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Wed, 9 Oct 2019 13:10:55 +0200 Subject: [PATCH 02/15] Add crop to vectordatasource.transform.drop_properties --- queries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.yaml b/queries.yaml index f25324d9c..23aa850f8 100644 --- a/queries.yaml +++ b/queries.yaml @@ -913,7 +913,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] From ec847b5d526f47ff4f8d8dddac2fc5b31a71b856 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Wed, 9 Oct 2019 13:25:42 +0200 Subject: [PATCH 03/15] Remap crop and add it as kind_detail into landuse farmland --- yaml/landuse.yaml | 48 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/yaml/landuse.yaml b/yaml/landuse.yaml index e7ba619df..47fbf3fa9 100644 --- a/yaml/landuse.yaml +++ b/yaml/landuse.yaml @@ -21,7 +21,6 @@ global: zoo: {col: zoo} barrier: {col: barrier} fence_type: {col: fence_type} - crop: {col: crop} min_zoom: case: - when: { meta.source: ne } @@ -33,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 } @@ -576,6 +619,7 @@ filters: <<: *output_properties kind: farmland tier: 2 + <<: *crop_kind_detail ############################################################ # NO TIER From 6e36b3c45a86b492b6d35d17f2ca2bf010fcfaa0 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Wed, 9 Oct 2019 13:35:36 +0200 Subject: [PATCH 04/15] Add test for crop --- .../1588-quay-wharf-other-sort-rank.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 87cee4124..bdb4c230a 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -2,6 +2,50 @@ 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', + 'crop': '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çúcar', + 'source': u'openstreetmap.org', + }), + ) + + self.assert_has_feature( + z, x, y, 'landuse', { + 'id': 145660534, + 'kind': 'farmland', + 'crop': 'sugarcane', + }) + class LanduseSortRankTest(FixtureTest): def _check(self, tags, expected_kind, expected_sort_rank): From 43da01ebd3c8823bc8f918453439aaaac136b0c4 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Wed, 9 Oct 2019 23:15:54 +0200 Subject: [PATCH 05/15] Try encode to utf-8 test value --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index bdb4c230a..13d3cfeef 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # https://www.openstreetmap.org/way/145660534 dsl.way(145660534, dsl.tile_box(z, x, y), { 'landuse': u'farmland', - 'crop': u'cana-de-açúcar', + 'crop': u'cana-de-açúcar'.encode('utf-8'), 'source': u'openstreetmap.org', }), ) From e7eafa3d4163a6316fedbe46c334a57c51323bfc Mon Sep 17 00:00:00 2001 From: Tomas Date: Thu, 17 Oct 2019 22:56:07 +0200 Subject: [PATCH 06/15] Change encode in test to decode --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 13d3cfeef..76f94ae95 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # https://www.openstreetmap.org/way/145660534 dsl.way(145660534, dsl.tile_box(z, x, y), { 'landuse': u'farmland', - 'crop': u'cana-de-açúcar'.encode('utf-8'), + 'crop': u'cana-de-açúcar'.decode('utf-8'), 'source': u'openstreetmap.org', }), ) From eec0c32425dab7b531d76132b8249529d91d19fa Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Thu, 24 Oct 2019 22:54:39 +0200 Subject: [PATCH 07/15] Escape diacritic characters --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 76f94ae95..d63f43495 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # https://www.openstreetmap.org/way/145660534 dsl.way(145660534, dsl.tile_box(z, x, y), { 'landuse': u'farmland', - 'crop': u'cana-de-açúcar'.decode('utf-8'), + 'crop': u'cana-de-a\xe7\xfacar', 'source': u'openstreetmap.org', }), ) From 124f8b421ed752d7c89608643220c4b6e1729fa6 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Thu, 24 Oct 2019 23:55:05 +0200 Subject: [PATCH 08/15] Another try for correct unicode encoding --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index d63f43495..eade900bd 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # https://www.openstreetmap.org/way/145660534 dsl.way(145660534, dsl.tile_box(z, x, y), { 'landuse': u'farmland', - 'crop': u'cana-de-a\xe7\xfacar', + 'crop': u'cana-de-a\u00e7\u00facar', 'source': u'openstreetmap.org', }), ) From d7c9aca63b4a625e1e764f6885f857791d287275 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Fri, 25 Oct 2019 09:13:04 +0200 Subject: [PATCH 09/15] Encode as utf-8 --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index eade900bd..22d00a1ab 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # 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', + 'crop': u'cana-de-a\u00e7\u00facar'.encode('utf-8'), 'source': u'openstreetmap.org', }), ) From bda19f281d19807f335b238595439465ce46e726 Mon Sep 17 00:00:00 2001 From: Vectura Games Maps Date: Fri, 25 Oct 2019 11:51:55 +0200 Subject: [PATCH 10/15] Decode as utf-8 --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 22d00a1ab..913c9e39a 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # 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'.encode('utf-8'), + 'crop': u'cana-de-a\u00e7\u00facar'.decode('utf-8'), 'source': u'openstreetmap.org', }), ) From 01e357d7a5d9f85255db254f3e9e91ebfcb5ff81 Mon Sep 17 00:00:00 2001 From: Ian Dees Date: Fri, 25 Oct 2019 07:20:29 -0500 Subject: [PATCH 11/15] Leave it as unicode here. --- integration-test/1588-quay-wharf-other-sort-rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 913c9e39a..eade900bd 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -34,7 +34,7 @@ def test_crop_remap_sugarcane(self): # 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'.decode('utf-8'), + 'crop': u'cana-de-a\u00e7\u00facar', 'source': u'openstreetmap.org', }), ) From 9e95aa33cb9b6cd0969287c021bd918c78e824c4 Mon Sep 17 00:00:00 2001 From: Ian Dees Date: Fri, 25 Oct 2019 07:21:59 -0500 Subject: [PATCH 12/15] Encode unicode objects into utf8 str's. --- vectordatasource/meta/python.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vectordatasource/meta/python.py b/vectordatasource/meta/python.py index e65a7d383..d43b3b77f 100644 --- a/vectordatasource/meta/python.py +++ b/vectordatasource/meta/python.py @@ -169,6 +169,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']) From d0ec9619df8c06b5827e24737aa0aa29885812db Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Fri, 25 Oct 2019 09:44:27 -0700 Subject: [PATCH 13/15] Appease flake gods Also, this should be in a new test file, not this test file --- integration-test/1588-quay-wharf-other-sort-rank.py | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index eade900bd..68f3d122c 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -46,6 +46,7 @@ def test_crop_remap_sugarcane(self): 'crop': 'sugarcane', }) + class LanduseSortRankTest(FixtureTest): def _check(self, tags, expected_kind, expected_sort_rank): From fd9b39cf7818efcd0ba45faecea433c5cc468321 Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Fri, 25 Oct 2019 10:30:11 -0700 Subject: [PATCH 14/15] Switch test to kind_detail from crop --- integration-test/1588-quay-wharf-other-sort-rank.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index 68f3d122c..e809835ef 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -22,7 +22,7 @@ def test_crop(self): z, x, y, 'landuse', { 'id': 145660534, 'kind': 'farmland', - 'crop': 'rice', + 'kind_detail': 'rice', }) def test_crop_remap_sugarcane(self): @@ -43,7 +43,7 @@ def test_crop_remap_sugarcane(self): z, x, y, 'landuse', { 'id': 145660534, 'kind': 'farmland', - 'crop': 'sugarcane', + 'kind_detail': 'sugarcane', }) From 5efadecfa138005e57a694ced93fe8a7ca779676 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Sat, 26 Oct 2019 12:58:44 +0200 Subject: [PATCH 15/15] Move crop kind detail test to a separate file --- .../1588-quay-wharf-other-sort-rank.py | 45 ------------------ .../1926-landuse-crop-kind-detail.py | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 integration-test/1926-landuse-crop-kind-detail.py diff --git a/integration-test/1588-quay-wharf-other-sort-rank.py b/integration-test/1588-quay-wharf-other-sort-rank.py index e809835ef..87cee4124 100644 --- a/integration-test/1588-quay-wharf-other-sort-rank.py +++ b/integration-test/1588-quay-wharf-other-sort-rank.py @@ -2,51 +2,6 @@ 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', - }) - - class LanduseSortRankTest(FixtureTest): def _check(self, tags, expected_kind, expected_sort_rank): 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', + })