diff --git a/integration-test.py b/integration-test.py index 3e0b5cd72..3637baede 100644 --- a/integration-test.py +++ b/integration-test.py @@ -103,6 +103,9 @@ def match_properties(actual, expected): if not exp_v(v): return False + elif isinstance(exp_v, unicode): + return v == exp_v.encode('utf-8') + elif v != exp_v: return False @@ -130,6 +133,8 @@ def match_distance(actual, expected): # normalise unicode values if isinstance(v, unicode): v = v.encode('utf-8') + if isinstance(exp_v, unicode): + exp_v = exp_v.encode('utf-8') if exp_v is not None: if isinstance(exp_v, set): diff --git a/integration-test/1016-missing-localized-names.py b/integration-test/1016-missing-localized-names.py new file mode 100644 index 000000000..4a067b666 --- /dev/null +++ b/integration-test/1016-missing-localized-names.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +# New Jersey - New York state boundary +# http://www.openstreetmap.org/relation/224951 (New Jersey) +# http://www.openstreetmap.org/relation/61320 (New York state) +assert_has_feature( + 15, 9643, 12327, "boundaries", + {"kind": "region", "name": "New Jersey - New York", + "name:right": "New York", "name:left": "New Jersey", + "name:right:es": "Nueva York", "name:left:es": "Nueva Jersey", + "name:right:lv":u"Ņujorka", "name:left:lv":u"Ņūdžersija" + }) diff --git a/queries/boundaries.jinja2 b/queries/boundaries.jinja2 index 36b01d768..dc11f43ff 100644 --- a/queries/boundaries.jinja2 +++ b/queries/boundaries.jinja2 @@ -1,5 +1,6 @@ {% macro ne_boundary_cols() %} gid AS __id__, + 'naturalearthdata.com' AS source, {% filter geometry %}the_geom{% endfilter %} AS __geometry__, mz_calculate_json_boundaries(t.*) AS mz_properties {% endmacro %} @@ -60,6 +61,7 @@ WHERE SELECT tags->'name' AS name, + 'openstreetmap.org' AS source, NULL AS maritime_boundary, mz_calculate_json_boundaries(planet_osm_polygon.*) AS mz_properties, -- note that we force the RHR, which makes outers clockwise, @@ -84,6 +86,7 @@ UNION ALL SELECT NULL AS name, + 'openstreetmap.org' AS source, true AS maritime_boundary, '{"kind": "maritime"}'::json as mz_properties, {% filter geometry %}{{ bounds['polygon']|bbox_intersection('the_geom',3857) }}{% endfilter %} AS __geometry__, @@ -99,6 +102,7 @@ UNION ALL SELECT tags->'name' AS name, + 'openstreetmap.org' AS source, NULL AS maritime_boundary, mz_calculate_json_boundaries(planet_osm_line.*) AS mz_properties, {% filter geometry %}way{% endfilter %} AS __geometry__, diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 12a522304..68e82870f 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -1752,7 +1752,11 @@ def admin_boundaries(ctx): maritime_features = list() new_features = list() - for shape, props, fid in layer['features']: + # Sorting here so that we have consistent ordering of left/right side + # on boundaries. + sorted_layer = sorted(layer['features'], key=lambda f: f[1]['id']) + + for shape, props, fid in sorted_layer: dims = _geom_dimensions(shape) kind = props.get('kind') maritime_boundary = props.get('maritime_boundary')