Skip to content

Commit cb0caeb

Browse files
authored
Fix NE country names (#2101)
Some country names in Natural Earth are undesirable so this changes them back to their OSM names which are generally shorter. Most of these changes can be deprecated once NE is updated. There was also an issue with the overwriting of chinese names with NE as the column name was incorrect that has been fixed and added to the test. This also addresses some broken country related tests that needed fixing
1 parent 4caaedc commit cb0caeb

12 files changed

+168
-45
lines changed

data/apply-ne_country_label_recasting.sql

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,119 @@ update ne_10m_admin_0_countries_tlc set featurecla = 'Admin-0 dependency' where
4242

4343
-- Fix Saint Helena wikidata id for this build. Remove once NE is updated
4444
update ne_10m_admin_0_countries_iso set wikidataid = 'Q192184' where ne_id = 1159320733;
45+
46+
47+
-- Fixes to country labels for some languages to shorten or match local expectations
48+
49+
--Update Bahamas name
50+
update ne_10m_admin_0_countries_iso set name_ru = 'Багамы' where ne_id = 1159320415;
51+
52+
--Update Central Africa Republic name
53+
update ne_10m_admin_0_countries_iso set name_fr = 'Centrafrique' where ne_id = 1159320463;
54+
update ne_10m_admin_0_countries_iso set name_zh = '中非' where ne_id = 1159320463;
55+
update ne_10m_admin_0_countries_iso set name_zht = '中非' where ne_id = 1159320463;
56+
57+
--Update China name
58+
update ne_10m_admin_0_countries_iso set name_de = 'China' where ne_id = 1159320471;
59+
update ne_10m_admin_0_countries_iso set name_en = 'China' where ne_id = 1159320471;
60+
update ne_10m_admin_0_countries_iso set name_fr = 'Chine' where ne_id = 1159320471;
61+
update ne_10m_admin_0_countries_iso set name_ko = '중국' where ne_id = 1159320471;
62+
update ne_10m_admin_0_countries_iso set name_zh = '中国' where ne_id = 1159320471;
63+
update ne_10m_admin_0_countries_iso set name_zht = '中国' where ne_id = 1159320471;
64+
65+
--Update Cocos (Keeling) Island
66+
update ne_10m_admin_0_countries_iso set name_ar = 'جزر كوكوس (كيلينغ)' where ne_id = 1159320367;
67+
update ne_10m_admin_0_countries_iso set name_en = 'Cocos (Keeling) Islands' where ne_id = 1159320367;
68+
update ne_10m_admin_0_countries_iso set name_es = 'Islas Cocos (Keeling)' where ne_id = 1159320367;
69+
update ne_10m_admin_0_countries_iso set name_ja = 'ココス[キーリング]諸島' where ne_id = 1159320367;
70+
update ne_10m_admin_0_countries_iso set name_ru = 'Кокосовые (Килинг) острова' where ne_id = 1159320367;
71+
72+
--Update Cyprus name
73+
update ne_10m_admin_0_countries_iso set name_de = 'Zypern' where ne_id = 1159320533;
74+
75+
--Update Czechia name
76+
update ne_10m_admin_0_countries_iso set name_en = 'Czechia' where ne_id = 1159320535;
77+
update ne_10m_admin_0_countries_iso set name_es = 'Chequia' where ne_id = 1159320535;
78+
update ne_10m_admin_0_countries_iso set name_zht = '捷克' where ne_id = 1159320535;
79+
80+
--Update Dominica name
81+
update ne_10m_admin_0_countries_iso set name_ko = '도미니카' where ne_id = 1159320543;
82+
83+
--Update Falklands Islands name
84+
update ne_10m_admin_0_countries_iso set name_en = 'Falkland Islands (Islas Malvinas)' where ne_id = 1159320711;
85+
update ne_10m_admin_0_countries_iso set name_fr = 'Îles Malouines (Îles Falkland)' where ne_id = 1159320711;
86+
update ne_10m_admin_0_countries_iso set name_ja = 'フォークランド諸島 (マルビナス諸島)' where ne_id = 1159320711;
87+
update ne_10m_admin_0_countries_iso set name_ko = '포클랜드 제도 (말비나스 군도)' where ne_id = 1159320711;
88+
89+
--Update Israel name
90+
update ne_10m_admin_0_countries_iso set name_ar = 'فلسطين' where ne_id = 1159320895;
91+
update ne_10m_admin_0_countries_iso set name_id = 'Palestina' where ne_id = 1159320895;
92+
update ne_10m_admin_0_countries_iso set name_ur = 'فلسطین' where ne_id = 1159320895;
93+
94+
--Update Haiti name
95+
update ne_10m_admin_0_countries_iso set name_ru = 'Гаити' where ne_id = 1159320839;
96+
97+
--Update Ireland name
98+
update ne_10m_admin_0_countries_iso set name_ar = 'أيرلندا' where ne_id = 1159320877;
99+
update ne_10m_admin_0_countries_iso set name_pt = 'Irlanda' where ne_id = 1159320877;
100+
101+
--Update Kosovo name
102+
update ne_10m_admin_0_countries_tlc set name_ja = 'コソボ' where ne_id = 1159321007;
103+
update ne_10m_admin_0_countries_tlc set name_ru = 'Косово' where ne_id = 1159321007;
104+
105+
--Update Mali name
106+
update ne_10m_admin_0_countries_iso set name_ja = 'マリ' where ne_id = 1159321063;
107+
update ne_10m_admin_0_countries_iso set name_zht = '馬利' where ne_id = 1159321063;
108+
109+
--Update Moldova name
110+
update ne_10m_admin_0_countries_iso set name_de = 'Moldawien' where ne_id = 1159321045;
111+
112+
--Update Myanmar name
113+
update ne_10m_admin_0_countries_iso set name_es = 'Myanmar' where ne_id = 1159321067;
114+
115+
--Update North Korea name
116+
update ne_10m_admin_0_countries_iso set name_zh = '朝鲜' where ne_id = 1159321181;
117+
update ne_10m_admin_0_countries_iso set name_zht = '北韓' where ne_id = 1159321181;
118+
119+
--Update Oman name
120+
update ne_10m_admin_0_countries_iso set name_ar = 'عمان' where ne_id = 1159321151;
121+
122+
--Update Saint Barthélemy name
123+
update ne_10m_admin_0_countries_iso set name_pt = 'São Bartolomeu' where ne_id = 1159320633;
124+
update ne_10m_admin_0_countries_iso set name_zht = '聖巴多祿繆島' where ne_id = 1159320633;
125+
126+
--Update Saint Helena, Ascension and Tristan da Cunha name
127+
update ne_10m_admin_0_countries_iso set name_ar = 'سانت هيلينا، أسينسيون وتريستان دا كونها' where ne_id = 1159320733;
128+
update ne_10m_admin_0_countries_iso set name_de = 'St. Helena, Ascension und Tristan da Cunha' where ne_id = 1159320733;
129+
update ne_10m_admin_0_countries_iso set name_en = 'Saint Helena, Ascension and Tristan da Cunha' where ne_id = 1159320733;
130+
update ne_10m_admin_0_countries_iso set name_es = 'Santa Elena, Ascensión y Tristán de Acuña' where ne_id = 1159320733;
131+
update ne_10m_admin_0_countries_iso set name_fr = 'Sainte-Hélène, Ascension et Tristan da Cunha' where ne_id = 1159320733;
132+
update ne_10m_admin_0_countries_iso set name_pt = 'Santa Helena, Ascensão e Tristão da Cunha' where ne_id = 1159320733;
133+
update ne_10m_admin_0_countries_iso set name_ru = 'Острова Святой Елены, Вознесения и Тристан-да-Кунья' where ne_id = 1159320733;
134+
update ne_10m_admin_0_countries_iso set name_zh= '圣赫勒拿、阿森松和特里斯坦-达库尼亚' where ne_id = 1159320733;
135+
update ne_10m_admin_0_countries_iso set name_zht = '圣赫勒拿、阿森松和特里斯坦-达库尼亚' where ne_id = 1159320733;
136+
137+
--Update Saint Kitts and Nevis
138+
update ne_10m_admin_0_countries_iso set name_zht = '圣基茨和尼维斯' where ne_id = 1159320983;
139+
140+
--Update South Africa name
141+
update ne_10m_admin_0_countries_iso set name_ja = '南アフリカ' where ne_id = 1159321431;
142+
update ne_10m_admin_0_countries_iso set name_ko = '남아프리카' where ne_id = 1159321431;
143+
144+
--Update South Korea name
145+
update ne_10m_admin_0_countries_iso set name_zh = '韩国' where ne_id = 1159320985;
146+
update ne_10m_admin_0_countries_iso set name_zht = '南韓' where ne_id = 1159320985;
147+
148+
--Update Taiwan name
149+
update ne_10m_admin_0_countries_iso set name_de = 'Taiwan' where ne_id = 1159321335;
150+
update ne_10m_admin_0_countries_iso set name_es = 'Taiwán' where ne_id = 1159321335;
151+
update ne_10m_admin_0_countries_iso set name_ja = '台湾' where ne_id = 1159321335;
152+
update ne_10m_admin_0_countries_iso set name_ko = '타이완' where ne_id = 1159321335;
153+
update ne_10m_admin_0_countries_iso set name_zh = '台湾' where ne_id = 1159321335;
154+
update ne_10m_admin_0_countries_iso set name_zht = '臺灣' where ne_id = 1159321335;
155+
156+
--Update Turks and Caicos Island
157+
update ne_10m_admin_0_countries_iso set name_zht = '特克斯和凱科斯群島' where ne_id = 1159320737;
158+
159+
--Update United States name
160+
update ne_10m_admin_0_countries_iso set name_en = 'United States' where ne_id = 1159321369;

data/functions.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,8 +1302,8 @@ BEGIN
13021302
'ne_name_uk', i.name_uk,
13031303
'ne_name_ur', i.name_ur,
13041304
'ne_name_vi', i.name_vi,
1305-
'ne_name_zh', i.name_zh,
1306-
'ne_name_zht', i.name_zht
1305+
'ne_name_zh-Hans', i.name_zh,
1306+
'ne_name_zh-Hant', i.name_zht
13071307
]) INTO ne_name_tags
13081308
FROM ne_10m_admin_0_countries_iso i
13091309
WHERE i.wikidataid = wikidata_id;
@@ -1335,8 +1335,8 @@ BEGIN
13351335
'ne_name_uk', t.name_uk,
13361336
'ne_name_ur', t.name_ur,
13371337
'ne_name_vi', t.name_vi,
1338-
'ne_name_zh', t.name_zh,
1339-
'ne_name_zht', t.name_zht
1338+
'ne_name_zh-Hans', t.name_zh,
1339+
'ne_name_zh-Hant', t.name_zht
13401340
]) INTO ne_name_tags
13411341
FROM ne_10m_admin_0_countries_tlc t
13421342
WHERE t.wikidataid = wikidata_id
@@ -1370,8 +1370,8 @@ BEGIN
13701370
'ne_name_uk', sp.name_uk,
13711371
'ne_name_ur', sp.name_ur,
13721372
'ne_name_vi', sp.name_vi,
1373-
'ne_name_zh', sp.name_zh,
1374-
'ne_name_zht', sp.name_zht
1373+
'ne_name_zh-Hans', sp.name_zh,
1374+
'ne_name_zh-Hant', sp.name_zht
13751375
]) INTO ne_name_tags
13761376
FROM ne_10m_admin_1_states_provinces sp
13771377
WHERE sp.wikidataid = wikidata_id;
@@ -1403,8 +1403,8 @@ BEGIN
14031403
'ne_name_uk', pp.name_uk,
14041404
'ne_name_ur', pp.name_ur,
14051405
'ne_name_vi', pp.name_vi,
1406-
'ne_name_zh', pp.name_zh,
1407-
'ne_name_zht', pp.name_zht
1406+
'ne_name_zh-Hans', pp.name_zh,
1407+
'ne_name_zh-Hant', pp.name_zht
14081408
]) INTO ne_name_tags
14091409
FROM ne_10m_populated_places pp
14101410
WHERE pp.wikidataid = wikidata_id;

