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 #Get counts for facilities, incidents, barrier features and attribute parameters facility_count = facilities_obj.count incident_count = incidents_obj.count #Convert inputs from record sets to feature classes if they are not empty.
#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. try: endBreakValue = max([locale.atof(val) for val in breakValueList]) except ValueError: arcpy.AddIDMessage("ERROR",30118) raise nau.InputError() impedanceUnit = nau.verify_impedance_units(timeImpedance,timeImpedanceUnits,distanceImpedance, distanceImpedanceUnits,descNDSAttributes,False)[impedanceAttribute] #Convert break values from user specified units to impedance units. convertedBreakValueList = nau.convert_units(breakValueList,breakUnits,impedanceUnit) converetedEndBreakValue = max([locale.atof(val) for val in convertedBreakValueList]) zeroString = nau.float_to_string(0,ROUND_PRECISION) ##Determine if the throtling conditions are met. If not raise an exception and quit ##If throtling parameters have zero value, then do not perform throtlling checks. # Thortling Check 1: Check for number of facilities if facilities_obj.count == 0: arcpy.AddIDMessage("ERROR",30117) raise nau.InputError() if strMaxFacilities and facilities_obj.count > maxFacilities: arcpy.AddIDMessage("ERROR", 30096,"Facilities", maxFacilities) raise nau.InputError()
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 # Get counts for facilities, incidents, barrier features and attribute parameters facility_count = facilities_obj.count incident_count = incidents_obj.count # Convert inputs from record sets to feature classes if they are not empty. if facility_count: facilities_obj.copyFeatures(out_gdb_workspace, FACILITIES_FIELDS)
#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. try: endBreakValue = max([locale.atof(val) for val in breakValueList]) except ValueError: arcpy.AddIDMessage("ERROR", 30118) raise nau.InputError() impedanceUnit = nau.verify_impedance_units( timeImpedance, timeImpedanceUnits, distanceImpedance, distanceImpedanceUnits, descNDSAttributes, False)[impedanceAttribute] #Convert break values from user specified units to impedance units. convertedBreakValueList = nau.convert_units(breakValueList, breakUnits, impedanceUnit) converetedEndBreakValue = max( [locale.atof(val) for val in convertedBreakValueList]) zeroString = nau.float_to_string(0, ROUND_PRECISION) ##Determine if the throtling conditions are met. If not raise an exception and quit ##If throtling parameters have zero value, then do not perform throtlling checks. # Thortling Check 1: Check for number of facilities if facilities_obj.count == 0: arcpy.AddIDMessage("ERROR", 30117) raise nau.InputError()