Skip to content

Commit 7e14371

Browse files
committed
Update common.py to choose between boundary service (intenal switch)
1 parent 047a6e6 commit 7e14371

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tools/code/common.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,35 @@
1212
os.makedirs(OUTPUT_DIR, exist_ok=True)
1313
os.makedirs(CACHE_DIR, exist_ok=True)
1414

15-
# Define the REST API URL
16-
rest_api_url = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions_VIEW/FeatureServer"
15+
# Define the REST API URLs
16+
rest_api_url_view = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions_VIEW/FeatureServer"
17+
rest_api_url_new = "https://services.arcgis.com/iQ1dY19aHwbSDYIF/ArcGIS/rest/services/World_Bank_Global_Administrative_Divisions/FeatureServer"
18+
19+
# Active service selection - Set to True to use new service, False for VIEW service
20+
USE_NEW_SERVICE = True
21+
22+
# Set active URL based on service selection
23+
rest_api_url = rest_api_url_new if USE_NEW_SERVICE else rest_api_url_view
24+
1725
worldpop_url = "https://data.worldpop.org/GIS/Population/"
1826
stac_search_url = "https://geoservice.dlr.de/eoc/ogc/stac/v1/search"
1927

2028

2129
# Mapping of administrative levels to field names for WB GAD dataset
22-
adm_field_mapping = {
23-
0: {'code': 'HASC_0', 'name': 'NAM_0'},
24-
1: {'code': 'HASC_1', 'name': 'NAM_1'},
25-
2: {'code': 'HASC_2', 'name': 'NAM_2'},
26-
# Add mappings for additional levels as needed
27-
}
30+
# Field mapping adjusted based on active service
31+
if USE_NEW_SERVICE:
32+
adm_field_mapping = {
33+
0: {'code': 'ISO_A3', 'name': 'NAM_0'}, # New service uses ISO_A3 instead of HASC_0
34+
1: {'code': 'ADM1CD_c', 'name': 'NAM_1'}, # New service uses ADM1CD_c instead of HASC_1
35+
2: {'code': 'ADM2CD_c', 'name': 'NAM_2'}, # New service uses ADM2CD_c instead of HASC_2
36+
}
37+
else:
38+
adm_field_mapping = {
39+
0: {'code': 'HASC_0', 'name': 'NAM_0'},
40+
1: {'code': 'HASC_1', 'name': 'NAM_1'},
41+
2: {'code': 'HASC_2', 'name': 'NAM_2'},
42+
# Add mappings for additional levels as needed
43+
}
2844

2945
wb_to_region = {
3046
'AFR': 'AFRICA', # Sub-Saharan Africa

0 commit comments

Comments
 (0)