integration-test/1810-alternate-viewpoints.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_boundary(self):
9898
# should get a section recognised only by XX
9999
self.assert_has_feature(
100100
z, x, y, 'boundaries', {
101-
'kind': 'unrecognized_country',
101+
'kind': 'unrecognized',
102102
'kind:xx': 'country',
103103
'name': 'XX Claim',
104104

@@ -111,14 +111,14 @@ def test_boundary(self):
111111
self.assert_has_feature(
112112
z, x, y, 'boundaries', {
113113
'kind': 'country',
114-
'kind:xx': 'unrecognized_country',
114+
'kind:xx': 'unrecognized',
115115
'name': 'XX - YY',
116116
})
117117

118118
def test_claim(self):
119119
# test that a claim by countries BB & CC (and recognised by DD) is
120120
# only kind:country for those countries. everyone else's view is
121-
# kind: unrecognized_country.
121+
# kind: unrecognized.
122122
#
123123
# TODO: recognized_by not working yet.
124124
import dsl
@@ -157,15 +157,15 @@ def test_claim(self):
157157
self.assert_has_feature(
158158
z, x, y, 'boundaries', {
159159
# generally unrecognised
160-
'kind': 'unrecognized_country',
160+
'kind': 'unrecognized',
161161
# but BB & CC both claim this as a border
162162
'kind:bb': 'country',
163163
'kind:cc': 'country',
164164
# AA disputes that this border exists. NOTE: the kind:aa is
165165
# added to the output even though it duplicates the kind. this
166166
# is to help with multi-level fallback. see
167167
# https://github.com/tilezen/vector-datasource/pull/1895#discussion_r283912502
168-
'kind:aa': 'unrecognized_country',
168+
'kind:aa': 'unrecognized',
169169
# DD recognizes BB's claim, so should see this as a country.
170170
'kind:dd': 'country',
171171
})

integration-test/2022-disputed-borders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def test_places_with_viewpoints(self):
297297
'place:IT': 'town',
298298
'place:TR': 'not_there',
299299
'place:XX': 'country',
300+
'__ne_min_zoom': 4,
300301
'source': u'openstreetmap.org',
301302
'source:sqkm': u'CIA World Factbook',
302303
}),

