描述
提供特定网络分析求解程序的分析属性。
说明
所有网络分析求解程序共有的属性(如 impedance)可通过描述网络分析图层直接确定。但部分属性如 UseTimeWindows 仅由特定的求解程序支持,如此例中的路径求解程序。因此,网络分析求解程序对象的可用属性取决于网络分析图层所引用的求解程序。使用 solverName 属性确定网络分析图层将引用的求解程序,并使用下面的链接确定对象的可用属性。
代码示例
网络分析求解程序属性示例
显示网络分析求解程序对象的属性。
# Name: NALayerSolverProperties_ex01.py
# Description: Lists all the solver specific properties that can be
# derived by describing a network analysis layer.
import arcpy
# ============
# Helper functions
# ============
def printRoute(justify=35):
'''Displays information about a Route layer'''
arcpy.AddMessage("---- Route properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Find Best Sequence?",
props.findBestSequence))
arcpy.AddMessage(" %*s: %s" % (justify, "OrderingType",
props.orderingType))
arcpy.AddMessage(" %*s: %s" % (justify, "Use Time Windows?",
props.useTimeWindows))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.routesShape))
arcpy.AddMessage(" %*s: %s" % (justify, "Start Time", props.startTime))
def printClosestFac(justify=35):
'''Displays information about a Closest Facility layer'''
arcpy.AddMessage("---- Closest Facilty properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel Direction",
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Target Facility Count",
props.defaultTargetFacilityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.cfRoutesShape))
def printServiceArea(justify=35):
'''Displays information about a Service Area layer'''
arcpy.AddMessage("---- Service Area properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel Direction",
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Default breaks",
props.defaultBreaks))
# Polygon info
arcpy.AddMessage(" ")
arcpy.AddMessage(" %*s: %s" % (justify, "Polygon Type?",
props.serviceAreaPolygons))
arcpy.AddMessage(" %*s: %s" % (justify, "Overlap Type",
props.serviceAreaPolygonType))
arcpy.AddMessage(" %*s: %s" % (justify, "Multiple Facilities Options?",
props.mergeSimilarRanges))
arcpy.AddMessage(" %*s: %s" % (justify, "Excluded sources",
props.exclusionSources))
arcpy.AddMessage(" %*s: %s" % (justify, "Trim Polygons?",
props.trimPolygons))
arcpy.AddMessage(" %*s: %s" % (justify, "Trim Distance?",
props.trimDistance))
# Line info
arcpy.AddMessage(" ")
arcpy.AddMessage(" %*s: %s" % (justify, "Line overlap type",
props.serviceAreaLinesType))
arcpy.AddMessage(" %*s: %s" % (justify, "Split lines at breaks?",
props.splitLinesAtBreaks))
arcpy.AddMessage(" %*s: %s" % (justify, "Output line shape",
props.serviceAreaLines))
arcpy.AddMessage(" %*s: %s" % (justify, "Output line shape",
props.includeNetworkSourceFields))
def printODMatrix(justify=40):
'''Displays information about an OD Cost Matrix layer.'''
arcpy.AddMessage("---- OD Cost Matrix properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Target Destination Count",
props.defaultTargetDestinationCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.odLinesShape))
def printVRP(justify=35):
'''Displays information about a Vehicle routing problem layer'''
arcpy.AddMessage("---- Vehicle Routing Problem properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Default Date",
props.defaultDate))
arcpy.AddMessage(" %*s: %s" % (justify, "Capacity Count",
props.capacityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Time Field Units",
props.timeFieldUnits))
arcpy.AddMessage(" %*s: %s" % (justify, "Distance Field Units",
props.distanceFieldUnits))
arcpy.AddMessage(" %*s: %s" % (justify, "Output Route Shape",
props.vrpRoutesShape))
arcpy.AddMessage(" %*s: %s"%(justify,"Time window violation penalty factor",
props.timeWindowViolationPenaltyFactor))
arcpy.AddMessage(" %*s: %s"%(justify,"Penalty factor value",
props.timeWindowViolationPenaltyFactorValue))
arcpy.AddMessage(" %*s: %s" % (justify,"Excess transit time penalty factor",
props.excessTransitTimePenaltyFactor))
arcpy.AddMessage(" %*s: %s" % (justify,"Penalty factor value",
props.excessTransitTimePenaltyFactorValue))
def printLocationAllocation(justify=35):
'''Displays information about a Location-Allocation layer'''
arcpy.AddMessage("---- Location-Allocation properties:")
props = desc.solverProperties
arcpy.AddMessage(" %*s: %s" % (justify, "Layer Name?" , desc.nameString))
arcpy.AddMessage(" %*s: %s" % (justify, "Travel from" ,
props.travelDirection))
arcpy.AddMessage(" %*s: %s" % (justify, "Location-allocation problem type",
props.problemType))
arcpy.AddMessage(" %*s: %s" % (justify, "Number of facilities to find",
props.defaultTargetFacilityCount))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance cutoff",
props.defaultCutoff))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance transformation",
props.impedanceTransformation))
arcpy.AddMessage(" %*s: %s" % (justify, "Impedance parameter",
props.impedanceParameter))
arcpy.AddMessage(" %*s: %s" % (justify, "Target market share",
props.targetMarketShare))
arcpy.AddMessage(" %*s: %s" % (justify, "Output path shape",
props.laLinesShape))
# ============
# main module
# ============
# Get the arguments..
in_layer = "C:/Data/Route.lyr"
justify = 35
#Describe the layer file and get the solver name
desc = arcpy.Describe(in_layer)
solvername = desc.solvername
# Branch on type of solver (Route, Closest Facility, etc)
if solvername.lower() == "route solver":
printRoute(justify)
elif solvername.lower() == "closest facility solver":
printClosestFac(justify)
elif solvername.lower() == "service area solver":
printServiceArea(justify)
elif solvername.lower() == "od cost matrix solver":
printODMatrix(justify)
elif solvername.lower() == "vehicle routing problem solver":
printVRP(justify)
elif solvername.lower() == "location-allocation solver":
printLocationAllocation(justify)
else:
arcpy.AddError("Unknown solver: %s" % solvername)
arcpy.AddMessage(" ")
arcpy.AddMessage("==== End description ====")
arcpy.AddMessage(" ")