-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcore.py
More file actions
22 lines (15 loc) · 647 Bytes
/
Copy pathcore.py
File metadata and controls
22 lines (15 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import time
def process_data(data: list):
time.sleep(1) # Simulate a long running process
# Calculate the average lat and average long from the data
lats = [float(x[0]) for x in data]
average_lat = sum(lats) / len(lats)
longs = [float(x[1]) for x in data]
average_long = sum(longs) / len(longs)
# The most northerly datapoint
most_northerly_lat = max(lats)
most_northerly_index = lats.index(most_northerly_lat)
most_northerly = data[most_northerly_index]
# Package up into processed data
result = {"centroid": (average_lat, average_long), "most_northerly": most_northerly}
return result