-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathata.py
More file actions
30 lines (27 loc) · 1.09 KB
/
ata.py
File metadata and controls
30 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from config import SpatiallyAPI
import requests
import ast
timeOfDayValues = ("AllDay", "Morning", "MidDay", "Evening", "Night")
locationValues = ("Home", "Work", "HomeAndWork")
def NewATA(token,locationWKT,timeOfDay="AllDay", locationType="Home", geoFence=False):
if timeOfDay not in timeOfDayValues:
raise ValueError("Value provided for timeOfDay invalid:", timeOfDay, "Must be one of the following:", timeOfDayValues)
if locationType not in locationValues:
raise ValueError("Value provided for locationType invalid:", locationType, "Must be one of the following:", locationValues)
data = {
"pointWKT": locationWKT,
"areaType": "ATA",
"buffer": 100,
"distance": 0,
"timeOfDay": timeOfDay,
}
if locationType == "Home":
data["locationType"] = ["Home"]
if locationType == "Work":
data["locationType"] = ["Work"]
if locationType == "HomeAndWork":
data["locationType"] = ["Home", "Work"]
data["geoFence"] = geoFence
headers = {"Authorization": "Bearer {}".format(token)}
resp = requests.post(SpatiallyAPI+"/ads/science/ata", json=data, headers=headers)
return ast.literal_eval(resp.text)