From 33979e5ffea5279a4ed2df02ea14d0cdc9c78a98 Mon Sep 17 00:00:00 2001 From: junderwood Date: Tue, 12 Apr 2022 16:50:12 -0700 Subject: [PATCH 01/15] lua to upgrade dependencies and territories to country status for labels. --- osm2pgsql.lua | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 4b0bfa257..71fa1cbb9 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -623,6 +623,97 @@ function osm2pgsql.process_node(object) output_hstore['place:VN'] = 'region' end +-- Recast various dependencies as countries +-- American Samoa + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'AS' then + output_hstore['place'] = 'county' + end +-- Christmas Island + if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'CX' then + output_hstore['place'] = 'county' + end +-- Cocos (Keeling) Islands + if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'CC' then + output_hstore['place'] = 'county' + end +-- French Guiana + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GF' then + output_hstore['place'] = 'county' + end +-- French Polynesia + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PF' then + output_hstore['place'] = 'county' + end +-- French Southern and Antarctic Lands + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'TF' then + output_hstore['place'] = 'county' + end +-- Guadeloupe + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GP' then + output_hstore['place'] = 'county' + end +-- Guam + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GU' then + output_hstore['place'] = 'county' + end +-- Heard Island and McDonald Islands + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'HM' then + output_hstore['place'] = 'county' + end +-- Martinique + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MQ' then + output_hstore['place'] = 'county' + end +-- Mayotte + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'YT' then + output_hstore['place'] = 'county' + end +-- Norfolk Island + if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'NF' then + output_hstore['place'] = 'county' + end +-- Northern Mariana Islands + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MP' then + output_hstore['place'] = 'county' + end +-- Puerto Rico + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PR' then + output_hstore['place'] = 'county' + end +-- Réunion + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'RE' then + output_hstore['place'] = 'county' + end +-- Saint Barthelemy + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'BL' then + output_hstore['place'] = 'county' + end +-- Saint Helena, Ascension and Tristan da Cunha + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'SH' then + output_hstore['place'] = 'county' + end +-- Saint Martin + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MF' then + output_hstore['place'] = 'county' + end +-- Saint Pierre and Miquelon + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PM' then + output_hstore['place'] = 'county' + end +-- Svalbard + if object.tags.place == 'region' and object.tags['ISO3166-1'] == 'SJ' then + output_hstore['place'] = 'county' + end +-- United States Virgin Islands + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'VI' then + output_hstore['place'] = 'county' + end +-- Wallis and Futuna + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'WF' then + output_hstore['place'] = 'county' + end + + output.tags = output_hstore if hstore_column then From e63395e34aac1ae042bc06ae6a3449eeb09c478b Mon Sep 17 00:00:00 2001 From: junderwood Date: Thu, 14 Apr 2022 11:27:50 -0700 Subject: [PATCH 02/15] Remove unneeded disputes and add ne_id and ne:brk to way tags to allow for a dispute_id. --- osm2pgsql.lua | 179 ++++++++------------------------------------------ 1 file changed, 28 insertions(+), 151 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 71fa1cbb9..6fe4b395f 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -499,221 +499,97 @@ function osm2pgsql.process_node(object) object.tags.wikidata == 'Q994730') then output_hstore['disputed_by'] = 'CN;RU;IN;GR' end --- Recast Northern Cyprus as country label and turn off for several POVs including China and Russia - if object.tags.place and object.tags.wikidata == 'Q23681' then - output_hstore['place'] = 'country' - output_hstore['disputed_by'] = 'CN;RU;IN;GR;CY' - end --- Turn off Abkhazia label for most countries - if object.tags.place and object.tags.wikidata == 'Q23334' then - output_hstore['place:AR'] = 'region' - output_hstore['place:BD'] = 'region' - output_hstore['place:BR'] = 'region' - output_hstore['place:CN'] = 'region' - output_hstore['place:DE'] = 'region' - output_hstore['place:EG'] = 'region' - output_hstore['place:GB'] = 'region' - output_hstore['place:GR'] = 'region' - output_hstore['place:ID'] = 'region' - output_hstore['place:IL'] = 'region' - output_hstore['place:IN'] = 'region' - output_hstore['place:IT'] = 'region' - output_hstore['place:JP'] = 'region' - output_hstore['place:KO'] = 'region' - output_hstore['place:MA'] = 'region' - output_hstore['place:NL'] = 'region' - output_hstore['place:NP'] = 'region' - output_hstore['place:PK'] = 'region' - output_hstore['place:PL'] = 'region' - output_hstore['place:PS'] = 'region' - output_hstore['place:PT'] = 'region' - output_hstore['place:SA'] = 'region' - output_hstore['place:SE'] = 'region' - output_hstore['place:TR'] = 'region' - output_hstore['place:TW'] = 'region' - output_hstore['place:UA'] = 'region' - output_hstore['place:VN'] = 'region' - end --- Turn off South Ossetia label for most countries - if object.tags.place and object.tags.wikidata == 'Q23427' then - output_hstore['place:AR'] = 'region' - output_hstore['place:BD'] = 'region' - output_hstore['place:BR'] = 'region' - output_hstore['place:CN'] = 'region' - output_hstore['place:DE'] = 'region' - output_hstore['place:EG'] = 'region' - output_hstore['place:GB'] = 'region' - output_hstore['place:GR'] = 'region' - output_hstore['place:ID'] = 'region' - output_hstore['place:IL'] = 'region' - output_hstore['place:IN'] = 'region' - output_hstore['place:IT'] = 'region' - output_hstore['place:JP'] = 'region' - output_hstore['place:KO'] = 'region' - output_hstore['place:MA'] = 'region' - output_hstore['place:NL'] = 'region' - output_hstore['place:NP'] = 'region' - output_hstore['place:PK'] = 'region' - output_hstore['place:PL'] = 'region' - output_hstore['place:PS'] = 'region' - output_hstore['place:PT'] = 'region' - output_hstore['place:SA'] = 'region' - output_hstore['place:SE'] = 'region' - output_hstore['place:TR'] = 'region' - output_hstore['place:TW'] = 'region' - output_hstore['place:UA'] = 'region' - output_hstore['place:VN'] = 'region' - end --- Turn off Nagorno-Karabakh label for most countries - if object.tags.place and object.tags.wikidata == 'Q2397204' then - output_hstore['place:AR'] = 'region' - output_hstore['place:BD'] = 'region' - output_hstore['place:BR'] = 'region' - output_hstore['place:CN'] = 'region' - output_hstore['place:DE'] = 'region' - output_hstore['place:EG'] = 'region' - output_hstore['place:ES'] = 'region' - output_hstore['place:FR'] = 'region' - output_hstore['place:GB'] = 'region' - output_hstore['place:GR'] = 'region' - output_hstore['place:ID'] = 'region' - output_hstore['place:IL'] = 'region' - output_hstore['place:IN'] = 'region' - output_hstore['place:IT'] = 'region' - output_hstore['place:JP'] = 'region' - output_hstore['place:KO'] = 'region' - output_hstore['place:MA'] = 'region' - output_hstore['place:NL'] = 'region' - output_hstore['place:NP'] = 'region' - output_hstore['place:PK'] = 'region' - output_hstore['place:PL'] = 'region' - output_hstore['place:PS'] = 'region' - output_hstore['place:PT'] = 'region' - output_hstore['place:RU'] = 'region' - output_hstore['place:SA'] = 'region' - output_hstore['place:SE'] = 'region' - output_hstore['place:TR'] = 'region' - output_hstore['place:TW'] = 'region' - output_hstore['place:US'] = 'region' - output_hstore['place:VN'] = 'region' - end --- Turn off Somaliland label for most countries - if object.tags.place and object.tags.wikidata == 'Q34754' then - output_hstore['place:AR'] = 'region' - output_hstore['place:BD'] = 'region' - output_hstore['place:BR'] = 'region' - output_hstore['place:CN'] = 'region' - output_hstore['place:EG'] = 'region' - output_hstore['place:GR'] = 'region' - output_hstore['place:ID'] = 'region' - output_hstore['place:IL'] = 'region' - output_hstore['place:IN'] = 'region' - output_hstore['place:MA'] = 'region' - output_hstore['place:NP'] = 'region' - output_hstore['place:PK'] = 'region' - output_hstore['place:PL'] = 'region' - output_hstore['place:PS'] = 'region' - output_hstore['place:PT'] = 'region' - output_hstore['place:RU'] = 'region' - output_hstore['place:SA'] = 'region' - output_hstore['place:SO'] = 'region' - output_hstore['place:TR'] = 'region' - output_hstore['place:TW'] = 'region' - output_hstore['place:UA'] = 'region' - output_hstore['place:VN'] = 'region' - end -- Recast various dependencies as countries -- American Samoa if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'AS' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Christmas Island if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'CX' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Cocos (Keeling) Islands if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'CC' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- French Guiana if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- French Polynesia if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- French Southern and Antarctic Lands if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'TF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Guadeloupe if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GP' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Guam if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GU' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Heard Island and McDonald Islands if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'HM' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Martinique if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MQ' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Mayotte if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'YT' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Norfolk Island if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'NF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Northern Mariana Islands if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MP' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Puerto Rico if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PR' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Réunion if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'RE' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Saint Barthelemy if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'BL' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Saint Helena, Ascension and Tristan da Cunha if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'SH' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Saint Martin if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Saint Pierre and Miquelon if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PM' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Svalbard if object.tags.place == 'region' and object.tags['ISO3166-1'] == 'SJ' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- United States Virgin Islands if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'VI' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end -- Wallis and Futuna if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'WF' then - output_hstore['place'] = 'county' + output_hstore['place'] = 'country' end - output.tags = output_hstore if hstore_column then @@ -811,6 +687,12 @@ function osm2pgsql.process_way(object) if v.recognized_by then output_hstore.recognized_by = v.recognized_by end + if v.ne_id then + output_hstore.ne_id = v.ne_id + end + if v['ne:brk'] then + output_hstore['ne:brk'] = v['ne:brk'] + end end end @@ -919,11 +801,6 @@ function osm2pgsql.process_relation(object) output_hstore['admin_level:CN'] = '4' end --- Convert admin_level 5 boundaries in Northern Cyprus to 4 - if type == 'boundary' and object.tags.is_in == 'Northern Cyprus' and object.tags.admin_level == '5' then - output_hstore['admin_level'] = '4' - end - -- Turn off West Bank and Judea and Samaria relations if type == 'boundary' and object.tags.wikidata == 'Q36678' then output_hstore = {} From c022e90bd3531100e40f3a46746a6656e14b3d73 Mon Sep 17 00:00:00 2001 From: junderwood Date: Wed, 20 Apr 2022 10:23:23 -0700 Subject: [PATCH 03/15] fixed Heard Island place type --- osm2pgsql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 6fe4b395f..41c43b158 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -534,7 +534,7 @@ function osm2pgsql.process_node(object) output_hstore['place'] = 'country' end -- Heard Island and McDonald Islands - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'HM' then + if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'HM' then output_hstore['place'] = 'country' end -- Martinique From f5c2b984817f489c59468445c39cfbc526a5a323 Mon Sep 17 00:00:00 2001 From: junderwood Date: Wed, 20 Apr 2022 12:14:06 -0700 Subject: [PATCH 04/15] fix brk_a3 tag --- osm2pgsql.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 41c43b158..72d790496 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -690,8 +690,8 @@ function osm2pgsql.process_way(object) if v.ne_id then output_hstore.ne_id = v.ne_id end - if v['ne:brk'] then - output_hstore['ne:brk'] = v['ne:brk'] + if v['ne:brk_a3'] then + output_hstore['ne:brk_a3'] = v['ne:brk_a3'] end end end From 964e37f243de7991215bffff08967c13998273a7 Mon Sep 17 00:00:00 2001 From: junderwood Date: Wed, 20 Apr 2022 12:32:49 -0700 Subject: [PATCH 05/15] Change removed dispute place value to nil to ensure it doesn't end up on the map. --- osm2pgsql.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 72d790496..414f6cc0f 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -500,6 +500,27 @@ function osm2pgsql.process_node(object) output_hstore['disputed_by'] = 'CN;RU;IN;GR' end +-- Turn off Northern Cyprus label + if object.tags.place and object.tags.wikidata == 'Q23681' then + output_hstore['place'] = nil + end +-- Turn off Abkhazia label + if object.tags.place and object.tags.wikidata == 'Q23334' then + output_hstore['place'] = nil + end +-- Turn off South Ossetia label + if object.tags.place and object.tags.wikidata == 'Q23427' then + output_hstore['place'] = nil + end +-- Turn off Nagorno-Karabakh label + if object.tags.place and object.tags.wikidata == 'Q2397204' then + output_hstore['place'] = nil + end +-- Turn off Somaliland label + if object.tags.place and object.tags.wikidata == 'Q34754' then + output_hstore['place'] = nil + end + -- Recast various dependencies as countries -- American Samoa if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'AS' then From d895639ab4be0e7ce2971b2452a9e2ae3177b5db Mon Sep 17 00:00:00 2001 From: junderwood Date: Thu, 21 Apr 2022 09:57:33 -0700 Subject: [PATCH 06/15] Comment changes --- osm2pgsql.lua | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 414f6cc0f..683acc970 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -500,25 +500,29 @@ function osm2pgsql.process_node(object) output_hstore['disputed_by'] = 'CN;RU;IN;GR' end --- Turn off Northern Cyprus label +-- Recast Northern Cyprus as country label and turn off for several POVs including China and Russia if object.tags.place and object.tags.wikidata == 'Q23681' then - output_hstore['place'] = nil + output_hstore['place'] = 'country' + output_hstore['disputed_by'] = 'CN;RU;IN;GR;CY' end --- Turn off Abkhazia label +-- Turn off Abkhazia label for most countries if object.tags.place and object.tags.wikidata == 'Q23334' then - output_hstore['place'] = nil + output_hstore['place'] = 'region' + output_hstore['place:RU'] = 'country' end --- Turn off South Ossetia label +-- Turn off South Ossetia label for most countries if object.tags.place and object.tags.wikidata == 'Q23427' then - output_hstore['place'] = nil + output_hstore['place'] = 'country' + output_hstore['place:RU'] = 'country' end --- Turn off Nagorno-Karabakh label +-- Turn off Nagorno-Karabakh label for most countries if object.tags.place and object.tags.wikidata == 'Q2397204' then - output_hstore['place'] = nil + output_hstore['place'] = 'country' + output_hstore['place:RU'] = 'region' end --- Turn off Somaliland label +-- Turn off Somaliland label for most countries if object.tags.place and object.tags.wikidata == 'Q34754' then - output_hstore['place'] = nil + output_hstore['place'] = 'country' end -- Recast various dependencies as countries @@ -822,6 +826,18 @@ function osm2pgsql.process_relation(object) output_hstore['admin_level:CN'] = '4' end +-- Convert admin_level 5 boundaries in Northern Cyprus to 4 + if type == 'boundary' and object.tags.is_in == 'Northern Cyprus' and object.tags.admin_level == '5' then + output_hstore['admin_level'] = '4' + end + +-- Convert admin_level 5 boundaries in Cyprus to 4 + if type == 'boundary' and object.tags.admin_level == '5' and object.tags['ISO3166-2'] then + if osm2pgsql.has_prefix(object.tags['ISO3166-2'], 'CY-') then + output_hstore['admin_level'] = '4' + end + end + -- Turn off West Bank and Judea and Samaria relations if type == 'boundary' and object.tags.wikidata == 'Q36678' then output_hstore = {} From 85b7492a8d9681e63710f75ca02b564242c377fe Mon Sep 17 00:00:00 2001 From: junderwood Date: Fri, 22 Apr 2022 15:04:02 -0700 Subject: [PATCH 07/15] grouped the french overseas department into regions --- osm2pgsql.lua | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 683acc970..538212e79 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -538,10 +538,6 @@ function osm2pgsql.process_node(object) if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'CC' then output_hstore['place'] = 'country' end --- French Guiana - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GF' then - output_hstore['place'] = 'country' - end -- French Polynesia if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PF' then output_hstore['place'] = 'country' @@ -550,10 +546,6 @@ function osm2pgsql.process_node(object) if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'TF' then output_hstore['place'] = 'country' end --- Guadeloupe - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GP' then - output_hstore['place'] = 'country' - end -- Guam if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GU' then output_hstore['place'] = 'country' @@ -562,13 +554,9 @@ function osm2pgsql.process_node(object) if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'HM' then output_hstore['place'] = 'country' end --- Martinique - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MQ' then - output_hstore['place'] = 'country' - end --- Mayotte - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'YT' then - output_hstore['place'] = 'country' +-- New Caledonia + if object.tags.place == 'archipelago' and object.tags['ISO3166-1'] == 'NF' then + output_hstore['place'] = 'region' end -- Norfolk Island if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'NF' then @@ -582,10 +570,6 @@ function osm2pgsql.process_node(object) if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'PR' then output_hstore['place'] = 'country' end --- Réunion - if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'RE' then - output_hstore['place'] = 'country' - end -- Saint Barthelemy if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'BL' then output_hstore['place'] = 'country' @@ -615,6 +599,29 @@ function osm2pgsql.process_node(object) output_hstore['place'] = 'country' end +-- Recast various French overseas departments as region +-- Réunion + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'RE' then + output_hstore['place'] = 'region' + end +-- Martinique + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MQ' then + output_hstore['place'] = 'region' + end +-- Mayotte + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'YT' then + output_hstore['place'] = 'region' + end +-- Guadeloupe + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GP' then + output_hstore['place'] = 'region' + end +-- French Guiana + if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GF' then + output_hstore['place'] = 'region' + end + + output.tags = output_hstore if hstore_column then From 987d52c2b7d22b04d71069a2eca4e5ad2eb14bc8 Mon Sep 17 00:00:00 2001 From: junderwood Date: Fri, 22 Apr 2022 15:25:44 -0700 Subject: [PATCH 08/15] grouped the french overseas department into regions --- data/apply-ne_borders.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/apply-ne_borders.sql diff --git a/data/apply-ne_borders.sql b/data/apply-ne_borders.sql new file mode 100644 index 000000000..e69de29bb From 50a61990d9f900249bb6156f9bde768f7be90458 Mon Sep 17 00:00:00 2001 From: junderwood Date: Fri, 22 Apr 2022 15:26:41 -0700 Subject: [PATCH 09/15] removed accidental inclusion --- data/apply-ne_borders.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 data/apply-ne_borders.sql diff --git a/data/apply-ne_borders.sql b/data/apply-ne_borders.sql deleted file mode 100644 index e69de29bb..000000000 From e3450171e9795bb0a07f6afa248355d3adf73c0c Mon Sep 17 00:00:00 2001 From: junderwood Date: Tue, 26 Apr 2022 11:07:58 -0700 Subject: [PATCH 10/15] fixed place types --- osm2pgsql.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 538212e79..ec9ea4c0d 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -500,9 +500,9 @@ function osm2pgsql.process_node(object) output_hstore['disputed_by'] = 'CN;RU;IN;GR' end --- Recast Northern Cyprus as country label and turn off for several POVs including China and Russia +-- Turn off Northern Cyprus label for most countries if object.tags.place and object.tags.wikidata == 'Q23681' then - output_hstore['place'] = 'country' + output_hstore['place'] = 'region' output_hstore['disputed_by'] = 'CN;RU;IN;GR;CY' end -- Turn off Abkhazia label for most countries @@ -512,17 +512,17 @@ function osm2pgsql.process_node(object) end -- Turn off South Ossetia label for most countries if object.tags.place and object.tags.wikidata == 'Q23427' then - output_hstore['place'] = 'country' + output_hstore['place'] = 'region' output_hstore['place:RU'] = 'country' end -- Turn off Nagorno-Karabakh label for most countries if object.tags.place and object.tags.wikidata == 'Q2397204' then - output_hstore['place'] = 'country' - output_hstore['place:RU'] = 'region' + output_hstore['place'] = 'region' + output_hstore['place:RU'] = 'country' end -- Turn off Somaliland label for most countries if object.tags.place and object.tags.wikidata == 'Q34754' then - output_hstore['place'] = 'country' + output_hstore['place'] = 'region' end -- Recast various dependencies as countries From a98f7d930f382c87e476b84af048f791c12c21f7 Mon Sep 17 00:00:00 2001 From: junderwood Date: Thu, 28 Apr 2022 12:35:27 -0700 Subject: [PATCH 11/15] Add yaml filter for place=unrecognized and upload lua --- integration-test/2068-place-unrecognized.py | 22 +++++++++++++++++++++ osm2pgsql.lua | 16 ++++++++------- yaml/places.yaml | 12 +++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 integration-test/2068-place-unrecognized.py diff --git a/integration-test/2068-place-unrecognized.py b/integration-test/2068-place-unrecognized.py new file mode 100644 index 000000000..34f9894fa --- /dev/null +++ b/integration-test/2068-place-unrecognized.py @@ -0,0 +1,22 @@ +import dsl + +from . import FixtureTest + + +class TestPlaceUnrecognized(FixtureTest): + def test_place_unrecognized_into_kind(self): + + z, x, y = 16, 0, 0 + self.generate_fixtures( + dsl.way(1, dsl.tile_centre_shape(z, x, y), { + 'place': 'unrecognized', + 'source': 'openstreetmap.org', + 'name': 'Foo' + }), + ) + + self.assert_has_feature( + z, x, y, 'places', { + 'kind': 'unrecognized', + 'min_zoom': 6, + }) \ No newline at end of file diff --git a/osm2pgsql.lua b/osm2pgsql.lua index ec9ea4c0d..cdefaff95 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -502,27 +502,29 @@ function osm2pgsql.process_node(object) -- Turn off Northern Cyprus label for most countries if object.tags.place and object.tags.wikidata == 'Q23681' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'unrecognized' + output_hstore['place:TR'] = 'country' output_hstore['disputed_by'] = 'CN;RU;IN;GR;CY' end --- Turn off Abkhazia label for most countries +-- Show Abkhazia label as region for most countries if object.tags.place and object.tags.wikidata == 'Q23334' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'unrecognized' output_hstore['place:RU'] = 'country' end --- Turn off South Ossetia label for most countries +-- Show South Ossetia label as region for most countries if object.tags.place and object.tags.wikidata == 'Q23427' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'unrecognized' output_hstore['place:RU'] = 'country' end -- Turn off Nagorno-Karabakh label for most countries if object.tags.place and object.tags.wikidata == 'Q2397204' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'unrecognized' output_hstore['place:RU'] = 'country' end -- Turn off Somaliland label for most countries if object.tags.place and object.tags.wikidata == 'Q34754' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'unrecognized' + output_hstore['place:TW'] = 'country' end -- Recast various dependencies as countries diff --git a/yaml/places.yaml b/yaml/places.yaml index 270a0d337..cc915a6cc 100644 --- a/yaml/places.yaml +++ b/yaml/places.yaml @@ -176,6 +176,18 @@ filters: kind: region kind_detail: province table: osm + - filter: {name: true, place: unrecognized} + # note: min_zoom needs to be smaller than any min_label in + # ne_10m_admin_1_states_provinces to make sure we're not dropping any by + # not being included in the PostgreSQL index. + # + # note: also, we knock this down to 6 during post-processing for any province + # which doesn't match an NE curated one. + min_zoom: 6 + output: + <<: [*output_properties, *ne_zooms] + kind: unrecognized + table: osm - filter: {name: true, population: true, place: [city, town]} min_zoom: 8 output: From 03046f42129ba0a8ba9ee54a90fb03ab24b95fde Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Apr 2022 19:36:29 +0000 Subject: [PATCH 12/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- integration-test/2068-place-unrecognized.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/2068-place-unrecognized.py b/integration-test/2068-place-unrecognized.py index 34f9894fa..6fd007878 100644 --- a/integration-test/2068-place-unrecognized.py +++ b/integration-test/2068-place-unrecognized.py @@ -19,4 +19,4 @@ def test_place_unrecognized_into_kind(self): z, x, y, 'places', { 'kind': 'unrecognized', 'min_zoom': 6, - }) \ No newline at end of file + }) From a784e74c8eee4190198a22e9a94a17280cb7a3b1 Mon Sep 17 00:00:00 2001 From: junderwood Date: Thu, 28 Apr 2022 12:37:41 -0700 Subject: [PATCH 13/15] typo --- osm2pgsql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index cdefaff95..9a58d7390 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -508,7 +508,7 @@ function osm2pgsql.process_node(object) end -- Show Abkhazia label as region for most countries if object.tags.place and object.tags.wikidata == 'Q23334' then - output_hstore['place'] = 'unrecognized' + output_hstore['place'] = 'region' output_hstore['place:RU'] = 'country' end -- Show South Ossetia label as region for most countries From 2c8da9b03430b8bf0d25c348f0bfa1c8fa994a90 Mon Sep 17 00:00:00 2001 From: junderwood Date: Thu, 28 Apr 2022 17:42:45 -0700 Subject: [PATCH 14/15] Addressed some of the comments --- osm2pgsql.lua | 10 +++++----- yaml/places.yaml | 16 ++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 9a58d7390..515c3109c 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -482,7 +482,7 @@ function osm2pgsql.process_node(object) end -- Turn off Kosovo country label for CN;RU;IN;GR if object.tags.place and object.tags.wikidata == 'Q1246' then - output_hstore['disputed_by'] = 'CN;GR;IN;RU' + output_hstore['disputed_by'] = 'AR;BR;CN;GR;ID;IN;MA;NP;PS;RU;UA;VN' output_hstore['recognized_by'] = 'AR;BD;BR;DE;EG;ES;FR;GB;ID;IL;IT;JP;KO;MA;NL;NP;PK;PL;PS;PT;SA;SE;TR;TW;UA;US;VN' end -- Hide Kosovo region labels for several POVs including China and Russia @@ -497,7 +497,7 @@ function osm2pgsql.process_node(object) object.tags.wikidata == 'Q963121' or object.tags.wikidata == 'Q991291' or object.tags.wikidata == 'Q991291' or object.tags.wikidata == 'Q991313' or object.tags.wikidata == 'Q991332' or object.tags.wikidata == 'Q994245' or object.tags.wikidata == 'Q994730') then - output_hstore['disputed_by'] = 'CN;RU;IN;GR' + output_hstore['disputed_by'] = 'AR;BR;CN;GR;ID;IN;MA;NP;PS;RU;UA;VN' end -- Turn off Northern Cyprus label for most countries @@ -511,12 +511,12 @@ function osm2pgsql.process_node(object) output_hstore['place'] = 'region' output_hstore['place:RU'] = 'country' end --- Show South Ossetia label as region for most countries +-- Turn off South Ossetia label for most countries if object.tags.place and object.tags.wikidata == 'Q23427' then output_hstore['place'] = 'unrecognized' output_hstore['place:RU'] = 'country' end --- Turn off Nagorno-Karabakh label for most countries +-- Turn off Artsakh (Nagorno-Karabakh) label for most countries if object.tags.place and object.tags.wikidata == 'Q2397204' then output_hstore['place'] = 'unrecognized' output_hstore['place:RU'] = 'country' @@ -558,7 +558,7 @@ function osm2pgsql.process_node(object) end -- New Caledonia if object.tags.place == 'archipelago' and object.tags['ISO3166-1'] == 'NF' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end -- Norfolk Island if object.tags.place == 'territory' and object.tags['ISO3166-1'] == 'NF' then diff --git a/yaml/places.yaml b/yaml/places.yaml index cc915a6cc..9ab087abd 100644 --- a/yaml/places.yaml +++ b/yaml/places.yaml @@ -138,7 +138,7 @@ filters: kind: {col: placetype} table: wof extra_columns: [ min_zoom ] - - filter: {name: true, place: country} + - filter: {name: true, place: [country,unrecognized]} # note: min_zoom needs to be smaller than any min_label in # ne_10m_admin_0_countries to make sure we're not dropping any by not being # included in the PostgreSQL index. @@ -148,7 +148,7 @@ filters: min_zoom: 1 output: <<: [*output_properties, *ne_zooms] - kind: country + kind: {col: place} table: osm - filter: {name: true, place: state} # note: min_zoom needs to be smaller than any min_label in @@ -176,18 +176,6 @@ filters: kind: region kind_detail: province table: osm - - filter: {name: true, place: unrecognized} - # note: min_zoom needs to be smaller than any min_label in - # ne_10m_admin_1_states_provinces to make sure we're not dropping any by - # not being included in the PostgreSQL index. - # - # note: also, we knock this down to 6 during post-processing for any province - # which doesn't match an NE curated one. - min_zoom: 6 - output: - <<: [*output_properties, *ne_zooms] - kind: unrecognized - table: osm - filter: {name: true, population: true, place: [city, town]} min_zoom: 8 output: From d6d17619f8c9513ea32960fdf71212d185d02c55 Mon Sep 17 00:00:00 2001 From: junderwood Date: Mon, 2 May 2022 15:18:35 -0700 Subject: [PATCH 15/15] updated french dependencies back to country --- osm2pgsql.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osm2pgsql.lua b/osm2pgsql.lua index 515c3109c..6d54c2354 100644 --- a/osm2pgsql.lua +++ b/osm2pgsql.lua @@ -483,7 +483,7 @@ function osm2pgsql.process_node(object) -- Turn off Kosovo country label for CN;RU;IN;GR if object.tags.place and object.tags.wikidata == 'Q1246' then output_hstore['disputed_by'] = 'AR;BR;CN;GR;ID;IN;MA;NP;PS;RU;UA;VN' - output_hstore['recognized_by'] = 'AR;BD;BR;DE;EG;ES;FR;GB;ID;IL;IT;JP;KO;MA;NL;NP;PK;PL;PS;PT;SA;SE;TR;TW;UA;US;VN' + output_hstore['recognized_by'] = 'BD;DE;EG;ES;FR;GB;IL;IT;JP;KO;NL;PK;PL;PT;SA;SE;TR;TW;US' end -- Hide Kosovo region labels for several POVs including China and Russia if object.tags.place and (object.tags.wikidata == 'Q1008042' or object.tags.wikidata == 'Q1021775' or @@ -604,23 +604,23 @@ function osm2pgsql.process_node(object) -- Recast various French overseas departments as region -- Réunion if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'RE' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end -- Martinique if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'MQ' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end -- Mayotte if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'YT' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end -- Guadeloupe if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GP' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end -- French Guiana if object.tags.place == 'state' and object.tags['ISO3166-1'] == 'GF' then - output_hstore['place'] = 'region' + output_hstore['place'] = 'country' end