From 659af4bf1dd737bd2c6c5bf62a567925edf4b7ec Mon Sep 17 00:00:00 2001
From: map-per <map-per@gmx.de>
Date: Wed, 29 Jan 2025 15:01:19 +0100
Subject: [PATCH] Separate quarter and neighbourhood

Signed-off-by: map-per <map-per@gmx.de>
---
 data/categories.txt                           |  8 +--
 data/mapcss-mapping.csv                       |  4 +-
 data/strings/types_strings.txt                | 68 ++++++++++++++++---
 .../default/include/Basemap_label.mapcss      | 23 ++++++-
 .../include/priorities_4_overlays.prio.txt    |  1 +
 .../include/priorities_4_overlays.prio.txt    |  1 +
 indexer/ftypes_matcher.cpp                    |  4 +-
 indexer/ftypes_matcher.hpp                    |  1 +
 search/geocoder.cpp                           |  1 +
 9 files changed, 93 insertions(+), 18 deletions(-)

diff --git a/data/categories.txt b/data/categories.txt
index 02a5457f58..83dd7cb1b4 100644
--- a/data/categories.txt
+++ b/data/categories.txt
@@ -7804,9 +7804,9 @@ sw:Kisiwa
 fa:جزیره
 mr:बेट
 
-place-suburb|landuse-residential|place-neighbourhood
-en:Suburb|district
-ru:Район|микрорайон|округ|квартал
+place-suburb|place-quarter|place-neighbourhood|landuse-residential
+en:Suburb|district|quarter|neighbourhood|neighborhood
+ru:Район|микрорайон|квартал
 bg:Район|микрорайон|окръг|квартал
 ar:حي سكني|ضاحية
 cs:Předměstí|městská část|městská zóna
@@ -7814,7 +7814,7 @@ da:Forstad|distrikt
 nl:Buitenwijken|voorstad|wijk
 fi:Esikaupunki
 fr:Banlieue|arrondissement|quartier
-de:Stadtteil|Kreis|Wohnbezirk|Wohnviertel
+de:Stadtteil|Stadtviertel|Wohnviertel|Wohnbezirk|Siedlung
 hi:मुहल्ला|उपनगर
 hu:Kerület
 id:Pinggiran kota
diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv
index da9e25558b..b390169d7d 100644
--- a/data/mapcss-mapping.csv
+++ b/data/mapcss-mapping.csv
@@ -1018,7 +1018,7 @@ deprecated|deprecated;903;x
 railway|subway|lightblue;[railway=subway][colour=lightblue];x;name;int_name;904;railway|subway|tunnel
 deprecated|deprecated;905;x
 railway|subway|lightgreen;[railway=subway][colour=lightgreen];x;name;int_name;906;railway|subway|tunnel
-deprecated|deprecated;907;x
+place|quarter;907;
 railway|subway|violet;[railway=subway][colour=violet];x;name;int_name;908;railway|subway|tunnel
 shop|rental;909;
 railway|subway|grey;[railway=subway][colour=grey];x;name;int_name;910;railway|subway|tunnel
@@ -1073,7 +1073,7 @@ craft|electronics_repair;958;
 shop|appliance;959;
 amenity|casino;960;
 amenity|brothel;961;
-place|neighbourhood;[place=neighbourhood],[place=quarter];;name;int_name;962;
+place|neighbourhood;962;
 place|isolated_dwelling;963;
 historic|wayside_cross;964;
 historic|wayside_shrine;965;
diff --git a/data/strings/types_strings.txt b/data/strings/types_strings.txt
index 19f55bc500..b7530519fa 100644
--- a/data/strings/types_strings.txt
+++ b/data/strings/types_strings.txt
@@ -21832,8 +21832,9 @@
     zh-Hans = 地方
     zh-Hant = 當地
 
