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

Add crop to landuse #1926

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions integration-test/1926-landuse-crop-kind-detail.py
Original file line number Diff line number Diff line change
@@ -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',
})
2 changes: 1 addition & 1 deletion queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions vectordatasource/meta/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
47 changes: 46 additions & 1 deletion yaml/landuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -567,6 +611,7 @@ filters:
<<: *output_properties
kind: farmland
tier: 2
<<: *crop_kind_detail

############################################################
# NO TIER
Expand Down