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

Fix missing localized names on boundaries #1022

Merged
merged 10 commits into from
Sep 9, 2016
5 changes: 5 additions & 0 deletions integration-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
12 changes: 12 additions & 0 deletions integration-test/1016-missing-localized-names.py
Original file line number Diff line number Diff line change
@@ -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"
})
4 changes: 4 additions & 0 deletions queries/boundaries.jinja2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down Expand Up @@ -60,6 +61,7 @@ WHERE

SELECT
tags->'name' AS name,
'openstreetmap.org' AS source,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Please also specify Natural Earth as a source at the top of the file in the macro:

{% 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 %}

NULL AS maritime_boundary,
mz_calculate_json_boundaries(planet_osm_polygon.*) AS mz_properties,
-- note that we force the RHR, which makes outers clockwise,
Expand All @@ -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__,
Expand All @@ -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__,
Expand Down
6 changes: 5 additions & 1 deletion vectordatasource/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down