#Store the OBJECTID field for facilities as it will used later when exporting output facilities orig_input_facilities_oid = facilities_obj.origOIDFieldName #Store all the fields names from input facilities to be used later when exporting output facilities orig_input_facilities_fld_names = facilities_obj.fieldNames incidents_obj = nau.InputFeatureClass(incidents) point_barriers_obj = nau.InputFeatureClass(point_barriers) line_barriers_obj = nau.InputFeatureClass(line_barriers) polygon_barriers_obj = nau.InputFeatureClass(polygon_barriers) attribute_parameters_obj = nau.InputTable(attribute_parameters) #Keep a list of input copies so we can delete them just before exit input_copies = (facilities_obj, incidents_obj, point_barriers_obj, line_barriers_obj, polygon_barriers_obj, attribute_parameters_obj) #If the network dataset does not support hierarchy, set the useHierarchy parameter to false. nds_has_hierarchy = nau.nds_supports_hierarchy(desc_nds_attributes) if not nds_has_hierarchy: use_hierarchy = False #determine whether we should use time based or distance based impedance attribute based on measurement method impedance_attribute = time_attribute if measurement_method == "TRAVEL_TIME" else distance_attribute impedance_units = nau.verify_impedance_units(time_attribute, time_attribute_units, distance_attribute, distance_attribute_units, desc_nds_attributes, False)[impedance_attribute] #If the Cutoff is specified, convert the cutoff value from user specified unit to impedance unit if default_cutoff: converted_cutoff = nau.convert_units(default_cutoff, measurement_units,
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.
point_barriers_obj = nau.InputFeatureClass(point_barriers) line_barriers_obj = nau.InputFeatureClass(line_barriers) polygon_barriers_obj = nau.InputFeatureClass(polygon_barriers) attribute_parameters_obj = nau.InputTable(attribute_parameters) # Keep a list of input copies so we can delete them just before exit input_copies = ( facilities_obj, incidents_obj, point_barriers_obj, line_barriers_obj, polygon_barriers_obj, attribute_parameters_obj, ) # If the network dataset does not support hierarchy, set the useHierarchy parameter to false. nds_has_hierarchy = nau.nds_supports_hierarchy(desc_nds_attributes) if not nds_has_hierarchy: use_hierarchy = False # determine whether we should use time based or distance based impedance attribute based on measurement method impedance_attribute = time_attribute if measurement_method == "TRAVEL_TIME" else distance_attribute impedance_units = nau.verify_impedance_units( time_attribute, time_attribute_units, distance_attribute, distance_attribute_units, desc_nds_attributes, False )[impedance_attribute] # If the Cutoff is specified, convert the cutoff value from user specified unit to impedance unit if default_cutoff: converted_cutoff = nau.convert_units(default_cutoff, measurement_units, impedance_units) else: converted_cutoff = default_cutoff
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: