Skip To Content

更新实时流量数据

从配置了实时流量的网络数据集发布路径服务后,必须确保这些服务所使用的实时流量数据定期更新。 这可以通过遵循下面概述的工作流来实现:

您需要使用 Windows 任务计划程序配置 Python 脚本,使其每两分钟运行一次。 该内置 Windows 实用程序允许用户在指定时间自动执行任务和程序。 虽然您可以使用 Windows 任务计划程序的用户界面来创建更新实时流量数据的任务,但本节使用名为 schtasks 的命令行实用程序介绍相同的工作流。

通过使用 Windows 任务计划程序运行 Python 脚本,每两分钟更新一次实时流量数据。 示例假设 ArcGIS Server 安装位置为 C:\Program Files\ArcGIS\Server

schtasks /create /tn "ArcGISLiveTrafficDataUpdater" /tr "\"C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe\" \"C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\Resources\ArcToolBox\Services\routingservices\update_traffic_cache_scheduler.py\"" /sc minute /mo 2 /ru "SYSTEM"
注:

必须在多机 ArcGIS Server 站点中的每台计算机上执行上述步骤。

Python 脚本生成一个名为 update_traffic_cache_scheduler.log 的日志文件,该文件存储在 ArcGIS Server 写入其日志的默认文件夹中,如 c:\arcgisserver\logs 您可以检查此日志文件来确定脚本执行过程中是否发生任何错误。

检查实时流量数据状态

设置实时流量数据定期更新后,您可以通过运行 NetworkAnalysisUtilities 地理处理服务中的 GetLiveTrafficStatus 工具来验证流量数据是否更新成功。 此服务位于发布其他路径服务的同一文件夹中。 例如,如果路径服务发布到名为 Routing 的服务文件夹,则 GetLiveTrafficStatus 工具的 URL 将为 https://machine.example.com/webadaptorname/rest/services/Routing/NetworkAnalysisUtilities/GPServer/GetLiveTrafficStatusGetLiveTrafficStatus 的输出可用于检查流量数据是否成功更新。

GetLiveTrafficStatus 工具的示例输出显示,由于 isLastUpdateSuccessfultrue,因此上次更新成功。 如果上次更新期间出现错误,则 isLastUpdateSuccessful 设置为 false,并且失败的原因将作为 lastUpdatedMessages 属性的一部分返回。

{
 "results": [
  {
   "paramName": "status",
   "dataType": "GPString",
   "value": {
    "cachePath":  "C:\\NA\\RoutingServices\\traffic-cache\\openlr.3a795f46cf77473fb1dc606ef73a2cb5",
     "isLastUpdateSuccessful":  true,
     "isUpdateInProgress":  false,
     "roadClosuresDataAvailable":  true,
     "roadClosuresDataSize":  64427318,
     "speedDataAvailable":  true,
     "speedsDataSize":  3977019303,
     "tempDataSize":  365970076,
     "trafficCacheStatus":  {
     "endTimeWindow":  1744065360000,
      "lastCreatedFileNames":  [
      "speeds.20250407132800.1.ff.dat",
       "speeds.20250407213200.1.nff.dat",
       "road_closures.20250407213200.1.dat",
       "speeds.20250407213200.info.dat",
       "speeds.20250407213600.info.dat"
     ],
      "lastDecodingElapsedTime":  0,
      "lastRemovedFileNames":  [
      "speeds.20250407173200.info.dat",
       "road_closures.20250407173200.1.dat"
     ],
      "lastUpdatedElapsedTime":  11582,
      "lastUpdatedMessages":  [
      
     ],
      "lastUpdatedTime":  1744062137882,
      "remainingSpeedLocationsToMatch":  0,
      "roadClosureLocationsCount":  23153,
      "selectedTrafficDataRegions":  [
      "CAN",
       "MEX",
       "USA_N",
       "USA_SW",
       "USA_SE",
       "USA_M"
     ],
      "speedLocationsCount":  1468719,
      "startTimeWindow":  1744047330000
    }
   }
  }
 ],
 "messages": [
  
 ]
}