Résumé
Provides the ability to map field names or set default values for the properties of a network analysis class within a network analysis layer. The properties of the network analysis class are used as inputs by the solvers while performing the network analyses.
Discussion
The NAClassFieldMap object cannot be instantiated by itself. It is obtained by instantiating an NAClassFieldMappings object, which returns a collection of NAClassFieldMap objects as a Python dictionary. The dictionary keys are the network analysis class property names, and the values are the NAClassFieldMap objects.
Propriétés
Propriété | Explication | Type de données |
defaultValue (Lecture/écriture) | Provides the ability to get or set the default value for the property represented by the NAClassFieldMap object. The value can be specified as a string representation of the value or as a value of the data type for the property. For example, the Curb Approach property can have default value specified as number 1 or as a string "1". The default value cannot be set for the Locations property in the Line Barriers and Polygon Barriers sublayer as they require BLOB values. If both mappedFieldName and defaultValue properties are specified for a property, the default value is used only if the feature attribute value corresponding to the mapped field has a null value. | Variant |
mappedFieldName (Lecture/écriture) | Provides the ability to get or set the field name from an input feature class or table that is used to derive the value for the property. If the feature attribute value corresponding to the mapped field has a null value, the value specified for the defaultValue property is used. | String |
propertyName (Lecture seule) | The name of the property for which a default value or a mapped field name is specified using the NAClassFieldMap object. | String |
Exemple de code
NAClassFieldMap Example (Python window)
The following script shows how to load fire stations as facilities into an existing service area layer and specify a delay of 10 minutes when loading the facilities using the NAClassFieldMappings object. It assumes that a service area network analysis layer called Fire Stations Coverage, created from the tutorial network dataset for the San Francisco region, and a feature layer called FireStations are already added to an existing map document.
#Get the service area layer called "Fire Stations Coverage" from the table of contents
saLayer = arcpy.mapping.Layer("Fire Stations Coverage")
#Get the list of fields from the FireStations feature layer in the table of contents
fields = arcpy.ListFields("FireStations")
#Get the facilities sublayer name from the service area layer. Note that we are not
#using a string called "Facilities" because the sublayer name can be
#different if using ArcGIS on a non-english operating system.
facilitiesSubLayerName = arcpy.na.GetNAClassNames(saLayer)["Facilities"]
#Create a field mappings object for facilities sublayer based on the fields from
#FireStations layer
fieldMappings = arcpy.na.NAClassFieldMappings(saLayer, facilitiesSubLayerName,
False, fields)
#Get the field map corresponding to the "Attr_TravelTime" property of facilities
fieldMap = fieldMappings["Attr_TravelTime"]
#Set a delay of 10 minutes for the facilities
fieldMap.defaultValue = 10
#Load the fire stations as service area facilities using the field mappings
arcpy.na.AddLocations(saLayer, facilitiesSubLayerName, "FireStations", fieldMappings)