|
| 1 | +# São Tomé and Príncipe Administrative Divisions Fix |
| 2 | + |
| 3 | +## Issue Reference |
| 4 | +**Title:** [Bug]: Sao Tome and Principe missing autonomous region and 6 district |
| 5 | +**Problem:** São Tomé and Príncipe had 2 old provinces instead of the correct 1 autonomous region and 6 districts per ISO 3166-2:ST standard |
| 6 | + |
| 7 | +## Executive Summary |
| 8 | +Successfully replaced the old provincial structure (2 provinces) with the correct administrative divisions (1 autonomous region + 6 districts) for São Tomé and Príncipe, matching the ISO 3166-2:ST standard. Also updated cities to reference the correct districts. |
| 9 | + |
| 10 | +## Country Addressed |
| 11 | +- **Country:** São Tomé and Príncipe (ST) |
| 12 | +- **ISO Code:** ST |
| 13 | +- **Country ID:** 193 |
| 14 | + |
| 15 | +## Changes Made |
| 16 | + |
| 17 | +### Provinces Removed |
| 18 | +**Old structure (removed):** |
| 19 | +1. **São Tomé** (Province) |
| 20 | + - ID: 271 |
| 21 | + - ISO2: S |
| 22 | + - Type: province |
| 23 | + |
| 24 | +2. **Príncipe** (Province) |
| 25 | + - ID: 270 |
| 26 | + - ISO2: P |
| 27 | + - Type: province |
| 28 | + |
| 29 | +### New Administrative Divisions Added |
| 30 | + |
| 31 | +**Districts (6):** |
| 32 | +1. **Água Grande** (ST-01) |
| 33 | + - ID: 5728 |
| 34 | + - ISO2: 01 |
| 35 | + - Type: district |
| 36 | + - Timezone: Africa/Sao_Tome |
| 37 | + - WikiData ID: Q652808 |
| 38 | + - Translations: 13 languages |
| 39 | + |
| 40 | +2. **Cantagalo** (ST-02) |
| 41 | + - ID: 5729 |
| 42 | + - ISO2: 02 |
| 43 | + - Type: district |
| 44 | + - Timezone: Africa/Sao_Tome |
| 45 | + - WikiData ID: Q652819 |
| 46 | + - Translations: 7 languages |
| 47 | + |
| 48 | +3. **Caué** (ST-03) |
| 49 | + - ID: 5730 |
| 50 | + - ISO2: 03 |
| 51 | + - Type: district |
| 52 | + - Timezone: Africa/Sao_Tome |
| 53 | + - WikiData ID: Q652823 |
| 54 | + - Translations: 13 languages |
| 55 | + |
| 56 | +4. **Lemba** (ST-04) |
| 57 | + - ID: 5731 |
| 58 | + - ISO2: 04 |
| 59 | + - Type: district |
| 60 | + - Timezone: Africa/Sao_Tome |
| 61 | + - WikiData ID: Q652810 |
| 62 | + - Translations: 4 languages |
| 63 | + |
| 64 | +5. **Lobata** (ST-05) |
| 65 | + - ID: 5732 |
| 66 | + - ISO2: 05 |
| 67 | + - Type: district |
| 68 | + - Timezone: Africa/Sao_Tome |
| 69 | + - WikiData ID: Q652816 |
| 70 | + - Translations: 12 languages |
| 71 | + |
| 72 | +6. **Mé-Zóchi** (ST-06) |
| 73 | + - ID: 5733 |
| 74 | + - ISO2: 06 |
| 75 | + - Type: district |
| 76 | + - Timezone: Africa/Sao_Tome |
| 77 | + - WikiData ID: Q652812 |
| 78 | + - Translations: 13 languages |
| 79 | + |
| 80 | +**Autonomous Region (1):** |
| 81 | +7. **Príncipe** (ST-P) |
| 82 | + - ID: 5734 |
| 83 | + - ISO2: P |
| 84 | + - Type: autonomous region |
| 85 | + - Timezone: Africa/Sao_Tome |
| 86 | + - WikiData ID: Q652806 |
| 87 | + - Translations: 17 languages |
| 88 | + |
| 89 | +### Cities Updated |
| 90 | +Removed old cities associated with provinces and added proper cities for each district: |
| 91 | + |
| 92 | +1. **São Tomé** - Água Grande District (ST-01) |
| 93 | + - Capital city |
| 94 | + - WikiData: Q3932 |
| 95 | + - 18 translations |
| 96 | + |
| 97 | +2. **Santana** - Cantagalo District (ST-02) |
| 98 | + - WikiData: Q2704421 |
| 99 | + - 13 translations |
| 100 | + |
| 101 | +3. **São João dos Angolares** - Caué District (ST-03) |
| 102 | + - WikiData: Q984427 |
| 103 | + - 10 translations |
| 104 | + |
| 105 | +4. **Neves** - Lemba District (ST-04) |
| 106 | + - WikiData: Q2704454 |
| 107 | + - 6 translations |
| 108 | + |
| 109 | +5. **Guadalupe** - Lobata District (ST-05) |
| 110 | + - WikiData: Q2704428 |
| 111 | + - 16 translations |
| 112 | + |
| 113 | +6. **Trindade** - Mé-Zóchi District (ST-06) |
| 114 | + - WikiData: Q1635802 |
| 115 | + - 13 translations |
| 116 | + |
| 117 | +7. **Santo António** - Príncipe Autonomous Region (ST-P) |
| 118 | + - WikiData: Q973656 |
| 119 | + - 13 translations |
| 120 | + |
| 121 | +## Before/After Counts |
| 122 | + |
| 123 | +### States |
| 124 | +- **Before:** 2 provinces (São Tomé, Príncipe) |
| 125 | +- **After:** 7 administrative divisions (6 districts + 1 autonomous region) |
| 126 | +- **Change:** Replaced 2 provinces with 7 correct administrative divisions |
| 127 | + |
| 128 | +### Cities |
| 129 | +- **Before:** 5 cities (incorrectly named as districts, referencing old provinces) |
| 130 | +- **After:** 7 cities (properly assigned to correct districts) |
| 131 | +- **Change:** Removed old data, added proper cities for each district |
| 132 | + |
| 133 | +## Validation Steps and Results |
| 134 | + |
| 135 | +### 1. Verified State Count |
| 136 | +```bash |
| 137 | +# Check state count in JSON |
| 138 | +jq '.[] | select(.country_code == "ST") | .name' contributions/states/states.json |
| 139 | +# Result: 7 administrative divisions (Água Grande, Cantagalo, Caué, Lemba, Lobata, Mé-Zóchi, Príncipe) |
| 140 | +``` |
| 141 | + |
| 142 | +### 2. Verified ISO 3166-2 Codes |
| 143 | +```bash |
| 144 | +jq '.[] | select(.country_code == "ST") | {name, iso3166_2, type}' contributions/states/states.json |
| 145 | +``` |
| 146 | +Result: |
| 147 | +- ST-01: Água Grande (district) ✓ |
| 148 | +- ST-02: Cantagalo (district) ✓ |
| 149 | +- ST-03: Caué (district) ✓ |
| 150 | +- ST-04: Lemba (district) ✓ |
| 151 | +- ST-05: Lobata (district) ✓ |
| 152 | +- ST-06: Mé-Zóchi (district) ✓ |
| 153 | +- ST-P: Príncipe (autonomous region) ✓ |
| 154 | + |
| 155 | +### 3. Verified Cities Assignment |
| 156 | +```bash |
| 157 | +jq '.[] | {name, state_code, timezone}' contributions/cities/ST.json |
| 158 | +``` |
| 159 | +All 7 cities properly assigned to their districts with correct state codes. |
| 160 | + |
| 161 | +### 4. Verified Timezone Enrichment |
| 162 | +All states and cities have timezone: `Africa/Sao_Tome` ✓ |
| 163 | + |
| 164 | +### 5. Verified Translation Enrichment |
| 165 | +- States: All have translations (4-17 languages) |
| 166 | +- Cities: All have translations (6-18 languages) |
| 167 | + |
| 168 | +### 6. Verified WikiData IDs |
| 169 | +All states and cities have valid WikiData IDs ✓ |
| 170 | + |
| 171 | +## Data Samples |
| 172 | + |
| 173 | +### State Entry (states.json) |
| 174 | +```json |
| 175 | +{ |
| 176 | + "id": 5728, |
| 177 | + "name": "Água Grande", |
| 178 | + "country_id": 193, |
| 179 | + "country_code": "ST", |
| 180 | + "iso2": "01", |
| 181 | + "iso3166_2": "ST-01", |
| 182 | + "type": "district", |
| 183 | + "native": "Água Grande", |
| 184 | + "latitude": "0.33019240", |
| 185 | + "longitude": "6.73334300", |
| 186 | + "timezone": "Africa/Sao_Tome", |
| 187 | + "translations": { |
| 188 | + "ar": "مقاطعة أجوا غراندي", |
| 189 | + "de": "Água Grande", |
| 190 | + "es": "Distrito de Água Grande", |
| 191 | + "fr": "District d'Água Grande", |
| 192 | + "it": "Distretto di Água Grande", |
| 193 | + "ja": "アグア・グランデ県", |
| 194 | + "ko": "아구아그란데구", |
| 195 | + "nl": "Água Grande", |
| 196 | + "pl": "Água Grande", |
| 197 | + "pt": "Água Grande", |
| 198 | + "ru": "Агуа-Гранде", |
| 199 | + "tr": "Água Grande", |
| 200 | + "zh": "大水区" |
| 201 | + }, |
| 202 | + "wikiDataId": "Q652808" |
| 203 | +} |
| 204 | +``` |
| 205 | + |
| 206 | +### Autonomous Region Entry (states.json) |
| 207 | +```json |
| 208 | +{ |
| 209 | + "id": 5734, |
| 210 | + "name": "Príncipe", |
| 211 | + "country_id": 193, |
| 212 | + "country_code": "ST", |
| 213 | + "iso2": "P", |
| 214 | + "iso3166_2": "ST-P", |
| 215 | + "type": "autonomous region", |
| 216 | + "native": "Príncipe", |
| 217 | + "latitude": "1.61393810", |
| 218 | + "longitude": "7.40569280", |
| 219 | + "timezone": "Africa/Sao_Tome", |
| 220 | + "translations": { |
| 221 | + "ar": "برينسيبي", |
| 222 | + "de": "Príncipe", |
| 223 | + "es": "Isla de Príncipe", |
| 224 | + "fr": "Île de Príncipe", |
| 225 | + "hi": "प्रिंसिपे", |
| 226 | + "it": "Isola di Príncipe", |
| 227 | + "ja": "プリンシペ島", |
| 228 | + "ko": "프린시페섬", |
| 229 | + "nl": "Príncipe", |
| 230 | + "pl": "Wyspa Książęca", |
| 231 | + "pt": "Príncipe", |
| 232 | + "ru": "Принсипи", |
| 233 | + "tr": "Príncipe", |
| 234 | + "uk": "Прінсіпі", |
| 235 | + "vi": "Príncipe", |
| 236 | + "zh": "普林西比岛" |
| 237 | + }, |
| 238 | + "wikiDataId": "Q652806" |
| 239 | +} |
| 240 | +``` |
| 241 | + |
| 242 | +### City Entry (ST.json) |
| 243 | +```json |
| 244 | +{ |
| 245 | + "id": 157068, |
| 246 | + "name": "São Tomé", |
| 247 | + "state_id": 5728, |
| 248 | + "state_code": "01", |
| 249 | + "country_id": 193, |
| 250 | + "country_code": "ST", |
| 251 | + "latitude": "0.33654000", |
| 252 | + "longitude": "6.72732000", |
| 253 | + "native": "São Tomé", |
| 254 | + "timezone": "Africa/Sao_Tome", |
| 255 | + "translations": { |
| 256 | + "ar": "ساو تومي", |
| 257 | + "bn": "সাঁউ তুমে", |
| 258 | + "de": "São Tomé", |
| 259 | + "es": "Santo Tomé", |
| 260 | + "fr": "Sao Tomé", |
| 261 | + "hi": "साओ टोमे", |
| 262 | + "id": "São Tomé", |
| 263 | + "it": "São Tomé", |
| 264 | + "ja": "サントメ", |
| 265 | + "ko": "상투메", |
| 266 | + "nl": "São Tomé", |
| 267 | + "pl": "Sao Tome", |
| 268 | + "pt": "São Tomé", |
| 269 | + "ru": "Сан-Томе", |
| 270 | + "tr": "Sao Tome", |
| 271 | + "uk": "Сан-Томе", |
| 272 | + "vi": "São Tomé", |
| 273 | + "zh": "圣多美" |
| 274 | + }, |
| 275 | + "wikiDataId": "Q3932", |
| 276 | + "created_at": "2025-11-18T04:26:59", |
| 277 | + "updated_at": "2025-11-18T04:28:03", |
| 278 | + "flag": 1 |
| 279 | +} |
| 280 | +``` |
| 281 | + |
| 282 | +## Technical Implementation |
| 283 | + |
| 284 | +### Files Modified |
| 285 | +1. `contributions/states/states.json` - Removed 2 old provinces, added 7 new administrative divisions |
| 286 | +2. `contributions/cities/ST.json` - Removed 5 old city entries, added 7 new cities |
| 287 | + |
| 288 | +### Workflow Followed |
| 289 | +1. Removed old ST provinces from `contributions/states/states.json` |
| 290 | +2. Added 7 new administrative divisions (without IDs) |
| 291 | +3. Cleared `contributions/cities/ST.json` temporarily |
| 292 | +4. Ran `import_json_to_mysql.py` to import states and auto-assign IDs |
| 293 | +5. Ran `sync_mysql_to_json.py` to sync IDs back to JSON |
| 294 | +6. Added 7 cities to `contributions/cities/ST.json` with correct state_ids |
| 295 | +7. Ran `import_json_to_mysql.py` again to import cities |
| 296 | +8. Ran `add_timezones.py` to add timezones to both states and cities |
| 297 | +9. Ran `sync_mysql_to_json.py` to sync timezones back to JSON |
| 298 | +10. Ran `translation_enricher.py` for cities (added 7 cities with translations) |
| 299 | +11. Ran `translation_enricher.py` for states (added 7 states with translations) |
| 300 | + |
| 301 | +### Commands Used |
| 302 | +```bash |
| 303 | +# Import JSON to MySQL (generates IDs) |
| 304 | +python3 bin/scripts/sync/import_json_to_mysql.py --host localhost --user root --password root --database world |
| 305 | + |
| 306 | +# Sync MySQL back to JSON (updates IDs and timezones) |
| 307 | +python3 bin/scripts/sync/sync_mysql_to_json.py --host localhost --user root --password root --database world |
| 308 | + |
| 309 | +# Add timezones to states and cities |
| 310 | +python3 bin/scripts/validation/add_timezones.py --host localhost --user root --password root --database world --table both |
| 311 | + |
| 312 | +# Add translations to cities |
| 313 | +python3 bin/scripts/validation/translation_enricher.py --file contributions/cities/ST.json --type city |
| 314 | + |
| 315 | +# Add translations to states |
| 316 | +python3 bin/scripts/validation/translation_enricher.py --file contributions/states/states.json --type state --country-code ST |
| 317 | +``` |
| 318 | + |
| 319 | +## References |
| 320 | +- **ISO 3166-2:ST Standard:** https://www.iso.org/obp/ui#iso:code:3166:ST |
| 321 | +- **Wikipedia - Districts of São Tomé and Príncipe:** https://en.wikipedia.org/wiki/Districts_of_São_Tomé_and_Príncipe |
| 322 | +- **Wikipedia - Autonomous Region of Príncipe:** https://en.wikipedia.org/wiki/Autonomous_Region_of_Príncipe |
| 323 | +- **WikiData - Água Grande:** https://www.wikidata.org/wiki/Q652808 |
| 324 | +- **WikiData - Cantagalo:** https://www.wikidata.org/wiki/Q652819 |
| 325 | +- **WikiData - Caué:** https://www.wikidata.org/wiki/Q652823 |
| 326 | +- **WikiData - Lemba:** https://www.wikidata.org/wiki/Q652810 |
| 327 | +- **WikiData - Lobata:** https://www.wikidata.org/wiki/Q652816 |
| 328 | +- **WikiData - Mé-Zóchi:** https://www.wikidata.org/wiki/Q652812 |
| 329 | +- **WikiData - Príncipe:** https://www.wikidata.org/wiki/Q652806 |
| 330 | + |
| 331 | +## Compliance |
| 332 | +✅ Matches ISO 3166-2:ST standard (1 autonomous region + 6 districts) |
| 333 | +✅ All administrative divisions have proper type designation |
| 334 | +✅ All entries have proper WikiData IDs |
| 335 | +✅ Follows existing data structure and formatting |
| 336 | +✅ Proper timezone (Africa/Sao_Tome) assigned to all entries |
| 337 | +✅ Coordinates verified from Wikipedia sources |
| 338 | +✅ All districts have representative cities |
| 339 | +✅ Comprehensive translations in 4-18 languages per entry |
0 commit comments