integration-test/2068-place-unrecognized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ def test_place_unrecognized_into_kind(self):
1818
self.assert_has_feature(
1919
z, x, y, 'places', {
2020
'kind': 'unrecognized',
21-
'min_zoom': 6,
21+
'min_zoom': 8,
2222
})

integration-test/2081-tlc-pov.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_osm_places_with_viewpoint_tlc(self):
9090
'place:TLC': 'district',
9191
'source': 'openstreetmap.org',
9292
'source:sqkm': 'CIA World Factbook',
93+
'__ne_min_zoom': 4,
9394
}),
9495
)
9596

integration-test/2088-use-NE-name.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ def test_use_ne_name_country(self):
1212
u'place': u'country',
1313
u'name': u'Schweiz/Suisse/Svizzera/Svizra',
1414
u'name:en': u'Switzerland',
15+
u'name:zh-Hans': u'\u745e\u58eb',
16+
u'name:zh-Hant': u'\u745e\u58eb',
1517
u'source': u'openstreetmap.org',
1618
u'wikidata': u'Q30',
17-
u'ne_name_en': u'Test'
19+
u'__ne_min_zoom': 4,
20+
u'ne_name_en': u'Test',
21+
u'ne_name_zh-Hans': u'\u745e\u58eb\u8054\u90a6',
22+
u'ne_name_zh-Hant': u'\u745e\u58eb\u806f\u90a6'
1823
}),
1924
)
2025

