Skip to content

Commit 608905f

Browse files
author
Michael Hillman
committed
dev-uk-base-world-vis: Dukes clean up script should now be more robust to geolocator API failure.
1 parent 0d3f349 commit 608905f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

web/uk-base-world/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Note that this script has been developed assuming a first-time spin up condition
6161

6262
To run the script and bring up a local instance of the UK Base World visualisation, follow the below steps. To get copies of the required data files, please see the data sections above or contact CMCL for archived copies.
6363

64+
**Note:** running the script to deploy this stack will remove any existing stack manager configurations; please backup any existing ones beforehand.
65+
6466
1. If required, run the `build.sh` script from within the `/web/digital-twin-vis-framework/library` directory.
6567
- This will build a local copy of the visualisation hosting image, in case the current branch contains a new version that hasn't been pushed yet.
6668
2. Navigate to the `uk-base-world` directory.

web/uk-base-world/scripts/dukes_generate_csv.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@
7474
logger.info("OS Postcode data has been cached.")
7575

7676
# Initialise the Geocoder
77-
geolocator = Nominatim(user_agent="geoapiExercises")
77+
try:
78+
geolocator = Nominatim(user_agent="geoapiExercises")
79+
except:
80+
logger.warn("Could not initialise geolocator, skipping this check.")
7881

7982
# Read the input workbook
8083
logger.info("Reading Excel workbook at: " + args.input)
@@ -110,7 +113,7 @@
110113
output_row = [str(s).replace(",", "/") for s in output_row]
111114

112115
# Round capacity to 2 decimal places
113-
output_row[7] = round(output_row[7], 2)
116+
output_row[7] = round(float(output_row[7]), 2)
114117

115118
# Get plant location details
116119
postcode = output_row[11]
@@ -132,7 +135,10 @@
132135
bng_lng_lat_str = str(bng_lng_lat[1][0]) + ", " + str(bng_lng_lat[0][0])
133136

134137
try:
135-
bng_location = geolocator.reverse(bng_lng_lat_str)
138+
if geolocator:
139+
bng_location = geolocator.reverse(bng_lng_lat_str)
140+
else:
141+
bng_location = None
136142
except:
137143
bng_location = None
138144

0 commit comments

Comments
 (0)