) if str_max_features_line_barriers else INFINITY max_features_polygon_barriers = int( str_max_features_polygon_barriers ) if str_max_features_polygon_barriers else INFINITY max_facilities = int( str_max_facilities) if str_max_facilities else INFINITY max_facilities_to_find = int( str_max_facilities_to_find) if str_max_facilities_to_find else INFINITY max_incidents = int(str_max_incidents) if str_max_incidents else INFINITY force_hierarchy_beyond_distance = float( str_force_hierarchy_beyond_distance ) if str_force_hierarchy_beyond_distance else INFINITY #Check if the output feature class names are valid. Fail with first invalid name nau.check_valid_table_name( out_routes_name, out_gdb_workspace, 30101, parameter_info[parameter_index['out_routes_name']].displayName) nau.check_valid_table_name( out_directions_name, out_gdb_workspace, 30101, parameter_info[parameter_index['out_directions_name']].displayName) nau.check_valid_table_name( out_facilities_name, out_gdb_workspace, 30101, parameter_info[parameter_index['out_facilities_name']].displayName) desc_nds = arcpy.Describe(network_dataset) desc_nds_attributes = desc_nds.attributes #Convert all input features to feature sets or recordsets if they are not #This is required as if input is passed a feature layer or feature class #We will end up directly modifying the inputs
pointBarriers = point_barriers_obj.catalogPath if line_barriers_obj.count: line_barriers_obj.copyFeatures(out_workspace, LINE_BARRIER_FIELDS) lineBarriers = line_barriers_obj.catalogPath if polygon_barriers_obj.count: polygon_barriers_obj.copyFeatures(out_workspace, POLYGON_BARRIER_FIELDS) polygonBarriers = polygon_barriers_obj.catalogPath if attribute_parameters_obj.count: attribute_parameters_obj.copyFeatures(out_workspace, ATTRIBUTE_PARAMETER_FIELDS) attributeParameters = attribute_parameters_obj.catalogPath #If the network dataset does not support hierarchy, set the useHierarchy parameter to false. ndsSupportsHierarchy = nau.nds_supports_hierarchy(descNDSAttributes) if not ndsSupportsHierarchy: useHierarchy = False isTrimDistanceZero = False if not polygonTrimDistance or polygonTrimDistance.split(" ")[0] == '0': isTrimDistanceZero = True #determine whether we should use time based or distance based impedance attribute based on break units #using python ternary operator here. impedanceAttribute = timeImpedance if breakUnits.lower() in TIME_UNITS else distanceImpedance #get the user supplied break values as list for easy processing breakValueList = [val.encode("utf-8") for val in breakValues.strip().split()] breakValueCount = len(breakValueList) if breakValueCount == 0: arcpy.AddIDMessage("ERROR",30117) raise nau.InputError() #Find the largest break value.
# Convert constraint values from strings to number. If empty string use max Int max_features_point_barriers = int(str_max_features_point_barriers) if str_max_features_point_barriers else INFINITY max_features_line_barriers = int(str_max_features_line_barriers) if str_max_features_line_barriers else INFINITY max_features_polygon_barriers = ( int(str_max_features_polygon_barriers) if str_max_features_polygon_barriers else INFINITY ) max_facilities = int(str_max_facilities) if str_max_facilities else INFINITY max_facilities_to_find = int(str_max_facilities_to_find) if str_max_facilities_to_find else INFINITY max_incidents = int(str_max_incidents) if str_max_incidents else INFINITY force_hierarchy_beyond_distance = ( float(str_force_hierarchy_beyond_distance) if str_force_hierarchy_beyond_distance else INFINITY ) # Check if the output feature class names are valid. Fail with first invalid name nau.check_valid_table_name( out_routes_name, out_gdb_workspace, 30101, parameter_info[parameter_index["out_routes_name"]].displayName ) nau.check_valid_table_name( out_directions_name, out_gdb_workspace, 30101, parameter_info[parameter_index["out_directions_name"]].displayName, ) nau.check_valid_table_name( out_facilities_name, out_gdb_workspace, 30101, parameter_info[parameter_index["out_facilities_name"]].displayName, ) desc_nds = arcpy.Describe(network_dataset)
strMaxBreakTime) if strMaxBreakTime else INFINITY maxBreakDistance = locale.atof( strMaxBreakDistance) if strMaxBreakDistance else INFINITY forceHierarchyTime = locale.atof( strForceHierarchyTime) if strForceHierarchyTime else INFINITY forceHierarchyDistance = locale.atof( strForceHierarchyDistance) if strForceHierarchyDistance else INFINITY descNDS = arcpy.Describe(networkDataset) descNDSAttributes = descNDS.attributes #Convert all input features to feature sets or recordsets if they are not #This is required as if input is passed a feature layer or feature class #We will end up directly modifying the inputs facilities_obj = nau.InputFeatureClass(facilities) #Store the OBJECTID field for facilities as it will used later when exporting output facilities orig_input_facilities_oid_fld_name = facilities_obj.origOIDFieldName #Store the describe object and all the fields names from input facilities to be used later when exporting output facilities orig_input_facilities_desc = facilities_obj.describeObject #orig_input_facilities_fld_aliases = {f.name:f.aliasName for f in orig_input_facilities_desc.fields} point_barriers_obj = nau.InputFeatureClass(pointBarriers) line_barriers_obj = nau.InputFeatureClass(lineBarriers) polygon_barriers_obj = nau.InputFeatureClass(polygonBarriers) attribute_parameters_obj = nau.InputTable(attributeParameters) #Keep a list of input copies so we can delete them just before exit input_copies = (facilities_obj, point_barriers_obj, line_barriers_obj, polygon_barriers_obj, attribute_parameters_obj) #Get counts for facilities, incidents, barrier features and attribute parameters facility_count = facilities_obj.count