概要
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 | サービスのデフォルトの移動モード。 | String |
コードのサンプル
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])
環境
このツールは、ジオプロセシング環境を使用しません。