VehicleRoutingProblemResult

Synthèse

An object containing the results of a vehicle routing problem analysis that can be used to access outputs and solver messages.

Discussion

Instances of this class cannot be created directly. Instead, they are returned by the solve method of the VehicleRoutingProblem class.

Learn more about how to use the result object to access and work with the analysis outputs

Propriétés

PropriétéExplicationType de données
isPartialSolution
(Lecture seule)

Returns True if the solver produced a partial solution, meaning that not all inputs were included in the results. This can occur if one of the inputs is unlocated and the solver class's ignoreInvalidLocations property is set to True.

Boolean
solveSucceeded
(Lecture seule)

Returns True if the solve was successful.

Boolean
spatialReference
(Lecture seule)

Returns the spatial reference of the output features. For example, feature classes created using the export method and geometry objects retrieved from the searchCursor method will have this spatial reference. The spatialReference value is typically the spatial reference of the network dataset or service used in the analysis.

SpatialReference

Vue d’ensemble des méthodes

MéthodeExplication
count (output_type)

Returns the number of rows for an output type.

export (output_type, output_features)

Exports the analysis results to a feature class or table.

When using the VehicleRoutingProblemSchemaVersion.One schema version, if the VehicleRoutingProblem object's returnStopShapes property is set to False, the exported output of VehicleRoutingProblemOutputDataType.Stops and VehicleRoutingProblemOutputDataType.UnassignedStops will be tables. If returnStopShapes is set to True, the exported output will be feature classes with geometry.

extent ({output_type})

Returns the extent of the analysis output.

The method returns a RuntimeError exception if the analysis solve failed.

fieldNames (output_type)

Returns a list of field names supported by a specified output type.

saveAsLayerFile (file_name)

Save the analysis result and settings to a layer file or layer package. The layer file or package can be opened in ArcGIS Pro as a record of the analysis settings or to visualize the results. A layer file can also be opened in ArcGIS Desktop.

The method returns a RuntimeError exception if the allowSaveLayerFile property on the solver object is set to False.

Héritage :

Routing services based on portals running versions of ArcGIS Enterprise older than 10.9 do not support saving layer packages. The method returns a RuntimeError exception if this is the case.

saveRouteData (file_name)

Save the outputs from the analysis to a .zip file. The .zip file can be used to share the routes from the analysis as route layer items in ArcGIS Online or ArcGIS Enterprise using the Share As Route Layers tool.

Un élément de couche d’itinéraire peut être utilisé par diverses applications. Dans ArcGIS Navigator, par exemple, il permet de guider les équipes dépêchées sur le terrain, via la fenêtre Directions (Feuille de route) du module Map Viewer Classic afin de personnaliser davantage l’itinéraire figurant dans la couche d’itinéraire ou via ArcGIS Pro pour créer une couche d’analyse d’itinéraires à partir d’une couche d’itinéraire.

The output features will be created in the spatial reference of the network dataset used for analysis. If the arcpy.env.outputCoordinateSystem environment has been set, the output will be created in that spatial reference instead.

If the solve fails, saveRouteData returns a RuntimeError exception.

The method returns a RuntimeError exception if the allowSaveRouteData property on the solver object is set to False.

searchCursor (output_type, field_names, {where_clause})

Establishes a search cursor on the specified output type. This cursor can be used to read rows directly from the output.

solverMessages (severity)

Get error, warning, and informational messages returned by the solver.

Méthodes

count (output_type)
ParamètreExplicationType de données
output_type

The type of output features to count.

The parameter should be set using the VehicleRoutingProblemOutputDataType enumeration when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemOutputDataType2 enumeration when using the VehicleRoutingProblemSchemaVersion.Two schema version.

Object
Valeur renvoyée
Type de donnéesExplication
Integer

The number of rows.

Raises no exception.

export (output_type, output_features)
ParamètreExplicationType de données
output_type

The type of output to export.

The parameter should be set using the VehicleRoutingProblemOutputDataType enumeration when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemOutputDataType2 enumeration when using the VehicleRoutingProblemSchemaVersion.Two schema version.

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

The catalog path to the output feature class or table that will contain the exported features.

String
extent ({output_type})
ParamètreExplicationType de données
output_type

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

The parameter should be set using the VehicleRoutingProblemOutputDataType enumeration when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemOutputDataType2 enumeration when using the VehicleRoutingProblemSchemaVersion.Two schema version.

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

Object
Valeur renvoyée
Type de donnéesExplication
Extent

An arcpy.Extent object indicating the extent of the designated output type.

fieldNames (output_type)
ParamètreExplicationType de données
output_type

The type of output for which to return a list of field names.

The parameter should be set using the VehicleRoutingProblemOutputDataType enumeration when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemOutputDataType2 enumeration when using the VehicleRoutingProblemSchemaVersion.Two schema version.

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

Object
Valeur renvoyée
Type de donnéesExplication
String

A list of field names supported by the specified output type.

saveAsLayerFile (file_name)
ParamètreExplicationType de données
file_name

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

Attention :

Layer files with an .lyr extension cannot be saved if the solver object uses a service URL as its network data source. The method returns a RuntimeError exception in this case.

String
saveRouteData (file_name)
ParamètreExplicationType de données
file_name

The full path of the output .zip file.

String
searchCursor (output_type, field_names, {where_clause})
ParamètreExplicationType de données
output_type

The type of output to read.

The parameter should be set using the VehicleRoutingProblemOutputDataType enumeration when using the VehicleRoutingProblemSchemaVersion.One schema version or the VehicleRoutingProblemOutputDataType2 enumeration when using the VehicleRoutingProblemSchemaVersion.Two schema version.

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

Expression optionnelle qui limite les enregistrements retournés. Pour plus d’informations sur les clauses WHERE et les instructions SQL, voir Référence SQL pour les expressions de requête utilisées dans ArcGIS.

(La valeur par défaut est None)

String
Valeur renvoyée
Type de donnéesExplication
Object

A SolverResultSearchCursor object that reads rows from the output.

solverMessages (severity)
ParamètreExplicationType de données
severity

The type of messages to be returned.

The parameter should be specified using the MessageSeverity enumeration.

Object
Valeur renvoyée
Type de donnéesExplication
List

The messages are returned as a list of lists. The inner list contains two values; the first is a number representing the message code, and the second value is the message text.

An example of a list of messages returned from a failed origin destination cost matrix analysis.

[[-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".']]