VehicleRoutingProblemResult

摘要

可以使用包含车辆配送问题分析结果的对象访问输出和求解程序消息。

说明

此类实例无法直接创建, 而是由 VehicleRoutingProblem 类的 solve 方法返回。

属性

属性说明数据类型
isPartialSolution
(只读)

如果求解程序产生了部分解决方案,则将返回 True,这意味着并非所有输入都包含在结果中。 如果其中一个输入未定位并且求解程序类的 ignoreInvalidLocations 属性被设置为 True,则会发生这种情况。

Boolean
solveSucceeded
(只读)

如果求解程序成功执行,则将返回 True

Boolean
spatialReference
(只读)

返回输出要素的空间参考。 例如,通过 export 方法创建的要素类和从 searchCursor 方法检索的几何对象将具有此空间参考。 通常,spatialReference 值为分析中所用的网络数据集或服务的空间参考。

SpatialReference

方法概述

方法说明
count (output_type)

返回输出类型的行数。

export (output_type, output_features)

将分析结果导出到要素类或表。

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,如果将 VehicleRoutingProblem 对象的 returnStopShapes 属性设置为 False,则导出的 VehicleRoutingProblemOutputDataType.StopsVehicleRoutingProblemOutputDataType.UnassignedStops 输出将为表格。如果将 returnStopShapes 设置为 True,则导出的输出将为具有几何的要素类。

extent ({output_type})

返回分析输出的范围。

如果分析求解失败,此方法将返回 RuntimeError 异常。

fieldNames (output_type)

返回指定输出类型支持的字段名称列表。

saveAsLayerFile (file_name)

将分析结果和设置保存到图层文件或图层包。 可以在 ArcGIS Pro 中将图层文件或包作为分析设置记录打开或用于可视化结果。 也可以在 ArcGIS Desktop 中打开图层文件。

如果求解程序对象上的 allowSaveLayerFile 属性设置为 False,该方法将返回 RuntimeError 异常。

旧版本:

基于运行 10.9 之前版本 ArcGIS Enterprise 的门户的路径服务不支持保存图层包。 在这种情况下,该方法将返回 RuntimeError 异常。

saveRouteData (file_name)

将来自分析的输出保存为 .zip 文件。.zip 文件可使用 共享为路径图层工具,在 ArcGIS OnlineArcGIS Enterprise 中将来自分析的路径共享为路径图层项目。

路径图层项目可供各种应用程序使用(例如 ArcGIS Navigator)来为外业工作人员提供路径指引,可供 Map Viewer 中的方向窗格来进一步自定义路径图层中包含的路径,或可供 ArcGIS Pro 基于路径图层来创建新的路径分析图层。

输出要素将在用于分析的网络数据集的空间参考中创建。如果已设置 arcpy.env.outputCoordinateSystem 环境,则将在该空间参考中创建输出。

如果求解失败,则 saveRouteData 将返回 RuntimeError 异常。

如果求解程序对象上的 allowSaveRouteData 属性设置为 False,该方法将返回 RuntimeError 异常。

searchCursor (output_type, field_names, {where_clause})

在指定的输出类型上建立搜索光标。 此游标可用于直接从输出读取行。

solverMessages (severity)

获取求解程序返回的错误、警告和信息性消息。

方法

count (output_type)
参数说明数据类型
output_type

用于计数的输出要素类型。

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,应使用 VehicleRoutingProblemOutputDataType 枚举设置此参数;在使用 VehicleRoutingProblemSchemaVersion.Two 方案版本时,应使用 VehicleRoutingProblemOutputDataType2 枚举设置此参数。

Object
返回值
数据类型说明
Integer

行数。

不引发任何异常。

export (output_type, output_features)
参数说明数据类型
output_type

要导出的输出类型。

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,应使用 VehicleRoutingProblemOutputDataType 枚举设置此参数;在使用 VehicleRoutingProblemSchemaVersion.Two 方案版本时,应使用 VehicleRoutingProblemOutputDataType2 枚举设置此参数。

See descriptions of the fields included in each output type when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemSchemaVersion.Two schema version.

Object
output_features

包含导出要素的输出要素类或表的目录路径。

String
extent ({output_type})
参数说明数据类型
output_type

The type of output features for which to get the extent.

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,应使用 VehicleRoutingProblemOutputDataType 枚举设置此参数;在使用 VehicleRoutingProblemSchemaVersion.Two 方案版本时,应使用 VehicleRoutingProblemOutputDataType2 枚举设置此参数。

If you do not specify a value, or you specify a value of None, the extent for the combined analysis outputs is returned.

Object
返回值
数据类型说明
Extent

arcpy.Extent 对象用于指示指定输出类型的范围。

fieldNames (output_type)
参数说明数据类型
output_type

要返回其字段名称列表的输出类型。

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,应使用 VehicleRoutingProblemOutputDataType 枚举设置此参数;在使用 VehicleRoutingProblemSchemaVersion.Two 方案版本时,应使用 VehicleRoutingProblemOutputDataType2 枚举设置此参数。

See descriptions of the fields included in each output type when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemSchemaVersion.Two schema version.

Object
返回值
数据类型说明
String

指定输出类型支持的字段名称列表。

saveAsLayerFile (file_name)
参数说明数据类型
file_name

The catalog path of the output layer file (.lyr) or layer package (.lpkx) to write.

String
saveRouteData (file_name)
参数说明数据类型
file_name

输出 .zip 文件的完整路径。

String
searchCursor (output_type, field_names, {where_clause})
参数说明数据类型
output_type

The type of output to read.

在使用 VehicleRoutingProblemSchemaVersion.One 方案版本时,应使用 VehicleRoutingProblemOutputDataType 枚举设置此参数;在使用 VehicleRoutingProblemSchemaVersion.Two 方案版本时,应使用 VehicleRoutingProblemOutputDataType2 枚举设置此参数。

Object
field_names
[field_names,...]

A list of field names of the output type whose values the cursor will return. You can get the names of the fields that are supported by an output type using the fieldNames method.

See descriptions of the fields included in each output type when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemSchemaVersion.Two schema version.

In addition to regular fields, you can also access the geometry of the output using one of the following geometry tokens:

  • SHAPE@XYA tuple of the feature's centroid's X and Y coordinates.
  • SHAPE@XYZA tuple of the feature's centroid's X, Y, and Z coordinates.
  • SHAPE@JSON The Esri JSON string representing the geometry.
  • SHAPE@WKBThe well-known binary (WKB) representation for OGC geometry. It provides a portable representation of a geometry value as a contiguous stream of bytes.
  • SHAPE@WKTThe well-known text (WKT) representation for OGC geometry. It provides a portable representation of a geometry value as a text string.
  • SHAPE@A geometry object for the feature.

The SHAPE@XY and SHAPE@XYZ tokens are only supported for point-based output types. The x-, y-, and z-values returned when using the SHAPE@XY and SHAPE@XYZ tokens are in the spatial reference reported by the solver result object's spatialReference property, and this is typically the same as the spatial reference of the network data source used for the analysis.

String
where_clause

用于限制所返回的记录的可选表达式。 有关 where 子句和 SQL 语句的详细信息,请参阅在 ArcGIS 中使用的查询表达式的 SQL 参考

(默认值为 None)

String
返回值
数据类型说明
Object

从输出读取行的 SolverResultSearchCursor 对象。

solverMessages (severity)
参数说明数据类型
severity

要返回的消息类型。

应使用 MessageSeverity 枚举指定此参数。

Object
返回值
数据类型说明
List

返回的消息为由 列表组成的列表。内部列表包含两个值;第一个值为表示消息代码的数字,第二个值为消息文本。

从失败的起点 - 目的地成本矩阵分析返回的消息列表的示例。

[[-2147200995, '0 location(s) in "Destinations" are valid.  Need at least 1 valid location(s).'],
 [30024, 'Solve returned a failure.'],
 [-2147200995, 'Insufficient number of valid locations in "Origins" or "Destinations".']]