AnsweredAssumed Answered

REST API JSON returns as inputs in GP tools?

Question asked by duncan.fetner_Zayo on Jun 20, 2018

I have a web tool that successfully solves a route based on a feature set input of stop points, but now I am stuck trying to get information about the traversed features on the solved route. My returned route is a JSON response from the ArcGIS REST API, but I am pretty clueless as to how to utilize that as an input in Copy Traversed Source Features. Unfortunately, I am too stuck to really provide much more info beyond this sample code of my failed attempt. Any help is tremendously appreciated!

 

#route is JSON response from route layer solve task with REST API
#I've tried using in_memory and a scratch GDB as my workspace
def copyTraversed(route, workspace):
import os
import json
arcpy.na.CopyTraversedSourceFeatures(route, workspace, 'edges', 'junctions', 'turns')
edgesTS = arcpy.TableSet()
junctionsTS = arcpy.TableSet()
edgesTS.load(os.path.join(workspace, 'edges'))
junctionsTS.load(os.path.join(workspace, 'junctions'))
traversedFeatures = {'edges': json.loads(edgesTS.JSON), 'junctions': json.loads(junctionsTS.JSON)}
return traversedFeatures

Outcomes