Connectivity Policies (arcpy)

摘要

提供有关边源和交汇点源所使用的连通性策略的信息。名称中包含 "X" 的属性为动态属性。"X" 的可能值取决于其他属性。例如,对于给定的边源,connSubtypeXconnPolicyX 为动态属性,属性中的 X 表示特定的子类型。X 值的允许范围取决于 subTypeConnCount 属性。因此,如果边源具有两个子类型,那么它将支持 connSubtype0connSubtype1connPolicy0connPolicy1 属性。

属性

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

For edge sources and junction sources.

A boolean indicating whether the given edge source or junction source determines connectivity groups and policies by subtypes.

Boolean
classConnectivity
(只读)

For edge sources and junction sources.

Indicates the policy determining how all edge elements in the given edge source or junction elements in the given junction source connect to each other. If the usesSubtypes property for a given edge source or junction source returns True, then this property should not be used to used to determine the connectivity policy. Instead, use the connPolicyX property for a particular subtype.

This property returns the following keywords for edge sources:

  • EndVertex
  • AnyVertex

This property returns the following keywords for junction sources:

  • Override
  • Honor
String
subtypeConnCount
(只读)

For edge sources and junction sources.

The total number of subtypes that are used to define connectivity policies for the given edge source or junction source. If the usesSubtypes property returns False, then this property returns 0.

Integer
connSubtypeX
(只读)

For edge sources and junction sources.

The subtype code used to define the subtype for the given edge feature source or junction feature source. connSubtypeX is a dynamic property that is supported only if the subTypeConnCount value is greater than 0.

Integer
connPolicyX
(只读)

For edge sources and junction sources.

Indicates the policy determining how all edge elements for a particular subtype in the given edge source connect to each other or how all junction elements for a particular subtype in the given junction source connect to each other. connPolicyX is a dynamic property that is supported only if the subTypeConnCount value is greater than 0.

This property returns the following keywords for edge sources:

  • EndVertex
  • AnyVertex

This property returns the following keywords for junction sources:

  • Override
  • Honor
String
defaultGroup
(只读)

For edge sources only.

The connectivity group in which this edge feature source participates.

If the usesSubtypes property returns True, then this property returns -1. In such a case, use the groupNameX property for a particular subtype.

Integer
groupCount
(只读)

For edge sources only.

The total number of subtypes that are used to define connectivity groups for the given edge source. If the usesSubtypes property returns False, then this property returns 0.

Integer
groupSubtypeX
(只读)

For edge sources only.

The subtype code used to define the subtype for the given edge feature source.groupSubtypeX is a dynamic property that is supported only if the groupCount value is greater than 0.

Integer
groupNameX
(只读)

For edge sources only.

The connectivity group in which the particular subtype of the given edge feature source participates. groupNameX is a dynamic property that is supported only if the groupCount value is greater than 0.

String
defaultGroupsCount
(只读)

For junction sources only.

The total number of connectivity groups to which a given junction source belongs. If the usesSubtypes property returns True, then use the subtypeXGroupsCount property to determine the total number of connectivity groups to which a particular subtype of a given junction source belongs.

If the usesSubtypes property returns True, then this property returns 0.

Integer
defaultGroupNameX
(只读)

For junction sources only.

The connectivity group in which this junction feature source participates. defaultGroupNameX is a dynamic property that is supported only if the defaultGroupsCount value is greater than 0. The possible range of values for X depends on the defaultGroupsCount property.

String
subtypeGroupCount
(只读)

For junction sources only.

The total number of subtypes that are used to define connectivity groups for the given junction source. If the usesSubtypes property returns False, then this property returns 0.

Integer
subtypeGroupX
(只读)

For junction sources only.

The subtype code used to define the subtype (indicated by X) for the given junction feature source. subtypeGroupX is a dynamic property that is supported only if the subtypeGroupCount value is greater than 0.

Integer
subtypeXGroupsCount
(只读)

For junction sources only.

The total number of connectivity groups to which a particular subtype (indicated by X) of a given junction source belongs. subtypeXGroupsCount is a dynamic property that is supported only if the subTypeGroupCount value is greater than 0.

Integer
subtypeXGroupNameX
(只读)

For junction sources only.

The connectivity group in which the particular subtype of the given edge feature source participates. groupNameX is a dynamic property that is supported only if the groupCount value is greater than 0.

String

代码实例

连通性策略属性示例 1

显示网络数据集中边源的连通性策略信息。

# Name: NDSConnectivityPolicies_ex01.py
# Description: Prints out the connectivity policy information about the
#              edge sources for a given network dataset 

import arcpy
import sys

# Set workspace
arcpy.env.workspace = "C:/Data/Paris.gdb/Transportation"

#Create a Describe object from the network dataset
desc = arcpy.Describe("ParisMultimodal_ND")

justify = 35
print ("------- Edge sources") 

# Get all the edge sources for the network dataset 
edgeSources = desc.edgeSources 

#If there are no edge sources, quit
if not edgeSources:
    print ("%*s" % (justify, "(No edge sources)")) 
    sys.exit(0)

