I am creating an APIFunction to which receives a zip code, radius in miles, and an address and then returns whether or not the given address is within a specified mile radius of the provided zip code.
I wrote the APIFunction on one line and then the command to run it on the next line. The results were as follows:
INPUT:
LocAPI = APIFunction[{"Zc" ->"ZIPCode","dist" -> "Integer","Saddress" ->"StreetAddress"},GeoWithinQ[GeoDisk[#Zc, Quantity[#dist,"Miles"]],#Saddress]&];
LocAPI[<|"Zc" -> "61606", "dist" -> 5, "Saddress" -> "300 NE Adams St Peoria, IL"|>]
OUTPUT (error):
GeoWithinQ[GeoDisk[<|"Zc" -> "ZIP 61615" Entity["ZIPCode", "61606"], "dist" -> 5 "ZIP 61615", "Saddress" -> "ZIP 61615" GeoPosition[{40.6939, -89.5862}]|>, Quantity[<|"Zc" -> 5 Entity["ZIPCode", "61606"], "dist" -> 25, "Saddress" -> 5 GeoPosition[{40.6939, -89.5862}]|>, "Miles"]], <|"Zc" ->
"300 NE Adams St Peoria, IL" Entity["ZIPCode", "61606"], "dist" -> 5 "300 NE Adams St Peoria, IL",
"Saddress" -> "300 NE Adams St Peoria, IL" GeoPosition[{40.6939, \-89.5862}]|>]
For some reason it tends to combine the inputs of the APIFunction: #Zc, #dist, etc. . .
Now if I input everything on the same line (or throw brackets around it all-essentially doing the same thing), the code will run fine:
INPUT:
(
LocAPI = APIFunction[{"Zc" ->"ZIPCode","dist" -> "Integer","Saddress" ->"StreetAddress"},GeoWithinQ[GeoDisk[#Zc, Quantity[#dist,"Miles"]],#Saddress]&];
LocAPI[<|"Zc" -> "61606", "dist" -> 5, "Saddress" -> "300 NE Adams St Peoria, IL"|>]
)
OUTPUT: true
So why does the APIFunction seem to require successive, separate instances of code to be on the same line or encapsulated in brackets? The same issue occurs when adding the "CloudDeploy" function in succession as well. It must be on the same line or else the same error occurs.
Regards,
Matt