Zusammenfassung
Provides read and write access to street directions properties, allowing you to customize the directions output from your network analysis layers. The StreetDirectionsProperties can be read from and set on a SolverProperties object obtained through the GetSolverProperties function.
Auswertung
The StreetDirectionsProperties object provides read and write access to street directions properties, allowing you to customize the directions output from your network analysis layers.
Properties that can be read and set include language, lengthUnits, styleName, timeAttribute, outputSpatialReference.
The StreetDirectionsProperties object is only available on Route, Closest Facility, and Vehicle Routing Problem network analysis layers. The other network analysis layer types do not support output directions. Additionally, the StreetDirectionsProperties object will not be available on network analysis layers built on network datasets that don't support directions. A Python None object will be returned if the layer is not supported.
After modifying the properties of the StreetDirectionsProperties object, the corresponding layer can be immediately used with other functions and geoprocessing tools. There is no refresh or update of the layer required to honor the changes modified through the object.
Eigenschaften
Eigenschaft | Erläuterung | Datentyp |
language (Lesen und schreiben) | Specifies the language in which the output text directions are written. Available languages depend on the languages installed on your machine and can be checked using the ListDirectionsLanguages function. | String |
lengthUnits (Lesen und schreiben) | Specifies the distance units used to measure lengths in the output text directions. The units must be one of the following string values:
| String |
styleName (Lesen und schreiben) | Specifies the style of the output text directions. Different styles are available for different applications, such as printing, using on a navigation device, or routing a pedestrian. Available styles depend upon the styles installed on your machine and can be checked using the ListDirectionsStyleNames function. | String |
timeAttribute (Lesen und schreiben) | Specifies the time-based network dataset cost attribute that is used to calculate the travel time in the output directions. The available timeAttribute values are a property of the network dataset. You can list the cost attributes in your network dataset using a network dataset describe object. | String |
outputSpatialReference (Lesen und schreiben) | Indicates the spatial reference for the output directions feature class. Input to this attribute must be a spatial reference object. | SpatialReference |
Codebeispiel
StreetDirectionsProperties example (Workflow)
Reads a route layer, sets its length units to kilometers, and generates directions features.
import arcpy
try:
arcpy.CheckOutExtension("network")
#Get the route layer object from a layer named "Route" in
#the table of contents.
RouteLayer = arcpy.mapping.Layer(r'C:\Data\Route.lyr')
# Get the solver properties of the layer.
SolverProps = arcpy.na.GetSolverProperties(RouteLayer)
# Get the street directions properties
DirectionsProps = SolverProps.streetDirectionsProperties
# Set the lengthUnits to Kilometers
DirectionsProps.lengthUnits = "Kilometers"
# Set the outputSpatialReference to web mercator
sr = arcpy.SpatialReference(3785)
DirectionsProps.outputSpatialReference = sr
# Get the time attribute used for directions for use later
timeAttribute = DirectionsProps.timeAttribute
#Generate directions features and save them to disk.
arcpy.na.GenerateDirectionsFeatures(RouteLayer,
r'C:\Data\Directions.gdb\RouteDirections')
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "An error occured on line %i" % tb.tb_lineno
print str(e)