can routing service url use encoded addresses instead of geocodes?

467
0
a month ago
AlcoGISUser
New Contributor III

I have a .NET application that is managed by another team in my department. The team asked if I could calculate mileage between two points in a manner in which the origin and destination would be user defined input fields on their application. After having some cert issues with google maps OD cost matrix I looked into an ArcGIS solution and came across this API reference:

https://developers.arcgis.com/documentation/mapping-apis-and-services/routing/travel-cost-matrix/

I've gotten it to work using xy coordinates:

route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix?origins=-122.68782,45.51238;-122.690176,45.522054&destinations=-122.614995,45.526201&f=json&token=<MY_ACCESS_TOKEN> 

 

The team has said they can get their app to kick off the python snippet:

oAddress = "555 5th Street, Anytown, Anystate 55555"
dAddress = "999 9th Street, Anytown, Anystate 99999"
origin = geocode(oAddress)
destination = geocode(dAddress)

 

where oAddress and dAddress would be derived from user input fields in the app

 

I can grab the XY values by calling the resultant dict keys within the results list:

origin[0]['location']

destination[0]['location']

 

It would be much better, however, if we could simply grab the addresses from the user input fields, encode them as such:

 

555%205th%20Street%2C%20Anytown%2C%20Anystate%2099999

 

and put them in the url request string.

 

I tried to do this and got the following error response:

{
"error": {
"code": 400,
"extendedCode": -2147200939,
"message": "Unable to complete operation.",
"details": [
"The input points are not all located within a single region."
]
}
}

(the actual addresses are within the same city)

Is there another way to simply encode or geocode addresses within the same url request to solve a simple 1 to 1 OD pair route?

 

Tags (3)
0 Kudos
0 Replies