for edgeSource in edgeSources:
    print (" %*s: %s" % (justify, "Source Name" , edgeSource.name))
    print (" %*s: %s" % (justify, "Source ID" , str(edgeSource.sourceID))) 
    print (" %*s: %s" % (justify, "Source Type", edgeSource.sourceType))
    print (" %*s: %s" % (justify, "Element Type", edgeSource.elementType))
    print (" %*s: %s" % (justify, "From Elevation Field",
                         edgeSource.fromElevationFieldName))
    print (" %*s: %s" % (justify, "To Elevation Field",
                         edgeSource.toElevationFieldName))
    # Get connectivity information
    conn = edgeSource.connectivityPolicies 
    # Check if subtypes are used for edge sources to define connectivity groups
    #and policies
    bUseSubtypes = conn.usesSubtypes 
    print(" %*s: %s" % (justify, "Connectivity defined by subtype?",
                        str(conn.usesSubtypes)))
    
    #Print connectivity policy information depending on the use of subtypes 
    if not bUseSubtypes:
        print("%*s: %s" %(justify,"Connectivity Policy",conn.classConnectivity)) 
    else: 
        # Connectivity policy by subtype
        print(" %*s: %s" % (justify, "Number of subtypes",
                            str(conn.subtypeConnCount))) 
        for i in range(0, conn.subtypeConnCount):
            subtypeCode = getattr(conn, "connSubtype" + str(i)) 
            policy = getattr(conn, "connPolicy" + str(i))
            print(" %*s: %s" %(justify, "Subtype Code",subtypeCode))  
            print(" %*s: %s" % (justify, "... has connectivity policy", policy))
    
    # Print connectivity Group information depending on the use of subtypes
    if not bUseSubtypes: 
        print("%*s: %s" % (justify,"Belongs to Connectivity Group",
                           conn.defaultGroup))         
    else: 
        # Connectivity group by subtype
        print(" %*s: %s" %(justify,"Number of subtypes for connectivity groups",
                          conn.groupCount))
        for i in range(0, conn.groupCount): 
            subtypeCode = getattr(conn, "groupSubtype" + str(i)) 
            name = getattr(conn, "groupName" + str(i)) 
            print( "%*s: %s" %(justify,"Subtype Code", subtypeCode)) 
            print("%*s: %s" %(justify,"... belongs to connectivity group",name))
    print(" ")
连通性策略属性示例 2

显示网络数据集中交汇点源的连通性策略信息。

# Name: NDSConnectivityPolicies_ex02.py
# Description: Prints out the connectivity policy information about the
#              junction sources for a given network dataset 

import arcpy
import sys

# Set workspace
arcpy.env.workspace = "C:/Data/Paris.gdb/Transportation"

#Create a Describe object from the network dataset
desc = arcpy.Describe("ParisMultimodal_ND")

justify = 35
print ("------- Junction sources") 

#Get all the junction sources for the network dataset
junctions = desc.junctionSources

#If there are no junction sources, quit
if not junctions: 
    print " %*s" % (justify, "(No junction sources)")    
    sys.exit(0) 
 
for junction in junctions:
    print (" %*s: %s" % (justify, "Source Name" , junction.name))
    print (" %*s: %s" % (justify, "Source ID" , str(junction.sourceID))) 
    print (" %*s: %s" % (justify, "Source Type", junction.sourceType))
    print (" %*s: %s" % (justify, "Element Type", junction.elementType))
    print (" %*s: %s" % (justify, "Elevation Field",
                         junction.elevationFieldName)) 

    # system junctions do not support connectivity information 
    sourcetype = junction.sourceType 
    if sourcetype.lower() != "junctionfeature":  
        continue 
    #Get the connectivity policies
    conn = junction.connectivityPolicies 
    if not conn:  
        continue 
    # Connectivity can be defined based on subtypes 
    bUseSubtypes = conn.usesSubtypes 
    print (" %*s: %s" % (justify + 5, "Connectivity defined by subtype?" , 
                         str(conn.usesSubtypes))) 
    if not bUseSubtypes: 
        print (" %*s: %s" % (justify + 5, "Connectivity policy" , 
                             conn.classConnectivity)) 
        outtext = "Belongs to %d different connectivity groups" % conn.defaultGroupsCount 
        print " %*s" % (justify + 5, outtext) 
        defgrouplist = []
        for i in range(0,conn.defaultGroupsCount): 
            defgrouplist.append(str(getattr(conn, "defaultGroupName" + str(i))))
        print ("%*s: %s" % (justify + 5,"... belongs to connectivity group(s)",
                            " ".join(defgrouplist))) 
    else: 
        print (" %*s: %s" % (justify + 5, "Number of subtypes" ,
                             str(conn.subtypeConnCount)))
        for i in range(0, conn.subtypeConnCount): 
            st = getattr(conn, "connSubtype" + str(i))
            policy = getattr(conn,"connPolicy" + str(i))
            print (" ")
            print (" %*s: %s" % (justify + 10, "Subtype value" , st)) 
            print (" %*s: %s" % (justify + 10, "...has connectivity policy" ,
                                  policy)) 
        
        print ("") 
        for i in range(0, conn.subtypeGroupCount): 
            stGroup = getattr(conn, "subtypeGroup" + str(i)) 
            print (" %*s: %d" % (justify + 10, "Subtype value", stGroup)) 
            count = getattr(conn, "subtype" + str(i) + "GroupsCount")
            grouplist = []
            for j in range(0, count): 
                key = getattr(conn,"subtype%dGroupName%d" % (i,j))
                grouplist.append(str(key)) 
            print (" %*s %s" % (justify + 10, "...belongs to connectivity group(s)",
                                " ".join(grouplist))) 
            
            print ("") 
    print (" ")
5/10/2014