Message Boards Message Boards

0
|
5551 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why does the "APIFunction" require the successive code on the same line?

Posted 10 years ago

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

POSTED BY: Matt Brauer
6 Replies
Posted 10 years ago

Arnoud,

That is precisely the error I am experiencing.

David,

I'm glad that you too were able to verify the issue.

POSTED BY: Matt Brauer

Matt,

This is the error you are seeing?

enter image description here

(I think it is, but just wanted to make sure before continuing).

POSTED BY: Arnoud Buzing

If I paste the code into a Programming Cloud notebook (it includes the carriage return after the first line as you posted it) it works fine. Then I delete the carriage return and add it back in and execute the code again and get your error message. So something is indeed amiss on the Cloud...

POSTED BY: David Reiss
Posted 10 years ago
POSTED BY: Matt Brauer
POSTED BY: Sean Clarke
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract