SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
4.3 KB · 49 lines typescript
Raw Blame History
1/**2 * ISO 3166-1 numeric → alpha-3, for the `world-atlas` TopoJSON (Natural Earth 1:110m), whose3 * geometries carry only the numeric code as `id` and an English short `name` in properties.4 * Pure data; covers every id present in `countries-110m.json` plus the territories that appear in5 * ClinicalTrials.gov exports (they have no polygon at 1:110m but keep a stable code).6 */7export const ISO_NUMERIC_TO_ALPHA3: Readonly<Record<string, string>> = {8  '004': 'AFG', '008': 'ALB', '010': 'ATA', '012': 'DZA', '016': 'ASM', '020': 'AND', '024': 'AGO', '028': 'ATG', '031': 'AZE', '032': 'ARG',9  '036': 'AUS', '040': 'AUT', '044': 'BHS', '048': 'BHR', '050': 'BGD', '051': 'ARM', '052': 'BRB', '056': 'BEL', '060': 'BMU', '064': 'BTN',10  '068': 'BOL', '070': 'BIH', '072': 'BWA', '076': 'BRA', '084': 'BLZ', '090': 'SLB', '092': 'VGB', '096': 'BRN', '100': 'BGR', '104': 'MMR',11  '108': 'BDI', '112': 'BLR', '116': 'KHM', '120': 'CMR', '124': 'CAN', '132': 'CPV', '136': 'CYM', '140': 'CAF', '144': 'LKA', '148': 'TCD',12  '152': 'CHL', '156': 'CHN', '158': 'TWN', '170': 'COL', '174': 'COM', '175': 'MYT', '178': 'COG', '180': 'COD', '188': 'CRI', '191': 'HRV',13  '192': 'CUB', '196': 'CYP', '203': 'CZE', '204': 'BEN', '208': 'DNK', '212': 'DMA', '214': 'DOM', '218': 'ECU', '222': 'SLV', '226': 'GNQ',14  '231': 'ETH', '232': 'ERI', '233': 'EST', '234': 'FRO', '238': 'FLK', '242': 'FJI', '246': 'FIN', '250': 'FRA', '254': 'GUF', '258': 'PYF',15  '260': 'ATF', '262': 'DJI', '266': 'GAB', '268': 'GEO', '270': 'GMB', '275': 'PSE', '276': 'DEU', '288': 'GHA', '292': 'GIB', '300': 'GRC',16  '304': 'GRL', '308': 'GRD', '312': 'GLP', '316': 'GUM', '320': 'GTM', '324': 'GIN', '328': 'GUY', '332': 'HTI', '340': 'HND', '344': 'HKG',17  '348': 'HUN', '352': 'ISL', '356': 'IND', '360': 'IDN', '364': 'IRN', '368': 'IRQ', '372': 'IRL', '376': 'ISR', '380': 'ITA', '384': 'CIV',18  '388': 'JAM', '392': 'JPN', '398': 'KAZ', '400': 'JOR', '404': 'KEN', '408': 'PRK', '410': 'KOR', '414': 'KWT', '417': 'KGZ', '418': 'LAO',19  '422': 'LBN', '426': 'LSO', '428': 'LVA', '430': 'LBR', '434': 'LBY', '438': 'LIE', '440': 'LTU', '442': 'LUX', '446': 'MAC', '450': 'MDG',20  '454': 'MWI', '458': 'MYS', '462': 'MDV', '466': 'MLI', '470': 'MLT', '474': 'MTQ', '478': 'MRT', '480': 'MUS', '484': 'MEX', '492': 'MCO',21  '496': 'MNG', '498': 'MDA', '499': 'MNE', '504': 'MAR', '508': 'MOZ', '512': 'OMN', '516': 'NAM', '524': 'NPL', '528': 'NLD', '531': 'CUW',22  '533': 'ABW', '540': 'NCL', '548': 'VUT', '554': 'NZL', '558': 'NIC', '562': 'NER', '566': 'NGA', '578': 'NOR', '580': 'MNP', '586': 'PAK',23  '591': 'PAN', '598': 'PNG', '600': 'PRY', '604': 'PER', '608': 'PHL', '616': 'POL', '620': 'PRT', '624': 'GNB', '626': 'TLS', '630': 'PRI',24  '634': 'QAT', '638': 'REU', '642': 'ROU', '643': 'RUS', '646': 'RWA', '659': 'KNA', '662': 'LCA', '670': 'VCT', '674': 'SMR', '678': 'STP',25  '682': 'SAU', '686': 'SEN', '688': 'SRB', '690': 'SYC', '694': 'SLE', '702': 'SGP', '703': 'SVK', '704': 'VNM', '705': 'SVN', '706': 'SOM',26  '710': 'ZAF', '716': 'ZWE', '724': 'ESP', '728': 'SSD', '729': 'SDN', '732': 'ESH', '740': 'SUR', '748': 'SWZ', '752': 'SWE', '756': 'CHE',27  '760': 'SYR', '762': 'TJK', '764': 'THA', '768': 'TGO', '776': 'TON', '780': 'TTO', '784': 'ARE', '788': 'TUN', '792': 'TUR', '795': 'TKM',28  '800': 'UGA', '804': 'UKR', '807': 'MKD', '818': 'EGY', '826': 'GBR', '834': 'TZA', '840': 'USA', '850': 'VIR', '854': 'BFA', '858': 'URY',29  '860': 'UZB', '862': 'VEN', '882': 'WSM', '887': 'YEM', '894': 'ZMB',30};3132/**33 * Natural Earth draws three polygons with no ISO numeric id (`id` undefined in the TopoJSON):34 * Kosovo (user-assigned XKX, used by the World Bank), Northern Cyprus and Somaliland (no code —35 * they render as "no data"). Keyed by the Natural Earth `name` property.36 */37export const ATLAS_NAME_TO_ALPHA3: Readonly<Record<string, string | null>> = { Kosovo: 'XKX', 'N. Cyprus': null, Somaliland: null };3839/** Alpha-3 for a world-atlas geometry (`id` numeric string, `name` from properties); null when it has no code. */40export function atlasGeometryIso3(id: string | number | null | undefined, name?: string | null): string | null {41  if (id != null && id !== '') {42    const key = String(id).padStart(3, '0');43    const iso = ISO_NUMERIC_TO_ALPHA3[key];44    if (iso) return iso;45  }46  if (name && name in ATLAS_NAME_TO_ALPHA3) return ATLAS_NAME_TO_ALPHA3[name] ?? null;47  return null;48}49