描述
可获取信息,例如用于分析的网络数据集的说明,以及地理处理服务中某一工具的执行限制。
使用方法
该工具需要在执行地理处理服务中的其他工具前执行。例如,如果您需要确定 FindRoutes 工具所支持的最大停靠点数量,则可以运行 GetToolInfo 来确定限制。
语法
arcpy.naagol.GetToolInfo(serviceName, toolName)
参数 | 说明 | 数据类型 |
serviceName | 包含工具的服务名称。应使用以下引用特定地理处理服务的关键字之一指定参数值:
默认值为 asyncRoute。 | String |
toolName | 地理处理服务中的工具名称。参数值应为 serviceName 参数在地理处理服务中指定的有效工具名称。有效的工具名称如下:
默认值为 FindRoutes。 | String |
派生输出
名称 | 说明 | 数据类型 |
toolInfo | 有关地理处理服务中工具的其他信息。 | 字符串 |
代码示例
GetToolInfo 示例
以下 Python 脚本演示了如何在脚本中使用 GetToolInfo 工具。
'''
The script shows how to use the GetToolInfo tool to get the maximum number of stops
that can be used as inputs with FindRoutes tool.
'''
import sys
import json
import arcpy
#Change the username and password applicable to your own ArcGIS Online account
username = "<your user name>"
password = "<your password>"
utility_service = "https://logistics.arcgis.com/arcgis/services;World/Utilities;{0};{1}".format(username, password)
#Add the geoprocessing service as a toolbox.
arcpy.ImportToolbox(utility_service)
#Call the tool to get the limits for the FindRoutes tool
result = arcpy.Utilities.GetToolInfo("asyncRoute", "FindRoutes")
#Print any warning or error messages returned from the tool
result_severity = arcpy.GetMaxSeverity()
if result_severity == 2:
arcpy.AddMessage("An error occured when running the tool")
arcpy.AddMessage(arcpy.GetMessages(2))
sys.exit(2)
elif result_severity == 1:
arcpy.AddMessage("Warnings were returned when running the tool")
arcpy.AddMessage(arcpy.GetMessages(1))
#Retrieve the tool info and convert it to a dictionary
output_tool_info_json = result.getOutput(0)
output_tool_info_dict = json.loads(output_tool_info_json)
#Retrieve the maximum number of stops allowed by the service
max_stops = int(output_tool_info_dict["serviceLimits"]["maximumStops"])
arcpy.AddMessage("The maximum number of stops supported by the FindRoutes tool: {}" .format(max_stops))
环境
此工具不使用任何地理处理环境。