描述
获取一份针对组织配置的出行模式列表,该列表可与 ArcGIS Online network analysis services 结合使用。出行模式代表了一种交通方式,如驾车行驶或步行。出行模式本质上是由一长串出行设置构成的模板。
使用方法
- 运行后,工具会向应用程序添加一张表格 Supported Travel Modes。地理服务中,Supported Travel Modes 表格内所有 Travel Mode Name 字段的值都可以指定为各种工具(例如 FindRoutes)所支持的 travel_mode 参数的输入。您还可以将 Travel Mode Settings 字段中的值指定为 travel_mode 参数的输入。由于 FindRoutes 等工具不必根据出行模式名称查找设置,因而加快了所用工具的执行速度。
工具不支持任何输入参数
语法
arcpy.naagol.GetTravelModes()
派生输出
名称 | 说明 | 数据类型 |
supportedTravelModes | 支持的出行模式列表。 | 列表 |
defaultTravelMode | 服务的默认出行模式。 | 字符串 |
代码示例
GetTravelModes 示例
以下 Python 脚本演示了如何在脚本中使用 GetTravelModes 工具。
'''
The script shows how to use the GetTravelModes tool to get a list of travel modes supported by your
ArcGIS Online organization.
'''
import sys
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
result = arcpy.Utilities.GetTravelModes()
#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 travel mode table
output_tm_table = result.getOutput(0)
#Save the travel mode table in memory.
output_tm_table.save("in_memory/TravelModes")
#Use a cursor to build a list of travel mode names from the table
arcpy.AddMessage("Travel Modes configured for your organization")
travel_mode_names = []
with arcpy.da.SearchCursor(output_tm_table, ["Name"]) as cursor:
for row in cursor:
travel_mode_names.append(row[0])
arcpy.AddMessage(row[0])
环境
此工具不使用任何地理处理环境。