2126
self.assert_has_feature(
2227
z, x, y, 'places', {
2328
'id': 10200326532,
24-
'name:en': u'Test'
29+
'kind': 'country',
30+
'name:en': u'Test',
31+
'name:zh-Hans': u'\u745e\u58eb\u8054\u90a6',
32+
'name:zh-Hant': u'\u745e\u58eb\u806f\u90a6'
2533
})
2634

2735
def test_use_ne_name_hamlet(self):
@@ -32,16 +40,23 @@ def test_use_ne_name_hamlet(self):
3240
u'place': u'hamlet',
3341
u'name': u'Schweiz/Suisse/Svizzera/Svizra',
3442
u'name:en': u'Switzerland',
43+
u'name:zh-Hans': u'\u745e\u58eb',
44+
u'name:zh-Hant': u'\u745e\u58eb',
3545
u'source': u'openstreetmap.org',
3646
u'wikidata': u'Q30',
37-
u'ne_name_en': u'Test'
47+
u'ne_name_en': u'Test',
48+
u'ne_name_zh-Hans': u'\u745e\u58eb\u8054\u90a6',
49+
u'ne_name_zh-Hant': u'\u745e\u58eb\u806f\u90a6'
3850
}),
3951
)
4052

4153
self.assert_has_feature(
4254
z, x, y, 'places', {
4355
'id': 10200326532,
44-
'name:en': u'Test'
56+
'kind': 'locality',
57+
'name:en': u'Test',
58+
'name:zh-Hans': u'\u745e\u58eb\u8054\u90a6',
59+
'name:zh-Hant': u'\u745e\u58eb\u806f\u90a6'
4560
})
4661

