From 5d210b2517b6432dc4fb32dae39a7d40b6827542 Mon Sep 17 00:00:00 2001 From: Maaike Date: Fri, 24 Nov 2023 17:09:21 +0100 Subject: [PATCH 1/3] updates to improve support for TLD --- config-templates/countries.json | 759 ++++++++++------------- config-templates/metadata-synop.yml.tmpl | 4 +- config-templates/metadata-temp.yml.tmpl | 4 +- docs/source/user/setup.rst | 7 +- wis2box-create-config.py | 133 +++- 5 files changed, 437 insertions(+), 470 deletions(-) diff --git a/config-templates/countries.json b/config-templates/countries.json index bda0b75fc..ad8317d17 100644 --- a/config-templates/countries.json +++ b/config-templates/countries.json @@ -1,6 +1,6 @@ { "countries": { - "fji": { + "fj": { "name": "Fiji", "bbox": { "minx": -180.0, @@ -9,7 +9,7 @@ "maxy": -12.2613866 } }, - "tza": { + "tz": { "name": "Tanzania", "bbox": { "minx": 29.3269773, @@ -18,16 +18,7 @@ "maxy": -0.9854812 } }, - "esh": { - "name": "W. Sahara", - "bbox": { - "minx": 15.5907052, - "miny": 60.3798713, - "maxx": 15.6024238, - "maxy": 60.3833937 - } - }, - "can": { + "ca": { "name": "Canada", "bbox": { "minx": -141.00275, @@ -36,7 +27,7 @@ "maxy": 83.3362128 } }, - "usa": { + "us": { "name": "United States of America", "bbox": { "minx": -180.0, @@ -45,7 +36,7 @@ "maxy": 71.5889534 } }, - "kaz": { + "kz": { "name": "Kazakhstan", "bbox": { "minx": 46.4932179, @@ -54,7 +45,7 @@ "maxy": 55.4421701 } }, - "uzb": { + "uz": { "name": "Uzbekistan", "bbox": { "minx": 55.9985531, @@ -63,7 +54,7 @@ "maxy": 45.5906784 } }, - "png": { + "pg": { "name": "Papua New Guinea", "bbox": { "minx": 140.8416553, @@ -72,7 +63,7 @@ "maxy": -0.5573576 } }, - "idn": { + "id": { "name": "Indonesia", "bbox": { "minx": 94.7717124, @@ -81,7 +72,7 @@ "maxy": 6.2744496 } }, - "arg": { + "ar": { "name": "Argentina", "bbox": { "minx": -73.5605371, @@ -90,7 +81,7 @@ "maxy": -21.7808568 } }, - "chl": { + "cl": { "name": "Chile", "bbox": { "minx": -109.6795789, @@ -99,7 +90,7 @@ "maxy": -17.4983832 } }, - "som": { + "so": { "name": "Somalia", "bbox": { "minx": 40.98918, @@ -108,7 +99,7 @@ "maxy": 12.1889121 } }, - "ken": { + "ke": { "name": "Kenya", "bbox": { "minx": 33.9096888, @@ -117,16 +108,16 @@ "maxy": 4.62 } }, - "sdn": { + "sd": { "name": "Sudan", "bbox": { - "minx": 21.8143904, - "miny": 8.685278, - "maxx": 39.0576252, - "maxy": 22.224918 + "minx": 5.5, + "miny": 9.9, + "maxx": 7.5, + "maxy": 11.9 } }, - "tcd": { + "td": { "name": "Chad", "bbox": { "minx": 13.47348, @@ -135,7 +126,7 @@ "maxy": 23.4507957 } }, - "hti": { + "ht": { "name": "Haiti", "bbox": { "minx": -75.2384618, @@ -144,16 +135,16 @@ "maxy": 20.2911852 } }, - "rus": { + "ru": { "name": "Russia", "bbox": { - "minx": -180.0, - "miny": 41.1850968, - "maxx": 180.0, - "maxy": 82.0586232 + "minx": -84.424049, + "miny": 40.226398, + "maxx": -84.388279, + "maxy": 40.241081 } }, - "bhs": { + "bs": { "name": "Bahamas", "bbox": { "minx": -80.7001941, @@ -162,43 +153,25 @@ "maxy": 27.4734551 } }, - "flk": { - "name": "Falkland Is.", - "bbox": { - "minx": -3.0732108, - "miny": 56.4514328, - "maxx": -3.0731354, - "maxy": 56.4518577 - } - }, - "nor": { + "no": { "name": "Norway", "bbox": { - "minx": -9.6846279, - "miny": -54.654, - "maxx": 34.6889114, - "maxy": 81.0280176 + "minx": 4.0875274, + "miny": 57.7590052, + "maxx": 31.7615929, + "maxy": 71.3848787 } }, - "grl": { + "gl": { "name": "Greenland", "bbox": { - "minx": -74.1250416, - "miny": 59.515387, - "maxx": -10.0288759, - "maxy": 83.875172 - } - }, - "atf": { - "name": "Fr. S. Antarctic Lands", - "bbox": { - "minx": 70.1274483, - "miny": -49.7098647, - "maxx": 70.1474483, - "maxy": -49.6898647 + "minx": -73.0263201, + "miny": 59.9737205, + "maxx": -11.3511087, + "maxy": 83.6608453 } }, - "tls": { + "tl": { "name": "Timor-Leste", "bbox": { "minx": 124.0339863, @@ -207,7 +180,7 @@ "maxy": -8.1161123 } }, - "zaf": { + "za": { "name": "South Africa", "bbox": { "minx": 16.3335213, @@ -216,7 +189,7 @@ "maxy": -22.1250301 } }, - "lso": { + "ls": { "name": "Lesotho", "bbox": { "minx": 27.0113763, @@ -225,16 +198,16 @@ "maxy": -28.5705652 } }, - "mex": { + "mx": { "name": "Mexico", "bbox": { - "minx": -118.599188, - "miny": 14.3886243, - "maxx": -86.493266, - "maxy": 32.7186679 + "minx": -99.3649242, + "miny": 19.0487187, + "maxx": -98.9403028, + "maxy": 19.5927572 } }, - "ury": { + "uy": { "name": "Uruguay", "bbox": { "minx": -58.4947729, @@ -243,16 +216,16 @@ "maxy": -30.0853962 } }, - "bra": { + "br": { "name": "Brazil", "bbox": { "minx": -73.9830625, - "miny": -33.8689056, + "miny": -33.8694284, "maxx": -28.6289646, "maxy": 5.2695808 } }, - "bol": { + "bo": { "name": "Bolivia", "bbox": { "minx": -69.6450073, @@ -261,7 +234,7 @@ "maxy": -9.6689438 } }, - "per": { + "pe": { "name": "Peru", "bbox": { "minx": -84.6356535, @@ -270,7 +243,7 @@ "maxy": -0.0392818 } }, - "col": { + "co": { "name": "Colombia", "bbox": { "minx": -82.1243611, @@ -279,7 +252,7 @@ "maxy": 16.0495518 } }, - "pan": { + "pa": { "name": "Panama", "bbox": { "minx": -83.0517245, @@ -288,7 +261,7 @@ "maxy": 9.8469028 } }, - "cri": { + "cr": { "name": "Costa Rica", "bbox": { "minx": -87.2951397, @@ -297,7 +270,7 @@ "maxy": 11.2195684 } }, - "nic": { + "ni": { "name": "Nicaragua", "bbox": { "minx": -87.8958171, @@ -306,7 +279,7 @@ "maxy": 15.0902778 } }, - "hnd": { + "hn": { "name": "Honduras", "bbox": { "minx": -89.3568207, @@ -315,7 +288,7 @@ "maxy": 17.619522 } }, - "slv": { + "sv": { "name": "El Salvador", "bbox": { "minx": -90.2089183, @@ -324,7 +297,7 @@ "maxy": 14.4510488 } }, - "gtm": { + "gt": { "name": "Guatemala", "bbox": { "minx": -92.3743889, @@ -333,7 +306,7 @@ "maxy": 17.8165947 } }, - "blz": { + "bz": { "name": "Belize", "bbox": { "minx": -89.2275905, @@ -342,7 +315,7 @@ "maxy": 18.4959143 } }, - "ven": { + "ve": { "name": "Venezuela", "bbox": { "minx": -73.3529632, @@ -351,7 +324,7 @@ "maxy": 15.9158431 } }, - "guy": { + "gy": { "name": "Guyana", "bbox": { "minx": -61.3827449, @@ -360,7 +333,7 @@ "maxy": 8.6038842 } }, - "sur": { + "sr": { "name": "Suriname", "bbox": { "minx": -58.0711851, @@ -369,7 +342,7 @@ "maxy": 6.2160842 } }, - "fra": { + "fr": { "name": "France", "bbox": { "minx": -178.3873749, @@ -378,7 +351,7 @@ "maxy": 51.3055721 } }, - "ecu": { + "ec": { "name": "Ecuador", "bbox": { "minx": -92.2072392, @@ -387,7 +360,7 @@ "maxy": 1.8835964 } }, - "pri": { + "pr": { "name": "Puerto Rico", "bbox": { "minx": -68.1109184, @@ -396,7 +369,7 @@ "maxy": 18.6663822 } }, - "jam": { + "jm": { "name": "Jamaica", "bbox": { "minx": -78.5782366, @@ -405,7 +378,7 @@ "maxy": 18.7256394 } }, - "cub": { + "cu": { "name": "Cuba", "bbox": { "minx": -85.1679702, @@ -414,7 +387,7 @@ "maxy": 23.4816972 } }, - "zwe": { + "zw": { "name": "Zimbabwe", "bbox": { "minx": 25.2373, @@ -423,7 +396,7 @@ "maxy": -15.6097033 } }, - "bwa": { + "bw": { "name": "Botswana", "bbox": { "minx": 19.9986486, @@ -432,7 +405,7 @@ "maxy": -17.778137 } }, - "nam": { + "na": { "name": "Namibia", "bbox": { "minx": 11.5280384, @@ -441,7 +414,7 @@ "maxy": -16.9635105 } }, - "sen": { + "sn": { "name": "Senegal", "bbox": { "minx": -17.7498686, @@ -450,7 +423,7 @@ "maxy": 16.6919712 } }, - "mli": { + "ml": { "name": "Mali", "bbox": { "minx": -12.2402835, @@ -459,7 +432,7 @@ "maxy": 25.001084 } }, - "mrt": { + "mr": { "name": "Mauritania", "bbox": { "minx": -17.2380959, @@ -468,7 +441,7 @@ "maxy": 27.314942 } }, - "ben": { + "bj": { "name": "Benin", "bbox": { "minx": 0.776667, @@ -477,16 +450,7 @@ "maxy": 12.4092028 } }, - "ner": { - "name": "Niger", - "bbox": { - "minx": 0.1689653, - "miny": 11.6936071, - "maxx": 15.996667, - "maxy": 23.517178 - } - }, - "nga": { + "ng": { "name": "Nigeria", "bbox": { "minx": 2.676932, @@ -495,7 +459,7 @@ "maxy": 13.885645 } }, - "cmr": { + "cm": { "name": "Cameroon", "bbox": { "minx": 8.3822176, @@ -504,7 +468,7 @@ "maxy": 13.083333 } }, - "tgo": { + "tg": { "name": "Togo", "bbox": { "minx": -0.1439746, @@ -513,7 +477,7 @@ "maxy": 11.1395102 } }, - "gha": { + "gh": { "name": "Ghana", "bbox": { "minx": -3.260786, @@ -522,7 +486,7 @@ "maxy": 11.1748562 } }, - "civ": { + "ci": { "name": "C\u00f4te d'Ivoire", "bbox": { "minx": -8.6014675, @@ -531,7 +495,7 @@ "maxy": 10.740197 } }, - "gin": { + "gn": { "name": "Guinea", "bbox": { "minx": -15.5680508, @@ -540,7 +504,7 @@ "maxy": 12.67563 } }, - "gnb": { + "gw": { "name": "Guinea-Bissau", "bbox": { "minx": -16.897501, @@ -549,7 +513,7 @@ "maxy": 12.6862384 } }, - "lbr": { + "lr": { "name": "Liberia", "bbox": { "minx": -11.6080764, @@ -558,7 +522,7 @@ "maxy": 8.5519251 } }, - "sle": { + "sl": { "name": "Sierra Leone", "bbox": { "minx": -13.5003389, @@ -567,7 +531,7 @@ "maxy": 9.999973 } }, - "bfa": { + "bf": { "name": "Burkina Faso", "bbox": { "minx": -5.513207, @@ -576,7 +540,7 @@ "maxy": 15.0840044 } }, - "cog": { + "cg": { "name": "Congo", "bbox": { "minx": 12.039074, @@ -585,25 +549,25 @@ "maxy": 5.3920026 } }, - "gab": { + "ga": { "name": "Gabon", "bbox": { "minx": 8.5002246, - "miny": -4.1012261, + "miny": -4.126909, "maxx": 14.539444, "maxy": 2.3192896 } }, - "zmb": { + "zm": { "name": "Zambia", "bbox": { "minx": 21.9993509, "miny": -18.0762145, - "maxx": 33.7095027, + "maxx": 33.7088556, "maxy": -8.2749338 } }, - "mwi": { + "mw": { "name": "Malawi", "bbox": { "minx": 32.6718589, @@ -612,7 +576,7 @@ "maxy": -9.368301 } }, - "moz": { + "mz": { "name": "Mozambique", "bbox": { "minx": 30.2121663, @@ -621,7 +585,7 @@ "maxy": -10.3252149 } }, - "swz": { + "sz": { "name": "eSwatini", "bbox": { "minx": 30.7908, @@ -630,7 +594,7 @@ "maxy": -25.71876 } }, - "ago": { + "ao": { "name": "Angola", "bbox": { "minx": 11.4609793, @@ -639,7 +603,7 @@ "maxy": -4.3458006 } }, - "bdi": { + "bi": { "name": "Burundi", "bbox": { "minx": 29.000716, @@ -648,25 +612,25 @@ "maxy": -2.3096796 } }, - "isr": { + "il": { "name": "Israel", "bbox": { - "minx": 34.2674994, - "miny": 29.4533796, - "maxx": 35.8950234, - "maxy": 33.3356317 + "minx": 27.8594762, + "miny": 23.8124247, + "maxx": 41.8594762, + "maxy": 37.8124247 } }, - "lbn": { + "lb": { "name": "Lebanon", "bbox": { - "minx": 34.8825667, - "miny": 33.0550325, - "maxx": 36.625, - "maxy": 34.6921448 + "minx": -76.6790862, + "miny": 40.1957824, + "maxx": -76.1514553, + "maxy": 40.555157 } }, - "mdg": { + "mg": { "name": "Madagascar", "bbox": { "minx": 42.9680076, @@ -675,16 +639,16 @@ "maxy": -11.732889 } }, - "pse": { + "ps": { "name": "Palestine", "bbox": { - "minx": 34.0546906, - "miny": 31.2201289, - "maxx": 35.5403583, - "maxy": 32.5489422 + "minx": -95.7242641, + "miny": 31.6952698, + "maxx": -95.5677611, + "maxy": 31.8084308 } }, - "gmb": { + "gm": { "name": "Gambia", "bbox": { "minx": -17.0223778, @@ -693,16 +657,16 @@ "maxy": 13.8253137 } }, - "tun": { + "tn": { "name": "Tunisia", "bbox": { - "minx": 7.5219807, - "miny": 30.229061, - "maxx": 11.8801133, - "maxy": 37.7612052 + "minx": 10.0037899, + "miny": 36.6925111, + "maxx": 10.3548094, + "maxy": 36.9430196 } }, - "dza": { + "dz": { "name": "Algeria", "bbox": { "minx": -8.668908, @@ -711,16 +675,16 @@ "maxy": 37.2962055 } }, - "jor": { + "jo": { "name": "Jordan", "bbox": { - "minx": 34.8844372, - "miny": 29.183401, - "maxx": 39.3012981, - "maxy": 33.3750617 + "minx": 35.5189087, + "miny": 31.758258, + "maxx": 35.6309601, + "maxy": 33.1956046 } }, - "are": { + "ae": { "name": "United Arab Emirates", "bbox": { "minx": 51.4160714, @@ -729,43 +693,43 @@ "maxy": 26.1517219 } }, - "qat": { + "qa": { "name": "Qatar", "bbox": { - "minx": 50.5675, - "miny": 24.4707534, - "maxx": 52.638011, - "maxy": 26.434565 + "minx": 47.4861085, + "miny": 39.0874426, + "maxx": 47.5261085, + "maxy": 39.1274426 } }, - "kwt": { + "kw": { "name": "Kuwait", "bbox": { - "minx": 46.5526837, - "miny": 28.5243622, - "maxx": 49.0046809, - "maxy": 30.1038082 + "minx": 47.8134174, + "miny": 29.2196532, + "maxx": 48.1334174, + "maxy": 29.5396532 } }, - "irq": { + "iq": { "name": "Iraq", "bbox": { - "minx": 38.7936719, + "minx": 38.7926388, "miny": 29.0585661, "maxx": 49.1067706, "maxy": 37.3806687 } }, - "omn": { + "om": { "name": "Oman", "bbox": { - "minx": 52.0000004, - "miny": 16.4649608, - "maxx": 60.054577, - "maxy": 26.7026737 + "minx": 26.9046399, + "miny": 42.2479001, + "maxx": 26.9446399, + "maxy": 42.2879001 } }, - "vut": { + "vu": { "name": "Vanuatu", "bbox": { "minx": 166.3355255, @@ -774,16 +738,16 @@ "maxy": -12.8713777 } }, - "khm": { + "kh": { "name": "Cambodia", "bbox": { - "minx": 102.3338282, - "miny": 9.4110961, - "maxx": 107.6276788, - "maxy": 14.6904224 + "minx": -73.1593675, + "miny": 3.9667059, + "maxx": -73.1393675, + "maxy": 3.9867059 } }, - "tha": { + "th": { "name": "Thailand", "bbox": { "minx": 97.3438072, @@ -792,25 +756,16 @@ "maxy": 20.4648337 } }, - "lao": { - "name": "Laos", - "bbox": { - "minx": 100.0843247, - "miny": 13.9096752, - "maxx": 107.6349989, - "maxy": 22.5086717 - } - }, - "mmr": { + "mm": { "name": "Myanmar", "bbox": { - "minx": 92.1729181, - "miny": 9.526084, - "maxx": 101.1700796, - "maxy": 28.547835 + "minx": 96.4514194, + "miny": 22.0451803, + "maxx": 96.4515194, + "maxy": 22.0452803 } }, - "vnm": { + "vn": { "name": "Vietnam", "bbox": { "minx": 102.1438643, @@ -819,7 +774,7 @@ "maxy": 23.3926918 } }, - "prk": { + "kp": { "name": "North Korea", "bbox": { "minx": 124.092355, @@ -828,7 +783,7 @@ "maxy": 43.0089642 } }, - "kor": { + "kr": { "name": "South Korea", "bbox": { "minx": 124.3727348, @@ -837,16 +792,16 @@ "maxy": 38.61772 } }, - "mng": { + "mn": { "name": "Mongolia", "bbox": { - "minx": 87.7345852, - "miny": 41.5800276, - "maxx": 119.9322079, - "maxy": 52.1496 + "minx": -79.2435563, + "miny": 43.9182593, + "maxx": -79.2035563, + "maxy": 43.9582593 } }, - "ind": { + "in": { "name": "India", "bbox": { "minx": 67.9544415, @@ -855,34 +810,34 @@ "maxy": 35.6745457 } }, - "bgd": { + "bd": { "name": "Bangladesh", "bbox": { - "minx": 88.007915, - "miny": 20.3679092, - "maxx": 92.6802967, - "maxy": 26.6382534 + "minx": 36.0314231, + "miny": -0.3064982, + "maxx": 36.0714231, + "maxy": -0.2664982 } }, - "btn": { + "bt": { "name": "Bhutan", "bbox": { - "minx": 88.7464856, - "miny": 26.7016859, - "maxx": 92.1252321, - "maxy": 28.2474194 + "minx": 75.6258366, + "miny": 33.0004804, + "maxx": 75.6658366, + "maxy": 33.0404804 } }, - "npl": { + "np": { "name": "Nepal", "bbox": { - "minx": 80.0570812, - "miny": 26.3477581, - "maxx": 88.2015257, - "maxy": 30.471487 + "minx": 110.8240229, + "miny": -6.5155532, + "maxx": 110.8640229, + "maxy": -6.4755532 } }, - "pak": { + "pk": { "name": "Pakistan", "bbox": { "minx": 60.872855, @@ -891,7 +846,7 @@ "maxy": 37.084107 } }, - "afg": { + "af": { "name": "Afghanistan", "bbox": { "minx": 60.5176034, @@ -900,7 +855,7 @@ "maxy": 38.4910682 } }, - "tjk": { + "tj": { "name": "Tajikistan", "bbox": { "minx": 67.3332775, @@ -909,16 +864,16 @@ "maxy": 41.0450935 } }, - "kgz": { + "kg": { "name": "Kyrgyzstan", "bbox": { - "minx": 69.2649523, - "miny": 39.1727382, - "maxx": 80.2295793, - "maxy": 43.2669041 + "minx": 74.714533, + "miny": 42.4857724, + "maxx": 74.714633, + "maxy": 42.4858724 } }, - "tkm": { + "tm": { "name": "Turkmenistan", "bbox": { "minx": 52.2643526, @@ -927,43 +882,43 @@ "maxy": 42.7996686 } }, - "irn": { + "ir": { "name": "Iran", "bbox": { - "minx": 44.0318908, - "miny": 24.8353084, - "maxx": 63.3332704, - "maxy": 39.7824624 + "minx": 115.4442856, + "miny": 2.9368196, + "maxx": 115.4443856, + "maxy": 2.9369196 } }, - "syr": { + "sy": { "name": "Syria", "bbox": { - "minx": 35.4714427, - "miny": 32.311354, - "maxx": 42.3745894, - "maxy": 37.3186563 + "minx": 38.5331373, + "miny": 35.8144462, + "maxx": 38.5596712, + "maxy": 35.8426126 } }, - "arm": { + "am": { "name": "Armenia", "bbox": { - "minx": 43.4471395, - "miny": 38.8404775, - "maxx": 46.6333087, - "maxy": 41.3016463 + "minx": -75.7893957, + "miny": 4.3957427, + "maxx": -75.6324993, + "maxy": 4.5881794 } }, - "swe": { + "se": { "name": "Sweden", "bbox": { - "minx": 10.5935025, - "miny": 55.1370957, - "maxx": 24.1776819, - "maxy": 69.0599735 + "minx": -70.8987665, + "miny": 44.0770978, + "maxx": -70.7348752, + "maxy": 44.1808705 } }, - "blr": { + "by": { "name": "Belarus", "bbox": { "minx": 23.1783313, @@ -972,16 +927,16 @@ "maxy": 56.1722484 } }, - "ukr": { + "ua": { "name": "Ukraine", "bbox": { "minx": 22.137059, "miny": 44.184598, - "maxx": 40.2275801, + "maxx": 40.2278093, "maxy": 52.3797464 } }, - "pol": { + "pl": { "name": "Poland", "bbox": { "minx": 14.0696389, @@ -990,7 +945,7 @@ "maxy": 55.03605 } }, - "aut": { + "at": { "name": "Austria", "bbox": { "minx": 9.5307487, @@ -999,16 +954,16 @@ "maxy": 49.0205249 } }, - "hun": { + "hu": { "name": "Hungary", "bbox": { - "minx": 16.1138866, - "miny": 45.737128, - "maxx": 22.8977094, - "maxy": 48.585257 + "minx": -72.7989842, + "miny": 41.9567629, + "maxx": -72.7589842, + "maxy": 41.9967629 } }, - "mda": { + "md": { "name": "Moldova", "bbox": { "minx": 26.6164054, @@ -1017,7 +972,7 @@ "maxy": 48.4920527 } }, - "rou": { + "ro": { "name": "Romania", "bbox": { "minx": 20.2619955, @@ -1026,7 +981,7 @@ "maxy": 48.2654738 } }, - "ltu": { + "lt": { "name": "Lithuania", "bbox": { "minx": 20.6557167, @@ -1035,16 +990,16 @@ "maxy": 56.4504213 } }, - "lva": { + "lv": { "name": "Latvia", "bbox": { "minx": 20.6009852, "miny": 55.6746505, - "maxx": 28.2414904, + "maxx": 28.2414937, "maxy": 58.0855688 } }, - "est": { + "ee": { "name": "Estonia", "bbox": { "minx": 21.3826069, @@ -1053,52 +1008,52 @@ "maxy": 59.9383333 } }, - "deu": { + "de": { "name": "Germany", "bbox": { - "minx": 5.8663153, - "miny": 47.2701114, - "maxx": 15.0419309, - "maxy": 55.099161 + "minx": -79.1366983, + "miny": 40.4003479, + "maxx": -79.0966983, + "maxy": 40.4403479 } }, - "bgr": { + "bg": { "name": "Bulgaria", "bbox": { - "minx": 22.3571459, - "miny": 41.2353678, - "maxx": 28.8875409, - "maxy": 44.2155388 + "minx": 23.5970346, + "miny": 46.7826456, + "maxx": 23.6398011, + "maxy": 46.7927583 } }, - "grc": { + "gr": { "name": "Greece", "bbox": { - "minx": 19.1127535, - "miny": 34.7188863, - "maxx": 29.68381, - "maxy": 41.7488889 + "minx": -77.753536, + "miny": 43.17927, + "maxx": -77.615591, + "maxy": 43.3347444 } }, - "tur": { + "tr": { "name": "Turkey", "bbox": { "minx": 25.5656305, - "miny": 35.8059015, + "miny": 35.8058974, "maxx": 44.8176638, "maxy": 42.297 } }, - "alb": { + "al": { "name": "Albania", "bbox": { - "minx": 19.0009866, - "miny": 39.640394, - "maxx": 21.0574335, - "maxy": 42.6610848 + "minx": -76.0033466, + "miny": 1.0977792, + "maxx": -75.7569629, + "maxy": 1.3654691 } }, - "hrv": { + "hr": { "name": "Croatia", "bbox": { "minx": 13.2104814, @@ -1107,7 +1062,7 @@ "maxy": 46.555029 } }, - "che": { + "ch": { "name": "Switzerland", "bbox": { "minx": 5.9559113, @@ -1116,16 +1071,16 @@ "maxy": 47.8084597 } }, - "lux": { + "lu": { "name": "Luxembourg", "bbox": { - "minx": 5.7357006, - "miny": 49.4478587, - "maxx": 6.5312481, - "maxy": 50.1827726 + "minx": 6.06917, + "miny": 49.5609875, + "maxx": 6.2036491, + "maxy": 49.6548682 } }, - "bel": { + "be": { "name": "Belgium", "bbox": { "minx": 2.3889137, @@ -1134,7 +1089,7 @@ "maxy": 51.550781 } }, - "nld": { + "nl": { "name": "Netherlands", "bbox": { "minx": -68.6255319, @@ -1143,7 +1098,7 @@ "maxy": 53.744395 } }, - "prt": { + "pt": { "name": "Portugal", "bbox": { "minx": -31.5575303, @@ -1152,7 +1107,7 @@ "maxy": 42.1543112 } }, - "esp": { + "es": { "name": "Spain", "bbox": { "minx": -18.3936845, @@ -1161,7 +1116,7 @@ "maxy": 43.9933088 } }, - "irl": { + "ie": { "name": "Ireland", "bbox": { "minx": -11.0133788, @@ -1170,25 +1125,16 @@ "maxy": 55.636 } }, - "ncl": { + "nc": { "name": "New Caledonia", "bbox": { - "minx": 157.9847541, - "miny": -23.2217509, - "maxx": 172.3057152, - "maxy": -17.6868616 + "minx": 156.2557034, + "miny": -26.4416318, + "maxx": 174.2757095, + "maxy": -14.8341667 } }, - "slb": { - "name": "Solomon Is.", - "bbox": { - "minx": -83.4848851, - "miny": 35.8292625, - "maxx": -82.8448851, - "maxy": 36.4692625 - } - }, - "nzl": { + "nz": { "name": "New Zealand", "bbox": { "minx": -179.059153, @@ -1197,7 +1143,7 @@ "maxy": -29.0303303 } }, - "aus": { + "au": { "name": "Australia", "bbox": { "minx": 72.2461932, @@ -1206,34 +1152,34 @@ "maxy": -9.0880125 } }, - "lka": { + "lk": { "name": "Sri Lanka", "bbox": { - "minx": 79.3959205, + "minx": 79.421989, "miny": 5.719, "maxx": 82.0810141, "maxy": 10.035 } }, - "chn": { + "cn": { "name": "China", "bbox": { - "minx": 73.4997347, - "miny": 8.6650385, - "maxx": 134.7754563, - "maxy": 53.5608154 + "minx": -94.347538, + "miny": 30.030471, + "maxx": -94.308516, + "maxy": 30.075717 } }, - "twn": { + "tw": { "name": "Taiwan", "bbox": { - "minx": 114.2857874, - "miny": 10.3267657, - "maxx": 122.3283, - "maxy": 26.4372222 + "minx": 120.0347671, + "miny": 21.8968599, + "maxx": 122.0064049, + "maxy": 25.2997353 } }, - "ita": { + "it": { "name": "Italy", "bbox": { "minx": 6.6272658, @@ -1242,7 +1188,7 @@ "maxy": 47.0921462 } }, - "dnk": { + "dk": { "name": "Denmark", "bbox": { "minx": 7.7153255, @@ -1251,7 +1197,7 @@ "maxy": 57.9524297 } }, - "gbr": { + "gb": { "name": "United Kingdom", "bbox": { "minx": -14.015517, @@ -1260,7 +1206,7 @@ "maxy": 61.061 } }, - "isl": { + "is": { "name": "Iceland", "bbox": { "minx": -25.0135069, @@ -1269,7 +1215,7 @@ "maxy": 67.353 } }, - "aze": { + "az": { "name": "Azerbaijan", "bbox": { "minx": 44.7633701, @@ -1278,16 +1224,16 @@ "maxy": 41.9646768 } }, - "geo": { + "ge": { "name": "Georgia", "bbox": { - "minx": 39.8844803, - "miny": 41.0551284, - "maxx": 46.7365373, - "maxy": 43.5864294 + "minx": -85.605165, + "miny": 30.3556558, + "maxx": -80.751429, + "maxy": 35.0006769 } }, - "phl": { + "ph": { "name": "Philippines", "bbox": { "minx": 114.1036921, @@ -1296,7 +1242,7 @@ "maxy": 21.321928 } }, - "mys": { + "my": { "name": "Malaysia", "bbox": { "minx": 98.7365109, @@ -1305,7 +1251,7 @@ "maxy": 8.3801468 } }, - "brn": { + "bn": { "name": "Brunei", "bbox": { "minx": 113.017925, @@ -1314,7 +1260,7 @@ "maxy": 6.546584 } }, - "svn": { + "si": { "name": "Slovenia", "bbox": { "minx": 13.3754696, @@ -1323,7 +1269,7 @@ "maxy": 46.8766816 } }, - "fin": { + "fi": { "name": "Finland", "bbox": { "minx": 19.0832, @@ -1332,16 +1278,16 @@ "maxy": 70.0922939 } }, - "svk": { + "sk": { "name": "Slovakia", "bbox": { "minx": 16.8331891, "miny": 47.7311798, - "maxx": 22.56571, + "maxx": 22.5657103, "maxy": 49.6138162 } }, - "cze": { + "cz": { "name": "Czechia", "bbox": { "minx": 12.0905752, @@ -1350,7 +1296,7 @@ "maxy": 51.0556945 } }, - "eri": { + "er": { "name": "Eritrea", "bbox": { "minx": 36.4333653, @@ -1359,7 +1305,7 @@ "maxy": 18.0709917 } }, - "jpn": { + "jp": { "name": "Japan", "bbox": { "minx": 122.7141754, @@ -1368,7 +1314,7 @@ "maxy": 45.7112046 } }, - "pry": { + "py": { "name": "Paraguay", "bbox": { "minx": -62.6406685, @@ -1377,7 +1323,7 @@ "maxy": -19.2876472 } }, - "yem": { + "ye": { "name": "Yemen", "bbox": { "minx": 41.60825, @@ -1386,61 +1332,52 @@ "maxy": 19.0 } }, - "sau": { + "sa": { "name": "Saudi Arabia", "bbox": { "minx": 34.4571718, "miny": 16.29, "maxx": 55.6666851, - "maxy": 32.1543377 + "maxy": 32.1542832 } }, - "ata": { + "aq": { "name": "Antarctica", "bbox": { - "minx": -24.6850688, - "miny": -104.4063075, - "maxx": 25.3149312, - "maxy": -54.4063075 - } - }, - "cyn": { - "name": "N. Cyprus", - "bbox": { - "minx": 32.4871506, - "miny": 35.0030286, - "maxx": 34.8553182, - "maxy": 35.913252 + "minx": -180.0, + "miny": -85.0511287, + "maxx": 180.0, + "maxy": -60.0 } }, - "cyp": { + "cy": { "name": "Cyprus", "bbox": { "minx": 32.0227581, "miny": 34.4383706, - "maxx": 34.8553182, - "maxy": 35.913252 + "maxx": 34.3338842, + "maxy": 35.3991245 } }, - "mar": { + "ma": { "name": "Morocco", "bbox": { - "minx": -17.2448353, - "miny": 21.333462, + "minx": -17.3190239, + "miny": 20.667252, "maxx": -0.998429, "maxy": 36.0021392 } }, - "egy": { + "eg": { "name": "Egypt", "bbox": { - "minx": 24.6499112, - "miny": 21.9936736, - "maxx": 37.1153517, - "maxy": 31.8330854 + "minx": -90.9598614, + "miny": 35.860483, + "maxx": -90.9347707, + "maxy": 35.8751547 } }, - "lby": { + "ly": { "name": "Libya", "bbox": { "minx": 9.391081, @@ -1449,7 +1386,7 @@ "maxy": 33.3545898 } }, - "eth": { + "et": { "name": "Ethiopia", "bbox": { "minx": 32.9975838, @@ -1458,7 +1395,7 @@ "maxy": 14.8943383 } }, - "dji": { + "dj": { "name": "Djibouti", "bbox": { "minx": 41.7713139, @@ -1467,16 +1404,7 @@ "maxy": 12.7923081 } }, - "sol": { - "name": "Somaliland", - "bbox": { - "minx": 42.708703, - "miny": 7.9998309, - "maxx": 49.0800591, - "maxy": 11.7160828 - } - }, - "uga": { + "ug": { "name": "Uganda", "bbox": { "minx": 29.573433, @@ -1485,7 +1413,7 @@ "maxy": 4.2340766 } }, - "rwa": { + "rw": { "name": "Rwanda", "bbox": { "minx": 28.861696, @@ -1494,16 +1422,7 @@ "maxy": -1.0474083 } }, - "bih": { - "name": "Bosnia and Herz.", - "bbox": { - "minx": 18.4251913, - "miny": 43.8592358, - "maxx": 18.4255335, - "maxy": 43.8596085 - } - }, - "mkd": { + "mk": { "name": "North Macedonia", "bbox": { "minx": 20.4529023, @@ -1512,25 +1431,7 @@ "maxy": 42.3739044 } }, - "srb": { - "name": "Serbia", - "bbox": { - "minx": 18.8149945, - "miny": 42.2314466, - "maxx": 23.006309, - "maxy": 46.1902839 - } - }, - "mne": { - "name": "Montenegro", - "bbox": { - "minx": 18.4195781, - "miny": 41.6849866, - "maxx": 20.3529276, - "maxy": 43.5585061 - } - }, - "-99": { + "rs": { "name": "Kosovo", "bbox": { "minx": 20.0142844, @@ -1539,7 +1440,16 @@ "maxy": 43.2733306 } }, - "tto": { + "me": { + "name": "Montenegro", + "bbox": { + "minx": -38.3760027, + "miny": -12.8806886, + "maxx": -38.0304294, + "maxy": -12.452 + } + }, + "tt": { "name": "Trinidad and Tobago", "bbox": { "minx": -62.083056, @@ -1547,16 +1457,7 @@ "maxx": -60.2895848, "maxy": 11.5628372 } - }, - "ssd": { - "name": "S. Sudan", - "bbox": { - "minx": 23.447778, - "miny": 3.48898, - "maxx": 35.948997, - "maxy": 12.236389 - } } }, - "_comment": "Generated on 2023-08-31 from geopandas, OpenStreetMap and Nominatim" -} + "_comment": "Generated on 2023-11-20 from geopandas, OpenStreetMap and Nominatim" +} \ No newline at end of file diff --git a/config-templates/metadata-synop.yml.tmpl b/config-templates/metadata-synop.yml.tmpl index 664f75222..e20680db3 100644 --- a/config-templates/metadata-synop.yml.tmpl +++ b/config-templates/metadata-synop.yml.tmpl @@ -15,8 +15,8 @@ metadata: identification: language: en charset: utf8 - title: Hourly synoptic observations from fixed-land stations (SYNOP) ($COUNTRY_NAME) - abstract: Hourly synoptic observations from fixed-land stations (SYNOP) ($COUNTRY_NAME) + title: Hourly synoptic observations from fixed-land stations (SYNOP) ($CENTRE_ID) + abstract: Hourly synoptic observations from fixed-land stations (SYNOP) ($CENTRE_ID) dates: creation: $CREATION_DATE publication: $PUBLICATION_DATE diff --git a/config-templates/metadata-temp.yml.tmpl b/config-templates/metadata-temp.yml.tmpl index bde22e2db..61578ecf9 100644 --- a/config-templates/metadata-temp.yml.tmpl +++ b/config-templates/metadata-temp.yml.tmpl @@ -15,8 +15,8 @@ metadata: identification: language: en charset: utf8 - title: Upper-level temperature/humidity/wind reports from fixed-land stations (TEMP) ($COUNTRY_NAME) - abstract: Upper-level temperature/humidity/wind reports from fixed-land stations (TEMP) ($COUNTRY_NAME) + title: Upper-level temperature/humidity/wind reports from fixed-land stations (TEMP) ($CENTRE_ID) + abstract: Upper-level temperature/humidity/wind reports from fixed-land stations (TEMP) ($CENTRE_ID) dates: creation: $CREATION_DATE publication: $PUBLICATION_DATE diff --git a/docs/source/user/setup.rst b/docs/source/user/setup.rst index 3d0de6f8f..b53bb52c4 100644 --- a/docs/source/user/setup.rst +++ b/docs/source/user/setup.rst @@ -42,12 +42,13 @@ Run the following command to create the initial configuration files for your wis The script will propose to automatically create passwords for ``WIS2BOX_STORAGE_PASSWORD`` and ``WIS2BOX_BROKER_PASSWORD``. These passwords are for internal use only within the wis2box, and it is recommended to accept the randomly generated passwords. - The script will ask for 3-letter ISO country code for your wis2box. Please provide the 3-letter ISO country code for your country, for example ``FRA``. - It will also ask for a centre-id. Please provide a lowercase string delimited by `-`, that is comprised of the `top level domain of your country`_ and a lowercase string that identifies your organization and does not use spaces or special characters, for example ``fr-meteofrance``. + The script will ask for your TLD, the `top level domain of your country`_, for example ``fr`` for France. International organizations should use ``int``. + + It will also ask for a centre-id. Please provide a lowercase string delimited by `-`, that is comprised of the TLD and a lowercase string that identifies your organization and does not use spaces or special characters, for example ``fr-meteofrance``. .. note:: - In alignment with WMO WIS2 Guidance, the above fields are automatically converted to lowercase when saved in wis2box. + In alignment with WMO WIS2 Guidance, the centre-id is automatically converted to lowercase when saved in wis2box. The remaining questions will be used in the creation the discovery metadata files for the ``synop`` and ``temp`` datasets. diff --git a/wis2box-create-config.py b/wis2box-create-config.py index ecc4ce566..5d04e589f 100644 --- a/wis2box-create-config.py +++ b/wis2box-create-config.py @@ -28,17 +28,45 @@ from string import Template from typing import Tuple +OTHER_TLDS = ['org', 'int'] + + +def get_country_name(country_code: str) -> str: + """ + provide the country name for the wis2box + using the country's 2-letter ISO code + using the data from config-templates/bounding_box_lookup.json + + :param country_code: `str` 2-letter ISO code for the country + + :returns: `str` of country name + """ + + country_name = 'NA' + # get the path to the data + data_path = Path(__file__).parent / 'config-templates' / 'countries.json' + + # open the file + with data_path.open() as fh: + # load the data + data = json.load(fh) + # get the bounding box for the country + if country_code in data['countries'] and 'name' in data['countries'][country_code]: # noqa + country_name = data['countries'][country_code]['name'] + + return country_name + def get_bounding_box(country_code: str) -> Tuple[str, str]: """ provide the initial bounding box for the wis2box - using the country's 3-letter ISO code + using the country's 2-letter ISO code using the data from config-templates/bounding_box_lookup.json use bounding box for the whole world if no value is found in the config-templates/bounding_box_lookup.json file - :param country_code: `str` 3-letter ISO code for the country + :param country_code: `str` 2-letter ISO code for the country :returns: `tuple` of (country_name, bbox) """ @@ -94,47 +122,68 @@ def get_bounding_box(country_code: str) -> Tuple[str, str]: return country_name, bounding_box -def get_country_and_centre_id() -> Tuple[str, str]: +def get_tld_and_centre_id() -> Tuple[str, str]: """ - Asks the user for the 3-letter ISO country-code + Asks the user for the TLD and a string identifying the centre hosting the wis2box. :returns: `tuple` of (country_code, centre_id) """ answer = '' - + country_code = '' while answer != 'y': if answer == 'exit': exit() - print('Please enter your 3-letter ISO country code:') + print('Please enter your ccTLD (2-letter country code) or other TLD:') # noqa country_code = input() - # check that the input is a 3-letter string + # check that the input is a 2-letter string or a relevant TLD # if not repeat the question - while len(country_code) != 3: - print('The country code must be a 3-letter string.') - print('Please enter your 3-letter ISO country code:') + while country_code not in OTHER_TLDS and len(country_code) != 2: + print(f'The country code must be a 2-letter ISO code or another relevant TLD (e.g. {OTHER_TLDS}).') # noqa + print('Please enter your 2-letter ISO country code (or TLD):') # noqa country_code = input() # make sure the country code is lowercase country_code = country_code.lower() + # if country_code is a 2-letter ISO code, check the country name + country_name = 'NA' + if len(country_code) == 2: + country_name = get_country_name(country_code) + if country_name == 'NA': + print(f'No country-name found for ccTLD={country_code} !') + + # ask the user to confirm their choice and give them the option to change it # noqa + print('Your TLD corresponds to: ') + print(f' {country_code} (country_name={country_name})') + print('Is this correct? (y/n/exit)') + answer = input() + + answer = '' + centre_id = '' + while answer != 'y': + if answer == 'exit': + exit() print('Please enter the centre-id for your wis2box:') centre_id = str(input()).lower() # check that the input is valid # if not repeat the question - while any([x in centre_id for x in ['#', '+', ' ']]) or len(centre_id) < 3: # noqa - print('The centre-id cannot contain spaces or the "+" or "#" characters, and must be at least 3 characters long.') # noqa - print('Please enter the string identifying the centre hosting the wis2box:') # noqa + while any([x in centre_id for x in ['#', '+', ' ']]) or len(centre_id) < 6 or not centre_id.startswith(country_code + '-'): # noqa + if not centre_id.startswith(country_code + '-'): + print(f' !!! The centre-id must start with {country_code}-') + print(f' For example: {country_code}-mycentre') + if any([x in centre_id for x in ['#', '+', ' ']]): + print(' !!! The centre-id cannot contain spaces or the "+" or "#" characters') # noqa + if len(centre_id) < 5: + print(' !!! The centre-id must be at least 6 characters long.') + print('Please enter the centre-id for your wis2box:') centre_id = str(input()).lower() # ask the user to confirm their choice and give them the option to change it # noqa - # and give them the option to exit the script - print('The country-code will be set to:') - print(f' {country_code}') print('The centre-id will be set to:') print(f' {centre_id}') print('Is this correct? (y/n/exit)') @@ -368,7 +417,7 @@ def create_config_dir() -> str: return config_dir -def create_datamappings_file(config_dir: str, centre_id: str) -> None: +def update_datamappings_file(config_dir: str, centre_id: str) -> None: """ creates the data mappings file in the directory config_dir @@ -389,16 +438,22 @@ def create_datamappings_file(config_dir: str, centre_id: str) -> None: with template_file.open() as fh: config_file = Template(fh.read()) result = config_file.substitute(template_vars) - with new_config_file.open("w") as fh2: - fh2.write(result) + if new_config_file.exists(): + print(f"Adding datasets to {new_config_file}") + with new_config_file.open("a") as fh2: + fh2.write(result.replace("data:\n", "")) + else: + print(f"Creating {new_config_file}") + with new_config_file.open("w") as fh2: + fh2.write(result) print("*" * 80) - print("Initial data_mappings.yml have been created") # noqa + print("data_mappings.yml have been created/updated") # noqa print("Please review the file and update as needed.") print("*" * 80) -def create_metadata_file(config_dir: str, country_name: str, +def create_metadata_file(config_dir: str, country_name: str, centre_id: str, centre_name: str, wis2box_email: str, bounding_box: str, template: str) -> str: """ @@ -425,7 +480,7 @@ def create_metadata_file(config_dir: str, country_name: str, if not discovery_metadata_dir.exists(): discovery_metadata_dir.mkdir(parents=True) - new_config_file = discovery_metadata_dir / f'metadata-{template}.yml' + new_config_file = discovery_metadata_dir / f'metadata-{template}-{centre_id}.yml' # noqa template_file = Path('config-templates') / f'metadata-{template}.yml.tmpl' # noqa template_vars = { @@ -470,7 +525,7 @@ def create_metadata_files(config_dir: str, country_code: str, if answer == "exit": exit() - print("Please enter the email address of the wis2box administrator:") + print(f"Please enter the email address of the wis2box administrator for {centre_id}:") # noqa wis2box_email = input() print("The email address of the wis2box administrator will be set to:") # noqa print(f" {wis2box_email}") @@ -483,15 +538,18 @@ def create_metadata_files(config_dir: str, country_code: str, while answer != "y": if answer == "exit": exit() - print("Please enter the name of your organization:") + print(f"Please enter the name of the organization for {centre_id}:") centre_name = input() - print("Your organization name will be set to:") + print("The organization name will be set to:") print(f" {centre_name}") print("Is this correct? (y/n/exit)") answer = input() # get an initial bounding box for the country - country_name, bounding_box = get_bounding_box(country_code) + country_name = 'NA' + bounding_box = '-180, -90, 180, 90' + if country_code not in OTHER_TLDS: + country_name, bounding_box = get_bounding_box(country_code) create_metadata_file( config_dir, @@ -513,7 +571,7 @@ def create_metadata_files(config_dir: str, country_code: str, ) print("*" * 80) - print(f"Initial metadata files created in directory {config_dir}.") # noqa + print(f"Metadata files for {centre_id} created in directory {config_dir}.") # noqa print("Please review the files and edit where necessary.") print("*" * 80) @@ -610,14 +668,21 @@ def main(): if not dev_env.is_file(): create_wis2box_env(config_dir) - country_code, centre_id = get_country_and_centre_id() - - print("*" * 80) - print("Creating initial configuration for surface and upper-air data.") - print("*" * 80) + q_metadata = 'Would you like to add datasets for another centre-id ? (y/n)' # noqa + answer = 'y' + while answer == 'y': + tld, centre_id = get_tld_and_centre_id() + create_metadata_files(config_dir, tld, centre_id) + update_datamappings_file(config_dir, centre_id) + print(" ") + print(f"Finished configuration for centre-id={centre_id}") + print(" ") + print(q_metadata) + answer = input() + if answer not in ['y', 'n']: + print(q_metadata) + answer = input() - create_metadata_files(config_dir, centre_id) - create_datamappings_file(config_dir, centre_id) create_station_list(config_dir) print("The configuration is complete.") From 6efda8cc2ecf8603cdac3b52ef8a8731c7450939 Mon Sep 17 00:00:00 2001 From: Maaike Date: Mon, 27 Nov 2023 10:15:41 +0100 Subject: [PATCH 2/3] add org and int to countries.json --- config-templates/countries.json | 18 ++++++++++++++++++ wis2box-create-config.py | 15 +++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/config-templates/countries.json b/config-templates/countries.json index ad8317d17..7153ee3f2 100644 --- a/config-templates/countries.json +++ b/config-templates/countries.json @@ -1,5 +1,23 @@ { "countries": { + "int": { + "name": "Intergovernmental Organization", + "bbox": { + "minx": -180.0, + "miny": -90.0, + "maxx": 180.0, + "maxy": 90.0 + } + }, + "org": { + "name": "International Organization", + "bbox": { + "minx": -180.0, + "miny": -90.0, + "maxx": 180.0, + "maxy": 90.0 + } + }, "fj": { "name": "Fiji", "bbox": { diff --git a/wis2box-create-config.py b/wis2box-create-config.py index 5d04e589f..7b086264c 100644 --- a/wis2box-create-config.py +++ b/wis2box-create-config.py @@ -149,12 +149,10 @@ def get_tld_and_centre_id() -> Tuple[str, str]: # make sure the country code is lowercase country_code = country_code.lower() - # if country_code is a 2-letter ISO code, check the country name - country_name = 'NA' - if len(country_code) == 2: - country_name = get_country_name(country_code) - if country_name == 'NA': - print(f'No country-name found for ccTLD={country_code} !') + # check the country name + country_name = get_country_name(country_code) + if country_name == 'NA': + print(f'No country-name found for TLD={country_code} !') # ask the user to confirm their choice and give them the option to change it # noqa print('Your TLD corresponds to: ') @@ -546,10 +544,7 @@ def create_metadata_files(config_dir: str, country_code: str, answer = input() # get an initial bounding box for the country - country_name = 'NA' - bounding_box = '-180, -90, 180, 90' - if country_code not in OTHER_TLDS: - country_name, bounding_box = get_bounding_box(country_code) + country_name, bounding_box = get_bounding_box(country_code) create_metadata_file( config_dir, From a04f401c562c7b2a1725b83f0f53be597ec2a024 Mon Sep 17 00:00:00 2001 From: Maaike Date: Mon, 27 Nov 2023 10:19:23 +0100 Subject: [PATCH 3/3] update doc string, try except KeyError --- wis2box-create-config.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wis2box-create-config.py b/wis2box-create-config.py index 7b086264c..fb3245e9a 100644 --- a/wis2box-create-config.py +++ b/wis2box-create-config.py @@ -34,10 +34,10 @@ def get_country_name(country_code: str) -> str: """ provide the country name for the wis2box - using the country's 2-letter ISO code + using the country's TLD code using the data from config-templates/bounding_box_lookup.json - :param country_code: `str` 2-letter ISO code for the country + :param country_code: `str` of TLD code of the country :returns: `str` of country name """ @@ -51,8 +51,10 @@ def get_country_name(country_code: str) -> str: # load the data data = json.load(fh) # get the bounding box for the country - if country_code in data['countries'] and 'name' in data['countries'][country_code]: # noqa + try: country_name = data['countries'][country_code]['name'] + except KeyError: + pass return country_name @@ -60,13 +62,13 @@ def get_country_name(country_code: str) -> str: def get_bounding_box(country_code: str) -> Tuple[str, str]: """ provide the initial bounding box for the wis2box - using the country's 2-letter ISO code + using the country's TLD code using the data from config-templates/bounding_box_lookup.json use bounding box for the whole world if no value is found in the config-templates/bounding_box_lookup.json file - :param country_code: `str` 2-letter ISO code for the country + :param country_code: `str` of TLD code of the country :returns: `tuple` of (country_name, bbox) """