def shipmentLoadingRate(self ,vehicle ,waste_type ,waste_medium ,unit_system ): loadingrate = None; unitpershipment = None; for obj in self.shipment_loading: if obj.vehicle == vehicle \ and obj.wastetype == waste_type \ and obj.wastemedium == waste_medium: loadingrate = obj.loadingrate; unitpershipment = obj.unitpershipment; break; if loadingrate is None and unitpershipment is None: return (None,None); return util.converter( in_unit = unitpershipment ,in_value = loadingrate ,unit_system = unit_system );
def CPLMUnitRate(self ,vehicle ,waste_type ,waste_medium ,distance ,unit_system ): cplunit_rate = None; unit = None; for obj in self.cplm_unit_rates: (cplmdist_lower,dummy) = util.converter( obj.unit ,obj.cplmdist_lower ,unit_system ); (cplmdist_upper,dummy) = util.converter( obj.unit ,obj.cplmdist_upper ,unit_system ); if obj.vehicle == vehicle \ and obj.wastetype == waste_type \ and obj.wastemedium == waste_medium \ and distance >= cplmdist_lower \ and distance < cplmdist_upper: cplunit_rate = obj.cplunit_rate; unit = obj.unit; break; if cplunit_rate is None and unit is None: return (None,None); return util.converter( in_unit = unit ,in_value = cplunit_rate ,unit_system = unit_system );
def __init__(self, haz, scenarioid, conditionid, factorid, facility_identifier, facility_rank, total_distance, total_distance_unit, total_traveltime, total_traveltime_unit, facility_name, facility_address, facility_city, facility_state, facility_zip, facility_telephone, facility_waste_mgt, facility_capacity_trucks_perday, facility_qty_accepted, facility_qty_accepted_unit, shape, unit_system, waste_type, waste_medium, waste_amount, waste_unit): self.haz = haz self.scenarioid = scenarioid self.conditionid = conditionid self.factorid = factorid self.facility_identifier = facility_identifier self.facility_rank = facility_rank (self.total_distance, self.distance_unit) = util.converter(total_distance_unit, total_distance, unit_system) (self.total_trucktraveltime, self.time_unit) = util.converter(total_traveltime_unit, total_traveltime, 'hr') self.average_speed = self.total_distance / self.total_trucktraveltime self.speed_unit = self.distance_unit + "/h" self.facility_name = facility_name self.facility_address = facility_address self.facility_city = facility_city self.facility_state = facility_state self.facility_zip = facility_zip self.facility_telephone = facility_telephone self.facility_waste_mgt = facility_waste_mgt self.facility_capacity_trucks_perday = facility_capacity_trucks_perday self.facility_qty_accepted = facility_qty_accepted self.facility_qty_accepted_unit = facility_qty_accepted_unit self.shape = shape self.unit_system = unit_system
def disposalFees(self ,waste_type ,waste_medium ,unit_system ): disposalcost = None; unit = None; for obj in self.disposal_fees: if obj.wastetype == waste_type \ and obj.wastemedium == waste_medium: disposalcost = obj.disposalcost unit = obj.unit; break; if disposalcost is None and unit is None: return (None,None); return util.converter( in_unit = unit ,in_value = disposalcost ,unit_system = unit_system );
def execute(self, parameters, messages): ######################################################################### # Step 10 # Abend if edits are pending ######################################################################### if util.sniff_editing_state(): raise arcpy.ExecuteError("Error. Pending edits must be saved or cleared before proceeding."); ######################################################################### # Step 20 # Read the parameters ######################################################################### if parameters[2].value is None: ary_waste_acceptance = None; else: ary_waste_acceptance = parameters[2].valueAsText.split(';'); if parameters[3].valueAsText == "true": loadDefaultFacilities = True; else: loadDefaultFacilities = False; if parameters[4].value is None: ary_user_defined = None; loadUserDefined = False; else: ary_user_defined = parameters[4].valueAsText.split(';'); loadUserDefined = True; if parameters[5].valueAsText == "true": limitBySupport = True; else: limitBySupport = False; if parameters[6].valueAsText == "true": truncateFacilities = "CLEAR"; else: truncateFacilities = "APPEND"; ######################################################################### # Step 30 # Initialize the haz toc object ######################################################################### haz = obj_AllHazardsWasteLogisticsTool.AllHazardsWasteLogisticsTool(); ( scenarioid ,unit_system ,waste_type ,waste_medium ,waste_amount ,waste_unit ) = haz.current_scenario(); ######################################################################### # Step 40 # Generate the waste acceptance where clause ######################################################################### filter_RAD_accepted = False; filter_LARWRad_accepted = False; filter_HW_accepted = False; filter_MSW_accepted = False; filter_C_D_accepted = False; if ary_waste_acceptance is None: arcpy.AddMessage("No Disposal Facility Types provided."); loadDefaultFacilities = False; loadUserDefined = False; else: for item in ary_waste_acceptance: if item.strip('\'') == 'Radioactive Waste Facility': filter_RAD_accepted = True; elif item.strip('\'') == 'RCRA Hazardous Waste Landfill with LARW': filter_LARWRad_accepted = True; elif item.strip('\'') == 'RCRA Hazardous Waste Landfill': filter_HW_accepted = True; elif item.strip('\'') == 'Municipal Solid Waste (MSW) Landfill': filter_MSW_accepted = True; elif item.strip('\'') == 'Construction and Demolition (C&D) Landfill': filter_C_D_accepted = True; else: raise arcpy.ExecuteError("Error unknown waste acceptance " + str(item)); ######################################################################### # Step 50 # Check if the Support Area has content ######################################################################### if limitBySupport: if haz.support_area.recordCount() == 0: limitBySupport = False; ######################################################################### # Step 60 # Truncate facility layer if requested ######################################################################### if truncateFacilities == "CLEAR": arcpy.AddMessage("Truncating Existing Facilities."); arcpy.TruncateTable_management(haz.network.facilities.dataSource); ######################################################################### # Step 70 # Create facility loader fc ######################################################################### if loadDefaultFacilities or \ (ary_user_defined is not None and len(ary_user_defined) > 0): scratch_ldr = arcpy.CreateScratchName( "Facility_Loader" ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); scratch_ldr_path,scratch_ldr_name = os.path.split(scratch_ldr); arcpy.CreateFeatureclass_management( out_path = scratch_ldr_path ,out_name = scratch_ldr_name ,geometry_type = "POINT" ,has_m = "DISABLED" ,has_z = "DISABLED" ,spatial_reference = arcpy.SpatialReference(4326) ,config_keyword = None ); arcpy.management.AddFields( scratch_ldr ,get_schema("core") ); arcpy.AddMessage("Scratch loading table created."); ######################################################################### # Step 80 # Load Default Facilities if requested ######################################################################### if loadDefaultFacilities: pn = os.path.dirname(os.path.realpath(__file__)); fc = pn + os.sep + r"Resources" + os.sep + r"AllHazardsWasteLogisticsFacilities.json"; if not os.path.exists(fc): raise arcpy.ExecuteError("Error. AllHazardsWasteLogisticsFacilities.json not found."); scratch_geo = arcpy.CreateScratchName( "Load_GeoJSON" ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); arcpy.env.outputMFlag = "Disabled"; arcpy.env.outputZFlag = "Disabled"; arcpy.JSONToFeatures_conversion( fc ,scratch_geo ,"POINT" ); arcpy.AddMessage("Default Facilities GeoJSON Loaded."); scratch_src = arcpy.CreateScratchName( "Load_Source" ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); scratch_src_path,scratch_src_name = os.path.split(scratch_src); arcpy.CreateFeatureclass_management( out_path = scratch_src_path ,out_name = scratch_src_name ,geometry_type = "POINT" ,has_m = "DISABLED" ,has_z = "DISABLED" ,spatial_reference = arcpy.SpatialReference(4326) ,config_keyword = None ); arcpy.management.AddFields( scratch_src ,get_schema("full") ); cursor_in = arcpy.da.SearchCursor( in_table = scratch_geo ,field_names = get_schema("full_fields") + [ 'SHAPE@' ] ); cursor_out = arcpy.da.InsertCursor( in_table = scratch_src ,field_names = get_schema("full_fields") + [ 'SHAPE@' ] ); for row in cursor_in: front_gate_longitude = clean_double(row[7]); front_gate_latitude = clean_double(row[8]); facility_qty_accepted_volume_solid = clean_double(row[11]); facility_qty_accepted_volume_liquid = clean_double(row[13]); C_D_accepted = clean_boo(row[15]); MSW_accepted = clean_boo(row[16]); HW_accepted = clean_boo(row[17]); LARWRAD_accepted = clean_boo(row[18]); RAD_accepted = clean_boo(row[19]); cursor_out.insertRow( ( row[0] ,row[1] ,row[2] ,row[3] ,row[4] ,row[5] ,row[6] ,front_gate_longitude ,front_gate_latitude ,row[9] ,row[10] ,facility_qty_accepted_volume_solid ,row[12] ,facility_qty_accepted_volume_liquid ,row[14] ,C_D_accepted ,MSW_accepted ,HW_accepted ,LARWRAD_accepted ,RAD_accepted ,row[20] ,row[21] ,row[22] ,row[23] ) ); flds = [ 'front_gate_longitude' ,'front_gate_latitude' ,'C_D_accepted' ,'MSW_accepted' ,'HW_accepted' ,'LARWRAD_accepted' ,'RAD_accepted' ,'SHAPE@X' ,'SHAPE@Y' ] del cursor_in; del cursor_out; with arcpy.da.UpdateCursor(scratch_src,flds) as cursor: for row in cursor: if (filter_C_D_accepted and row[2] == 'True') \ or (filter_MSW_accepted and row[3] == 'True') \ or (filter_HW_accepted and row[4] == 'True') \ or (filter_LARWRad_accepted and row[5] == 'True') \ or (filter_RAD_accepted and row[6] == 'True'): if row[0] is not None: row[7] = row[0]; row[8] = row[1]; cursor.updateRow(row); else: cursor.deleteRow(); count = int(arcpy.GetCount_management(scratch_src).getOutput(0)); if limitBySupport and count > 0: scratch_clp = arcpy.CreateScratchName( "Clip_Facilities" ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); arcpy.Clip_analysis( in_features = scratch_src ,clip_features = haz.support_area.dataSource ,out_feature_class = scratch_clp ); scratch_src = scratch_clp; count = int(arcpy.GetCount_management(scratch_src).getOutput(0)); arcpy.AddMessage("Default Facilities Clipped to Support Area."); if count > 0: cursor_in = arcpy.da.SearchCursor( in_table = scratch_src ,field_names = get_schema("core_fields") + [ 'SHAPE@' ] ); cursor_out = arcpy.da.InsertCursor( in_table = scratch_ldr ,field_names = get_schema("core_fields") + [ 'SHAPE@' ] ); for row in cursor_in: if row[11] is not None and row[11] != "": (sol,sol_unit) = util.converter( in_unit = row[12] ,in_value = row[11] ,unit_system = unit_system ); else: sol = None sol_unit = None; if row[13] is not None and row[13] != "": (liq,liq_unit) = util.converter( in_unit = row[14] ,in_value = row[13] ,unit_system = unit_system ); else: liq = None; liq_unit = None; cursor_out.insertRow( ( 'Facility' + str(row[0]) ,row[1] ,row[2] ,row[3] ,row[4] ,row[5] ,row[6] ,row[7] ,row[8] ,row[9] ,row[10] ,sol ,sol_unit ,liq ,liq_unit ,row[15] ) ); del cursor_in; del cursor_out; arcpy.AddMessage("Facility Loader Layer loaded."); ######################################################################### # Step 90 # Load facility loader fc ######################################################################### if loadUserDefined \ and ary_user_defined is not None \ and len(ary_user_defined) > 0: for i in range(len(ary_user_defined)): boo_stagingsite = False; scratch_usr = arcpy.CreateScratchName( "UserDefined" + str(i) ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); scratch_usr_path,scratch_usr_name = os.path.split(scratch_usr); src_input = ary_user_defined[i]; desc = arcpy.Describe(src_input); if desc.shapeType == "Polygon": fields = arcpy.ListFields(src_input) chck = 0; for field in fields: if field.name == "Name": chck = chck + 1; elif field.name == "CENTROID_X": chck = chck + 1; elif field.name == "CENTROID_Y": chck = chck + 1; elif field.name == "Available_Solid_Waste_Capacity__m3_": chck = chck + 1; elif field.name == "Available_Liquid_Waste_Capacity__L_": chck = chck + 1; if chck != 5: raise arcpy.ExecuteError( "Polygon feature class " + str(src_input) + " does not appear to be a valid staging site tool output file." ); boo_stagingsite = True; scratch_ste = arcpy.CreateScratchName( "StagingSite" + str(i) ,"" ,"FeatureClass" ,arcpy.env.scratchGDB ); scratch_ste_path,scratch_ste_name = os.path.split(scratch_ste); arcpy.CreateFeatureclass_management( out_path = scratch_ste_path ,out_name = scratch_ste_name ,geometry_type = "POINT" ,has_m = "DISABLED" ,has_z = "DISABLED" ,spatial_reference = arcpy.SpatialReference(4326) ,config_keyword = None ); arcpy.management.AddFields( scratch_ste ,get_schema("full") ); cursor_in = arcpy.da.SearchCursor( in_table = src_input ,field_names = [ 'Name' ,'CENTROID_X' ,'CENTROID_Y' ,'Available_Solid_Waste_Capacity__m3_' ,'Available_Liquid_Waste_Capacity__L_' ] ); cursor_out = arcpy.da.InsertCursor( in_table = scratch_ste ,field_names = [ 'Facility_Identifier' ,'Facility_Name' ,'facility_waste_mgt' ,'facility_capacity_trucks_perday' ,'facility_qty_accepted_volume_solid' ,'facility_qty_accepted_volume_solid_unit' ,'facility_qty_accepted_volume_liquid' ,'facility_qty_accepted_volume_liquid_unit' ,'SHAPE@X' ,'SHAPE@Y' ] ); for row in cursor_in: if row[3] is not None and row[3] != "": (sol,sol_unit) = util.converter( in_unit = 'm3' ,in_value = row[3] ,unit_system = unit_system ); else: sol = None sol_unit = None; if row[4] is not None and row[4] != "": (liq,liq_unit) = util.converter( in_unit = 'L' ,in_value = row[4] ,unit_system = unit_system ); else: liq = None; liq_unit = None; cursor_out.insertRow( ( 'StagingSiteSelectionTool.' + str(i) ,row[0] ,'Staging' ,30 ,sol ,sol_unit ,liq ,liq_unit ,row[1] ,row[2] ) ); del cursor_in; del cursor_out; src_input = scratch_ste; if limitBySupport: arcpy.Clip_analysis( in_features = src_input ,clip_features = haz.support_area.dataSource ,out_feature_class = scratch_usr ); else: arcpy.CopyFeatures_management( in_features = src_input ,out_feature_class = scratch_usr ); count = int(arcpy.GetCount_management(scratch_usr).getOutput(0)); if count > 0: cursor_in = arcpy.da.SearchCursor( in_table = scratch_usr ,field_names = get_schema("full_fields") + [ 'SHAPE@' ] ); cursor_out = arcpy.da.InsertCursor( in_table = scratch_ldr ,field_names = get_schema("core_fields") + [ 'SHAPE@' ] ); for row in cursor_in: if (filter_C_D_accepted and row[15] == 'True') \ or (filter_MSW_accepted and row[16] == 'True') \ or (filter_HW_accepted and row[17] == 'True') \ or (filter_LARWRad_accepted and row[18] == 'True') \ or (filter_RAD_accepted and row[19] == 'True') \ or boo_stagingsite: if row[11] is not None and row[11] != "": (sol,sol_unit) = util.converter( in_unit = row[12] ,in_value = row[11] ,unit_system = unit_system ); else: sol = None; sol_unit = None; if row[13] is not None and row[13] != "": (liq,liq_unit) = util.converter( in_unit = row[14] ,in_value = row[13] ,unit_system = unit_system ); else: liq = None; liq_unit = None; cursor_out.insertRow( ( 'Facility' + str(row[0]) ,row[1] ,row[2] ,row[3] ,row[4] ,row[5] ,row[6] ,row[7] ,row[8] ,row[9] ,row[10] ,sol ,sol_unit ,liq ,liq_unit ,row[23] ) ); del cursor_in; del cursor_out; arcpy.AddMessage("User Provided Facilities Layer " + str(i) + " loaded."); ######################################################################### # Step 100 # Load facilities from facility fc ######################################################################### if loadDefaultFacilities or \ (ary_user_defined is not None and len(ary_user_defined) > 0): count = int(arcpy.GetCount_management(scratch_ldr).getOutput(0)); if count == 0: arcpy.AddMessage("No facilities qualify for loading."); else: str_fm = "Name Facility_Name #;" \ + "CurbApproach # 0;" \ + "Attr_Minutes # 0;" \ + "Attr_TravelTime # 0;" \ + "Attr_Miles # 0;" \ + "Attr_Kilometers # 0;" \ + "Attr_TimeAt1KPH # 0;" \ + "Attr_WalkTime # 0;" \ + "Attr_TruckMinutes # 0;" \ + "Attr_TruckTravelTime # 0;" \ + "Cutoff_Minutes # #;" \ + "Cutoff_TravelTime # #;" \ + "Cutoff_Miles # #;" \ + "Cutoff_Kilometers # #;" \ + "Cutoff_TimeAt1KPH # #;" \ + "Cutoff_WalkTime # #;" \ + "Cutoff_TruckMinutes # #;" \ + "Cutoff_TruckTravelTime # #;" \ + "Facility_Identifier Facility_Identifier #;" \ + "Facility_Name Facility_Name #;" \ + "Facility_Address Facility_Address #;" \ + "Facility_City Facility_City #;" \ + "Facility_State Facility_State #;" \ + "Facility_Zip Facility_Zip #;" \ + "Facility_Telephone Facility_Telephone #;" \ + "Facility_Waste_Mgt Facility_Waste_Mgt #;" \ + "Facility_Capacity_Trucks_PerDay Facility_Capacity_Trucks_PerDay #;" \ + "Facility_Qty_Accepted_Volume_Solid Facility_Qty_Accepted_Volume_Solid #;" \ + "Facility_Qty_Accepted_Volume_Solid_Unit Facility_Qty_Accepted_Volume_Solid_Unit #;" \ + "Facility_Qty_Accepted_Volume_Liquid Facility_Qty_Accepted_Volume_Liquid #;" \ + "Facility_Qty_Accepted_Volume_Liquid_Unit Facility_Qty_Accepted_Volume_Liquid_Unit #;"; arcpy.na.AddLocations( in_network_analysis_layer = haz.network.lyr() ,sub_layer = haz.network.facilities.name ,in_table = scratch_ldr ,field_mappings = str_fm ,search_tolerance = None ,sort_field = None ,search_criteria = None ,match_type = None ,append = truncateFacilities ,snap_to_position_along_network = None ,snap_offset = None ,exclude_restricted_elements = None ,search_query = None ); arcpy.AddMessage("Network Facilities loaded."); ############################################################################ # Step 110 # Clean up and exit ############################################################################ del haz; return;
def execute(self, parameters, messages): ######################################################################### # Step 10 # Abend if edits are pending ######################################################################### if util.sniff_editing_state(): raise arcpy.ExecuteError( "Error. Pending edits must be saved or cleared before proceeding." ) ######################################################################### # Step 20 # Read the parameters ######################################################################### unit_system = parameters[2].valueAsText net_source = parameters[3].value net_source_str = parameters[3].valueAsText ago_account = parameters[4].valueAsText travel_mode = parameters[5].valueAsText if travel_mode is not None and travel_mode.strip() == "": travel_mode = None network_distance_field = parameters[6].valueAsText network_distance_unit = parameters[7].valueAsText network_time_field = parameters[8].valueAsText network_time_unit = parameters[9].valueAsText ######################################################################### # Step 30 # Verify the default feature class geojson file ######################################################################### pn = os.path.dirname(os.path.realpath(__file__)) fc = pn + os.sep + r"Resources" + os.sep + r"AllHazardsWasteLogisticsFacilities.json" if not os.path.exists(fc): raise arcpy.ExecuteError( "Error. AllHazardsWasteLogisticsFacilities.json not found.") with open(fc, "r") as json_f: json_d = json.load(json_f) del json_d arcpy.AddMessage("Facilities verified.") ######################################################################### # Step 40 # Verify the map ######################################################################### aprx = arcpy.mp.ArcGISProject("CURRENT") map = aprx.listMaps("AllHazardsWasteLogisticsMap")[0] if map is None: raise arcpy.ExecuteError("Error. Project map not found.") ######################################################################### # Step 50 # Cleanup preexisting map resources ######################################################################### cleanup = gp_RemoveWorkEnvironment.execute(self, parameters, messages) ######################################################################### # Step 60 # Make fresh Closest Facility Analysis Layer ######################################################################### result_object = arcpy.na.MakeClosestFacilityAnalysisLayer( network_data_source=net_source, layer_name="Network", travel_mode=travel_mode, travel_direction="TO_FACILITIES", cutoff=None, number_of_facilities_to_find=3, time_of_day=None, time_zone=None, time_of_day_usage=None, line_shape="ALONG_NETWORK") lyr_net = result_object.getOutput(0) arcpy.AddMessage("Network Analysis Layer created.") network_sublayers = arcpy.na.GetNAClassNames(lyr_net) arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_identifier", field_type="TEXT", field_length=255, field_alias="Facility_Identifier") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_name", field_type="TEXT", field_length=255, field_alias="Facility_Name") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_address", field_type="TEXT", field_length=255, field_alias="Facility_Address") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_city", field_type="TEXT", field_length=255, field_alias="Facility_City") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_state", field_type="TEXT", field_length=255, field_alias="Facility_State") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_zip", field_type="TEXT", field_length=255, field_alias="Facility_Zip") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_telephone", field_type="TEXT", field_length=255, field_alias="Facility_Telephone") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_waste_mgt", field_type="TEXT", field_alias="Facility_Waste_Mgt") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_capacity_trucks_perday", field_type="INTEGER", field_alias="Facility_Capacity_Trucks_PerDay") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_qty_accepted_volume_solid", field_type="DOUBLE", field_alias="Facility_Qty_Accepted_Volume_Solid") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_qty_accepted_volume_solid_unit", field_type="TEXT", field_alias="Facility_Qty_Accepted_Volume_Solid_Unit") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_qty_accepted_volume_liquid", field_type="DOUBLE", field_alias="Facility_Qty_Accepted_Volume_Liquid") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["Facilities"], field_name="facility_qty_accepted_volume_liquid_unit", field_type="TEXT", field_alias="Facility_Qty_Accepted_Volume_Liquid_Unit") arcpy.AddMessage("Facilities Layer extended.") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_identifier", field_type="TEXT", field_length=255, field_alias="Facility_Identifier") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_name", field_type="TEXT", field_length=255, field_alias="Facility_Name") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_address", field_type="TEXT", field_length=255, field_alias="Facility_Address") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_city", field_type="TEXT", field_length=255, field_alias="Facility_City") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_state", field_type="TEXT", field_length=255, field_alias="Facility_State") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_zip", field_type="TEXT", field_length=255, field_alias="Facility_Zip") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_telephone", field_type="TEXT", field_length=255, field_alias="Facility_Telephone") arcpy.na.AddFieldToAnalysisLayer(in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_waste_mgt", field_type="TEXT", field_length=255, field_alias="Facility_Waste_Mgt") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_capacity_trucks_perday", field_type="INTEGER", field_alias="Facility_Capacity_Trucks_PerDay") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_qty_accepted_volume_solid", field_type="DOUBLE", field_alias="Facility_Qty_Accepted_Volume_Solid") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_qty_accepted_volume_solid_unit", field_type="TEXT", field_alias="Facility_Qty_Accepted_Volume_Solid_Unit") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_qty_accepted_volume_liquid", field_type="DOUBLE", field_alias="Facility_Qty_Accepted_Volume_Liquid") arcpy.na.AddFieldToAnalysisLayer( in_network_analysis_layer=lyr_net, sub_layer=network_sublayers["CFRoutes"], field_name="facility_qty_accepted_volume_liquid_unit", field_type="TEXT", field_alias="Facility_Qty_Accepted_Volume_Liquid_Unit") arcpy.AddMessage("Routes Layer extended.") ######################################################################### # Step 70 # Create Supporting Resources ######################################################################### arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="Conditions", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "Conditions", [['conditionid', 'TEXT', 'ConditionID', 255, None, ''], ['roadtolls', 'DOUBLE', 'RoadTolls', None, None, ''], ['misccost', 'DOUBLE', 'MiscCost', None, None, ''], [ 'totalcostmultiplier', 'DOUBLE', 'TotalCostMultiplier', None, None, '' ], ['vehicledeconcost', 'DOUBLE', 'VehicleDeconCost', None, None, ''], ['stagingsitecost', 'DOUBLE', 'StagingSiteCost', None, None, ''], [ 'numberoftrucksavailable', 'DOUBLE', 'NumberofTrucksAvailable', None, None, '' ], ['drivinghours', 'DOUBLE', 'DrivingHours', None, None, '']]) arcpy.AddMessage("Conditions table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="ShipmentLoading", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "ShipmentLoading", [['factorid', 'TEXT', 'FactorID', 255, None, ''], ['vehicle', 'TEXT', 'Vehicle', 255, None, ''], ['wastetype', 'TEXT', 'WasteType', 255, None, ''], ['wastemedium', 'TEXT', 'WasteMedium', 255, None, ''], ['loadingrate', 'DOUBLE', 'LoadingRate', None, None, ''], ['unitpershipment', 'TEXT', 'UnitPerShipment', 255, None, '']]) arcpy.AddMessage("ShipmentLoading table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="CPLMUnitRates", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "CPLMUnitRates", [['factorid', 'TEXT', 'FactorID', 255, None, ''], ['vehicle', 'TEXT', 'Vehicle', 255, None, ''], ['cplmdist_lower', 'DOUBLE', 'CPLMDist_Lower', None, None, ''], ['cplmdist_upper', 'DOUBLE', 'CPLMDist_Upper', None, None, ''], ['cplmunit', 'TEXT', 'CPLMUnit', 255, None, ''], ['wastetype', 'TEXT', 'WasteType', 255, None, ''], ['wastemedium', 'TEXT', 'WasteMedium', 255, None, ''], ['cplunit_rate', 'DOUBLE', 'CPLMUnit_Rate', None, None, ''], ['unit', 'TEXT', 'Unit', 255, None, '']]) arcpy.AddMessage("CPLMUnitRates table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="FixedTransCost", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "FixedTransCost", [['factorid', 'TEXT', 'FactorID', 255, None, ''], ['vehicle', 'TEXT', 'Vehicle', 255, None, ''], ['fixedcost_type', 'TEXT', 'FixedCost_Type', 255, None, ''], ['wastetype', 'TEXT', 'WasteType', 255, None, ''], ['wastemedium', 'TEXT', 'WasteMedium', 255, None, ''], ['fixedcost_value', 'DOUBLE', 'FixedCost_Value', None, None, ''], ['unit', 'TEXT', 'Unit', 255, None, '']]) arcpy.AddMessage("FixedTransCost table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="LaborCosts", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "LaborCosts", [['factorid', 'TEXT', 'FactorID', 255, None, ''], ['laborcategory', 'TEXT', 'LaborCategory', 255, None, ''], ['laborcost', 'DOUBLE', 'LaborCost', None, None, ''], ['unit', 'TEXT', 'Unit', 255, None, '']]) arcpy.AddMessage("LaborCosts table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="DisposalFees", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "DisposalFees", [['factorid', 'TEXT', 'FactorID', 255, None, ''], ['wastetype', 'TEXT', 'WasteType', 255, None, ''], ['wastemedium', 'TEXT', 'WasteMedium', 255, None, ''], ['disposalcost', 'DOUBLE', 'DisposalCost', None, None, ''], ['unit', 'TEXT', 'Unit', 255, None, '']]) arcpy.AddMessage("DisposalFees table created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="IncidentArea", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "IncidentArea", [['name', 'TEXT', 'Name', 255, None, ''], ['description', 'TEXT', 'Description', 2000, None, '']]) arcpy.AddMessage("IncidentArea feature class created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="SupportArea", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "SupportArea", [['name', 'TEXT', 'Name', 255, None, ''], ['description', 'TEXT', 'Description', 2000, None, '']]) arcpy.AddMessage("SupportArea feature class created.") arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="ScenarioResults", geometry_type="POLYLINE", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields("ScenarioResults", [ ['scenarioid', 'TEXT', 'ScenarioID', 255, None, ''], ['conditionid', 'TEXT', 'ConditionID', 255, None, ''], ['factorid', 'TEXT', 'FactorID', 255, None, ''], ['facility_identifier', 'TEXT', 'Facility_Identifier', 255, None, ''], ['facility_rank', 'LONG', 'Facility_Rank', None, None, ''], ['total_distance', 'DOUBLE', 'Total_Distance', None, None, ''], ['distance_unit', 'TEXT', 'Distance_Unit', 255, None, ''], [ 'total_truck_travel_time', 'DOUBLE', 'Total_Truck_Travel_Time', None, None, '' ], ['time_unit', 'TEXT', 'Time_Unit', 255, None, ''], ['average_speed', 'DOUBLE', 'Average_Speed', None, None, ''], ['speed_unit', 'TEXT', 'Speed_Unit', 255, None, ''], ['facility_name', 'TEXT', 'Facility_Name', 255, None, ''], ['facility_address', 'TEXT', 'Facility_Addres', 255, None, ''], ['facility_city', 'TEXT', 'Facility_City', 255, None, ''], ['facility_state', 'TEXT', 'Facility_State', 255, None, ''], ['facility_zip', 'TEXT', 'Facility_Zip', 255, None, ''], ['facility_telephone', 'TEXT', 'Facility_Telephone', 255, None, ''], ['facility_waste_mgt ', 'TEXT', 'Facility_Waste_Mgt', 255, None, ''], [ 'facility_capacity_trucks_perday', 'DOUBLE', 'Facility_Capacity_Trucks_PerDay', None, None, '' ], [ 'facility_qty_accepted', 'DOUBLE', 'Facility_Qty_Accepted', None, None, '' ], [ 'facility_qty_accepted_unit', 'TEXT', 'Facility_Qty_Accepted_Unit', 255, None, '' ], ['allocated_amount', 'DOUBLE', 'Allocated_Amount', None, None, ''], [ 'allocated_amount_unit', 'TEXT', 'Allocated_Amount_Unit', 255, None, '' ], ['number_of_shipments', 'LONG', 'Number_Of_Shipments', None, None, ''], ['cplm_cost_usd', 'DOUBLE', 'CPLM_Cost_USD', None, None, ''], [ 'fixed_cost_usd_per_shipment', 'DOUBLE', 'Fixed_Cost_USD_Per_Shipment', None, None, '' ], [ 'fixed_cost_usd_per_hour', 'DOUBLE', 'Fixed_Cost_USD_Per_Hour', None, None, '' ], ['tolls_usd', 'DOUBLE', 'Tolls_USD', None, None, ''], [ 'misc_trans_cost_usd', 'DOUBLE', 'Misc_Trans_Cost_USD', None, None, '' ], ['trans_cost_usd', 'DOUBLE', 'Trans_Cost_USD', None, None, ''], [ 'staging_site_cost_usd', 'DOUBLE', 'Staging_Site_Cost_USD', None, None, '' ], [ 'disposal_cost_usd', 'DOUBLE', 'Disposal_Cost_USD', None, None, '' ], ['labor_cost_usd', 'DOUBLE', 'Labor_Cost_USD', None, None, ''], [ 'vehicle_decon_cost_usd', 'DOUBLE', 'Vehicle_Decon_Cost_USD', None, None, '' ], [ 'cost_multiplier_usd', 'DOUBLE', 'Cost_Multiplier_USD', None, None, '' ], ['cost_usd', 'DOUBLE', 'Cost_USD', None, None, ''], [ 'trucks_time_to_comp_days', 'DOUBLE', 'Truck_Time_To_Comp_Days', None, None, '' ], [ 'dest_time_to_comp_days', 'DOUBLE', 'Dest_Time_To_Comp_Days', None, None, '' ], ['time_days', 'DOUBLE', 'Time_Days', None, None, ''], ['username', 'TEXT', 'UserName', None, None, ''], ['creationtime', 'DATE', 'CreationTime', None, None, ''] ]) arcpy.AddMessage("ScenarioResults feature class created.") ############################################################################ arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="Scenario", geometry_type="POLYGON", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields( "Scenario", [['scenarioid', 'TEXT', 'ScenarioID', 255, None, ''], ['waste_type', 'TEXT', 'Waste_Type', 255, None, ''], ['waste_medium', 'TEXT', 'Waste_Medium', 255, None, ''], ['waste_amount', 'DOUBLE', 'Waste_Amount', None, None, ''], ['waste_unit', 'TEXT', 'Waste_Unit', 255, None, ''], [ 'numberoffacilitiestofind', 'LONG', 'NumberOfFacilitiesToFind', None, None, '' ], [ 'route_count_requested', 'LONG', 'Route_Count_Requested', None, None, '' ], [ 'route_count_returned', 'LONG', 'Route_Count_Returned', None, None, '' ], ['map_image', 'TEXT', 'Map_Image', 255, None, ''], ['conditionid', 'TEXT', 'ConditionID', 255, None, ''], ['factorid', 'TEXT', 'FactorID', 255, None, '']]) arcpy.AddMessage("Scenario table created.") ############################################################################ arcpy.CreateFeatureclass_management( out_path=arcpy.env.workspace, out_name="SystemCache", geometry_type="POLYLINE", has_m="DISABLED", has_z="DISABLED", spatial_reference=arcpy.SpatialReference(4326), config_keyword=None) arcpy.management.AddFields("SystemCache", [ ['current_unit_system', 'TEXT', 'Current_Unit_System', None, None, ''], ['current_scenarioid', 'TEXT', 'Current_ScenarioID', 255, None, ''], ['current_conditionid', 'TEXT', 'Current_ConditionID', 255, None, ''], ['current_factorid', 'TEXT', 'Current_FactorID', 255, None, ''], ['network_dataset', 'TEXT', 'Network_Dataset', 2000, None, ''], [ 'network_distance_fieldname', 'TEXT', 'Network_Distance_Fieldname', 255, None, '' ], [ 'network_distance_unit', 'TEXT', 'Network_Distance_Unit', 255, None, '' ], [ 'network_time_fieldname', 'TEXT', 'Network_Time_Fieldname', 255, None, '' ], ['network_time_unit', 'TEXT', 'Network_Time_Unit', 255, None, ''] ]) arcpy.AddMessage("SystemCache feature class created.") ######################################################################### # Step 80 # Load config defaults ######################################################################### json_d = util.load_settings() if json_d is None: raise arcpy.ExecuteError("Error unable to read Defaults.json") else: arcpy.AddMessage("Defaults read successfully.") if 'Conditions' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "Conditions", obj_Condition.Condition.fields) for row in json_d["Conditions"]: cursor.insertRow( (row["ConditionID"], row["RoadTolls"], row["MiscCost"], row["TotalCostMultiplier"], row["VehicleDeconCost"], row["StagingSiteCost"], row["NumberofTrucksAvailable"], row["DrivingHours"])) del cursor arcpy.AddMessage("Conditions table loaded.") if 'ShipmentLoading' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "ShipmentLoading", obj_ShipmentLoading.ShipmentLoading.fields) for cid in json_d["ShipmentLoading"]: factorid = cid["FactorID"] for row in cid["rows"]: (loading_rate, unitpershipment) = util.converter( in_unit=row["UnitPerShipment"], in_value=row["LoadingRate"], unit_system=unit_system) cursor.insertRow( (factorid, row["Vehicle"], row["WasteType"], row["WasteMedium"], loading_rate, unitpershipment)) del cursor arcpy.AddMessage("ShipmentLoading table loaded.") if 'CPLMUnitRates' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "CPLMUnitRates", obj_CPLMUnitRates.CPLMUnitRates.fields) for cid in json_d["CPLMUnitRates"]: factorid = cid["FactorID"] for row in cid["rows"]: (lower_value, cplm_unit) = util.converter(in_unit=row["CPLMUnit"], in_value=row["CPLMDist_Lower"], unit_system=unit_system) (upper_value, unit) = util.converter(in_unit=row["CPLMUnit"], in_value=row["CPLMDist_Upper"], unit_system=unit_system) (unit_rate, unit) = util.converter(in_unit=row["Unit"], in_value=row["CPLMUnit_Rate"], unit_system=unit_system) cursor.insertRow((factorid, row["Vehicle"], lower_value, upper_value, cplm_unit, row["WasteType"], row["WasteMedium"], unit_rate, unit)) del cursor arcpy.AddMessage("CPLMUnitRates table loaded.") if 'FixedTransCost' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "FixedTransCost", obj_FixedTransCost.FixedTransCost.fields) for cid in json_d["FixedTransCost"]: factorid = cid["FactorID"] for row in cid["rows"]: cursor.insertRow( (factorid, row["Vehicle"], row["FixedCost_Type"], row["WasteType"], row["WasteMedium"], row["FixedCost_Value"], row["Unit"])) del cursor arcpy.AddMessage("FixedTransCost table loaded.") if 'LaborCosts' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "LaborCosts", obj_LaborCosts.LaborCosts.fields) for cid in json_d["LaborCosts"]: factorid = cid["FactorID"] for row in cid["rows"]: cursor.insertRow((factorid, row["LaborCategory"], row["LaborCost"], row["Unit"])) del cursor arcpy.AddMessage("LaborCosts table loaded.") if 'DisposalFees' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "DisposalFees", obj_DisposalFees.DisposalFees.fields) for cid in json_d["DisposalFees"]: factorid = cid["FactorID"] for row in cid["rows"]: (disposal_cost, unit) = util.converter(in_unit=row["Unit"], in_value=row["DisposalCost"], unit_system=unit_system) cursor.insertRow((factorid, row["WasteType"], row["WasteMedium"], disposal_cost, unit)) del cursor arcpy.AddMessage("DisposalFees table loaded.") if 'SystemCache' in json_d: cursor = arcpy.da.InsertCursor( arcpy.env.workspace + os.sep + "SystemCache", obj_SystemCache.SystemCache.fields) cursor.insertRow(( unit_system, None # current scenarioid , None # current conditionid , None # current factorid , net_source_str, network_distance_field, network_distance_unit, network_time_field, network_time_unit)) del cursor ######################################################################### # Step 90 # Create the Folder Group for items and add incident and support area fcs ######################################################################### fld = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "Folder.lyrx")) grp = fld.listLayers("Folder")[0] grp.name = "AllHazardsWasteLogisticsTool" map.addLayer(grp, "TOP") grp = map.listLayers("AllHazardsWasteLogisticsTool")[0] fld = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "Settings.lyrx")) set = fld.listLayers("Folder")[0] set.name = "Settings" map.addLayerToGroup(grp, set, "TOP") set = map.listLayers("Settings")[0] lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "SystemCache.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "Conditions.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "Scenario.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "ShipmentLoading.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "CPLMUnitRates.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "FixedTransCost.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "LaborCosts.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "DisposalFees.lyrx")) map.addLayerToGroup(set, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "ScenarioResults.lyrx")) map.addLayerToGroup(grp, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "IncidentArea.lyrx")) map.addLayerToGroup(grp, lyr, "TOP") lyr = arcpy.mp.LayerFile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "SupportArea.lyrx")) map.addLayerToGroup(grp, lyr, "TOP") ######################################################################### # Step 100 # Grind up the network layer and add rendering to the new item ######################################################################### lyrx_style = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Resources", "Network.lyrx") lyrx_target = arcpy.CreateScratchName("Network.lyrx", "", "Folder", arcpy.env.scratchFolder) arcpy.SaveToLayerFile_management(in_layer=lyr_net, out_layer=lyrx_target) with open(lyrx_style, "r") as jsonFile_style: data_style = json.load(jsonFile_style) with open(lyrx_target, "r") as jsonFile_target: data_target = json.load(jsonFile_target) for item in data_target["layerDefinitions"]: if item["name"] == "Facilities": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Facilities": item["renderer"] = item2["renderer"] if item["name"] == "Incidents": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Incidents": item["renderer"] = item2["renderer"] if item["name"] == "Point Barriers": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Point Barriers": item["renderer"] = item2["renderer"] if item["name"] == "Routes": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Routes": item["renderer"] = item2["renderer"] if item["name"] == "Line Barriers": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Line Barriers": item["renderer"] = item2["renderer"] if item["name"] == "Polygon Barriers": for item2 in data_style["layerDefinitions"]: if item2["name"] == "Polygon Barriers": item["renderer"] = item2["renderer"] with open(lyrx_target, "w") as jsonFile: json.dump(data_target, jsonFile) net = arcpy.mp.LayerFile(lyrx_target) map.addLayerToGroup(grp, net, "TOP") ######################################################################### # Step 110 # Scope is always a problem, try to cleanup manually ######################################################################### del aprx del lyr del lyr_net del net del map return