4762
def test_no_ne_name(self):
@@ -52,15 +67,21 @@ def test_no_ne_name(self):
5267
u'place': u'country',
5368
u'name': u'Schweiz/Suisse/Svizzera/Svizra',
5469
u'name:en': u'Switzerland',
70+
u'name:zh-Hans': u'\u745e\u58eb',
71+
u'name:zh-Hant': u'\u745e\u58eb',
72+
u'__ne_min_zoom': 4,
5573
u'source': u'openstreetmap.org',
56-
u'wikidata': u'Q30',
74+
u'wikidata': u'Q30'
5775
}),
5876
)
5977

6078
self.assert_has_feature(
6179
z, x, y, 'places', {
6280
'id': 10200326532,
63-
'name:en': u'Switzerland'
81+
'kind': 'country',
82+
'name:en': u'Switzerland',
83+
'name:zh-Hans': u'\u745e\u58eb',
84+
'name:zh-Hant': u'\u745e\u58eb'
6485
})
6586

6687
def test_null_name(self):
@@ -73,12 +94,14 @@ def test_null_name(self):
7394
u'name:en': u'Switzerland',
7495
u'source': u'openstreetmap.org',
7596
u'wikidata': u'Q30',
97+
u'__ne_min_zoom': 4,
7698
u'ne_name_en': u''
7799
}),
78100
)
79101

80102
self.assert_has_feature(
81103
z, x, y, 'places', {
82104
'id': 10200326532,
105+
'kind': 'country',
83106
'name:en': u'Switzerland'
84107
})

integration-test/988-add-population-to-collision-rank.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def test_country_population_rank(self):
153153
'name': 'Foo Country',
154154
'population': '1000000000',
155155
'source': 'openstreetmap.org',
156+
'__ne_min_zoom': 4,
156157
}),
157158
)
158159

osm2pgsql.lua

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,6 @@ function osm2pgsql.process_node(object)
462462
output_hstore['place'] = 'country'
463463
output_hstore['disputed_by'] = 'FR;ID;IN;MA;NL;Pl;PS;SA;TR'
464464
end
465-
-- Redefine Israel country label for SA;PK;ID
466-
if object.tags.place and object.tags.wikidata == 'Q801' then
467-
output_hstore["name:id"] = 'Palestina'
468-
output_hstore["name:ur"] = 'فلسطین'
469-
output_hstore["name:ar"] = 'فلسطين'
470-
end
471465
-- Recast Taiwan country label as region label for China POV
472466
if object.tags.place and object.tags.wikidata == 'Q865' then
473467
output_hstore['place:CN'] = 'region'
@@ -648,20 +642,6 @@ function osm2pgsql.process_node(object)
648642
output_hstore['place'] = 'country'
649643
end
650644

651-
-- Update names of some countries for better rendering. We will update the data and deprecate this eventually.
652-
-- Rename Falkland Islands
653-
if object.tags.place == 'country' and object.tags['ISO3166-1'] == 'FK' then
654-
output_hstore['name:en'] = 'Falkland Islands (Islas Malvinas)'
655-
end
656-
-- Rename Saint Martin
657-
if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MF' then
658-
output_hstore['name:en'] = 'Saint Martin'
659-
end
660-
-- Rename Sint Maarten
661-
if object.tags.place == 'country' and object.tags['ISO3166-1'] == 'SX' then
662-
output_hstore['name:en'] = 'Sint Maarten'
663-
end
664-
665645
output.tags = output_hstore
666646

667647
if hstore_column then

scripts/disputed_relation_overpass_query.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ rel(13563121); // Extent of Claim at South Ossetia
8484
rel(13573737); // Extent of Chilean Claim at Southern Glaciers Field
8585
rel(13573738); // Extent of Argentinian Claim at Southern Glaciers Field
8686
rel(13573952); // Extent of Claim at Abkhazia
87-
rel(13573966); // Extent of Claim at Donbass
87+
// timeline(rel,13573966);foreach(retro(u(t["created"]))(rel(13573966);(._;>;); out meta;);); // Extent of Claim at Donbass
8888
rel(13573969); // Extent of Belize Claim
8989
rel(13573970); // Extent of Guatemalan Claim
9090
rel(13573985); // Extent of Kosovo Claim
9191
rel(13574165); // Extent of Israeli Claim at Golan Heights
92-
rel(13574166); // 1949 Israeli–Syrian DMZ
92+
timeline(rel,13574166);foreach(retro(u(t["created"]))(rel(13574166);(._;>;); out meta;);); // 1949 Israeli–Syrian DMZ
9393
rel(13574167); // Extent of Syrian Claims at Golan Heights
9494
rel(13790690); // Approximate Extent of Siachen Glacier Dispute
9595
rel(13812677); // Line of Control at Demchok

0 commit comments

Comments
 (0)