-  [type.place.neighbourhood]
-    en = Neighbourhood
+  [type.place.quarter]
+    comment = Named part of a city or town, bigger than place=neighbourhood and smaller than place=suburb (Wiki: https://wiki.openstreetmap.org/wiki/Tag:place%3Dquarter)
+    en = Quarter
     af = Buurt
     ar = حي سكني
     az = Qonşuluq
@@ -21843,9 +21844,9 @@
     da = Kvarter
     de = Stadtviertel
     el = Γειτονιά
-    es = Vecindario
+    es = Barrio
     et = Naabruskond
-    eu = Auzo
+    eu = Auzoa
     fa = محله
     fi = Naapurusto
     fr = Quartier
@@ -21856,25 +21857,72 @@
     it = Quartiere
     ja = 地域
     ko = 동네
+    lv = Apkaime
     mr = शेजार
     nb = Strøk
-    nl = Buurt
+    nl = Wijk
     pl = Sąsiedztwo
     pt = Bairro
-    pt-BR = Vizinhança
+    pt-BR = Sub-bairro
     ro = Cartier
-    ru = Микрорайон
+    ru = Район / Микрорайон
     sk = Štvrť
     sr = Насеље
     sv = Grannskap
     sw = Mtaa
     th = ละแวกบ้าน
-    tr = Mahalle
+    tr = Semt
     uk = Мiкрорайон
     vi = Vùng lân cận
     zh-Hans = 邻里社区
     zh-Hant = 鄰里社區
 
+  [type.place.neighbourhood]
+    comment = Named part of a city, town or suburb, smaller than place=quarter (Wiki: https://wiki.openstreetmap.org/wiki/Neighbourhood)
+    en = Neighbourhood
+    af = Buurt
+    ar = الحي
+    az = Qonşuluq
+    be = Наваколле
+    bg = Съседство
+    ca = Barri
+    cs = Sousedství
+    da = Nabolag
+    de = Siedlung
+    el = Γειτονιά
+    es = Vecindario
+    et = Naabruskond
+    eu = Barrutia
+    fa = محله
+    fi = Naapurusto
+    fr = Quartier
+    he = שְׁכוּנָה
+    hi = अड़ोस-पड़ोस
+    hu = Szomszédság
+    id = Lingkungan
+    it = Quartiere
+    ja = 近隣
+    ko = 이웃
+    lt = Kaimynystė
+    lv = Maza apkaime
+    mr = शेजारी
+    nb = Nabolag
+    nl = Buurt
+    pl = Sąsiedztwo
+    pt = Bairro
+    pt-BR = Vizinhança
+    ro = Cartier
+    ru = Микрорайон / ЖК
+    sk = Susedstvo
+    sv = Grannskapet
+    sw = Ujirani
+    th = ละแวกบ้าน
+    tr = Muhit
+    uk = Сусідство
+    vi = Hàng xóm
+    zh-Hans = 社区
+    zh-Hant = 鄰裡
+
   [type.place.ocean]
     en = Ocean
     af = Oseaan
@@ -22126,6 +22174,7 @@
     zh-Hant = 州
 
   [type.place.suburb]
+    comment = Named part of a city or town, bigger than place=quarter (Wiki: https://wiki.openstreetmap.org/wiki/Tag:place%3Dsuburb)
     en = Suburb
     af = Voorstad
     ar = ضاحية
@@ -22149,6 +22198,7 @@
     it = Quartiere
     ja = 区
     ko = 교외
+    lv = Pilsētas apgabals
     mr = उपनगर
     nb = Forstad
     nl = Buitenwijk
@@ -22156,7 +22206,7 @@
     pt = Subúrbio
     pt-BR = Bairro
     ro = Suburbie
-    ru = Район
+    ru = Район / Пригород
     sk = Predmestie
     sr = Кварт
     sv = Förort
diff --git a/data/styles/default/include/Basemap_label.mapcss b/data/styles/default/include/Basemap_label.mapcss
index 6dfe31f0c2..e5ecac4f97 100644
--- a/data/styles/default/include/Basemap_label.mapcss
+++ b/data/styles/default/include/Basemap_label.mapcss
@@ -341,6 +341,7 @@ node|z13-[place=hamlet]
 
 node|z10-14[place=suburb],
 node|z13-[place=locality],
+node|z13-[place=quarter],
 node|z13-[place=neighbourhood],
 node|z14-[place=farm],
 node|z14-[place=isolated_dwelling],
@@ -348,6 +349,7 @@ node|z17-[landuse=residential],
 {text: name;text-color: @district_label;}
 node|z13-14[place=suburb]::int_name,
 node|z13-[place=locality]::int_name,
+node|z13-[place=quarter]::int_name,
 node|z13-[place=neighbourhood]::int_name,
 node|z14-[place=farm]::int_name,
 node|z14-[place=isolated_dwelling]::int_name,
@@ -362,10 +364,27 @@ node|z12[place=suburb]
 {font-size: 11;}
 node|z12[place=suburb]::int_name
 {font-size: 9;}
-node|z13-14[place=suburb]
+node|z13[place=suburb]
 {font-size: 12;}
-node|z13-14[place=suburb]::int_name
+node|z13[place=suburb]::int_name
 {font-size: 10;}
+node|z14[place=suburb]
+{font-size: 14;}
+node|z14[place=suburb]::int_name
+{font-size: 12;}
+
+node|z13[place=quarter],
+{font-size: 11;}
+node|z13[place=quarter]::int_name,
+{font-size: 9;}
+node|z14[place=quarter],
+{font-size: 12;}
+node|z14[place=quarter]::int_name,
+{font-size: 10;}
+node|z15-[place=quarter],
+{font-size: 14;}
+node|z15-[place=quarter]::int_name,
+{font-size: 12;}
 
 node|z13-14[place=locality],
 node|z13-14[place=neighbourhood],
diff --git a/data/styles/default/include/priorities_4_overlays.prio.txt b/data/styles/default/include/priorities_4_overlays.prio.txt
index d9cb980cdc..c09ae29c54 100644
--- a/data/styles/default/include/priorities_4_overlays.prio.txt
+++ b/data/styles/default/include/priorities_4_overlays.prio.txt
@@ -289,6 +289,7 @@ waterway-waterfall                                  # icon z13- (also has captio
 === 5800
 
 place-hamlet                                        # caption z13-
+place-quarter                                       # caption z13-
 === 5750
 
 place-farm                                          # caption z14-
diff --git a/data/styles/outdoors/include/priorities_4_overlays.prio.txt b/data/styles/outdoors/include/priorities_4_overlays.prio.txt
index 63a973fdb9..4280315246 100644
--- a/data/styles/outdoors/include/priorities_4_overlays.prio.txt
+++ b/data/styles/outdoors/include/priorities_4_overlays.prio.txt
@@ -289,6 +289,7 @@ waterway-waterfall                                  # icon z10- (also has captio
 === 5800
 
 place-hamlet                                        # caption z13-
+place-quarter                                       # caption z13-
 === 5750
 
 place-farm                                          # caption z14-
diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp
index d74d22512a..6a0ce1e34f 100644
--- a/indexer/ftypes_matcher.cpp
+++ b/indexer/ftypes_matcher.cpp
@@ -261,6 +261,7 @@ IsSuburbChecker::IsSuburbChecker()
   Classificator const & c = classif();
   base::StringIL const types[] = {{"landuse", "residential"},
                                   {"place", "neighbourhood"},
+                                  {"place", "quarter"},
                                   {"place", "suburb"}};
   for (auto const & e : types)
     m_types.push_back(c.GetTypeByPath(e));
@@ -268,7 +269,8 @@ IsSuburbChecker::IsSuburbChecker()
   // `types` order should match next indices.
   static_assert(static_cast<size_t>(SuburbType::Residential) == 0, "");
   static_assert(static_cast<size_t>(SuburbType::Neighbourhood) == 1, "");
-  static_assert(static_cast<size_t>(SuburbType::Suburb) == 2, "");
+  static_assert(static_cast<size_t>(SuburbType::Quarter) == 2, "");
+  static_assert(static_cast<size_t>(SuburbType::Suburb) == 3, "");
 }
 
 SuburbType IsSuburbChecker::GetType(uint32_t t) const
diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp
index b2d3e45e8f..22fb1b3889 100644
--- a/indexer/ftypes_matcher.hpp
+++ b/indexer/ftypes_matcher.hpp
@@ -141,6 +141,7 @@ enum class SuburbType
 {
   Residential = 0,
   Neighbourhood,
+  Quarter,
   Suburb,
   Count
 };
diff --git a/search/geocoder.cpp b/search/geocoder.cpp
index a8c207f039..519ecea407 100644
--- a/search/geocoder.cpp
+++ b/search/geocoder.cpp
@@ -1269,6 +1269,7 @@ void Geocoder::GreedilyMatchStreetsWithSuburbs(BaseContext & ctx, CentersFilter
       {
       case ftypes::SuburbType::Residential: radius = kMaxResidentialRadiusM; break;
       case ftypes::SuburbType::Neighbourhood: radius = kMaxNeighbourhoodRadiusM; break;
+      case ftypes::SuburbType::Quarter: radius = kMaxNeighbourhoodRadiusM; break;
       case ftypes::SuburbType::Suburb: radius = kMaxSuburbRadiusM; break;
       default: CHECK(false, ("Bad suburb type:", base::Underlying(suburbType)));
       }