|
2 | 2 | SCENE 2: 3D GLOBE |
3 | 3 | ============================================ */ |
4 | 4 |
|
5 | | -const GLOBE_COUNTRY_NAME_ALIASES = { |
6 | | - 'bolivia plurinational state of': 'bolivia', |
7 | | - 'bosnia and herz': 'bosnia and herzegovina', |
8 | | - 'brunei darussalam': 'brunei', |
9 | | - 'cape verde': 'cabo verde', |
10 | | - 'central african rep': 'central african republic', |
11 | | - 'czech republic': 'czechia', |
12 | | - 'dem rep congo': 'democratic republic of the congo', |
13 | | - 'dominican rep': 'dominican republic', |
14 | | - 'eq guinea': 'equatorial guinea', |
15 | | - 'iran islamic republic of': 'iran', |
16 | | - 'ivory coast': 'cote d ivoire', |
17 | | - 'lao peoples democratic republic': 'laos', |
18 | | - 'macedonia': 'north macedonia', |
19 | | - 'micronesia federated states of': 'micronesia', |
20 | | - 'moldova': 'republic of moldova', |
21 | | - 'netherlands kingdom of the': 'netherlands', |
22 | | - 'north korea': 'democratic peoples republic of korea', |
23 | | - 'republic of congo': 'congo', |
24 | | - 'republic of korea': 'south korea', |
25 | | - 'russian federation': 'russia', |
26 | | - 's korea': 'south korea', |
27 | | - 's sudan': 'south sudan', |
28 | | - 'solomon is': 'solomon islands', |
29 | | - 'state of palestine': 'palestine', |
30 | | - 'swaziland': 'eswatini', |
31 | | - 'syrian arab republic': 'syria', |
32 | | - 'tanzania': 'united republic of tanzania', |
33 | | - 'turkiye': 'turkey', |
34 | | - 'united kingdom of great britain and northern ireland': 'united kingdom', |
35 | | - 'venezuela bolivarian republic of': 'venezuela', |
36 | | - 'viet nam': 'vietnam' |
37 | | -}; |
38 | | - |
39 | | -// ISO_ALIASES and canonicalIso() are defined in data.js (loaded first) |
| 5 | +// GLOBE_COUNTRY_NAME_ALIASES, baseNormalize(), canonicalIso() defined in data.js (loaded first) |
40 | 6 | const GLOBE_ISO_CENTER_ALIASES = ISO_ALIASES; |
41 | 7 |
|
42 | 8 | const GLOBE_FALLBACK_CENTERS = { |
@@ -335,7 +301,7 @@ const Scene2 = { |
335 | 301 | ? getDisasterTypeLabel(this.selectedType) |
336 | 302 | : 'No matching type'; |
337 | 303 | const accent = hasMatches ? getDisasterColor(this.selectedType) : '#97AEC4'; |
338 | | - const displayName = country?.properties?.name || stats.country; |
| 304 | + const displayName = normalizeCountryName(stats.country || country?.properties?.name); |
339 | 305 |
|
340 | 306 | return ` |
341 | 307 | <div style="background: rgba(13,17,23,0.95); padding: 12px; border-radius: 8px; border: 1px solid ${accent};"> |
@@ -445,15 +411,8 @@ const Scene2 = { |
445 | 411 | }, |
446 | 412 |
|
447 | 413 | normalizeCountryName(name = '') { |
448 | | - const normalized = String(name) |
449 | | - .normalize('NFD') |
450 | | - .replace(/[\u0300-\u036f]/g, '') |
451 | | - .toLowerCase() |
452 | | - .replace(/[^a-z0-9]+/g, ' ') |
453 | | - .replace(/\s+/g, ' ') |
454 | | - .trim(); |
455 | | - |
456 | | - return GLOBE_COUNTRY_NAME_ALIASES[normalized] || normalized; |
| 414 | + const key = baseNormalize(name); |
| 415 | + return GLOBE_COUNTRY_NAME_ALIASES[key] || key; |
457 | 416 | }, |
458 | 417 |
|
459 | 418 | getInternalCountryCenter(feature) { |
@@ -556,7 +515,7 @@ const Scene2 = { |
556 | 515 | const color = this.selectedType === 'all' ? '#1E3A8A' : getDisasterColor(this.selectedType); |
557 | 516 |
|
558 | 517 | return countryGroups.map(({ iso, events: countryEvents, center }) => { |
559 | | - const country = COUNTRY_STATS[iso]?.country || countryEvents[0]?.country || iso; |
| 518 | + const country = normalizeCountryName(COUNTRY_STATS[iso]?.country || countryEvents[0]?.country) || iso; |
560 | 519 | const count = countryEvents.length; |
561 | 520 | const deaths = d3.sum(countryEvents, d => d.deaths); |
562 | 521 |
|
@@ -923,7 +882,7 @@ const Scene2 = { |
923 | 882 |
|
924 | 883 | return { |
925 | 884 | iso, |
926 | | - country: stats.country, |
| 885 | + country: normalizeCountryName(stats.country), |
927 | 886 | count: countryEvents.length, |
928 | 887 | deaths: d3.sum(countryEvents, d => d.deaths), |
929 | 888 | damage: d3.sum(countryEvents, d => d.damage) |
|
0 commit comments