def __init__(self,conditions_layer=None):

      if conditions_layer is not None:
         self.conditions_layer = conditions_layer;

      else:
         aprx = arcpy.mp.ArcGISProject("CURRENT");
         map  = aprx.listMaps("AllHazardsWasteLogisticsMap")[0];

         for lyr in map.listLayers():

            if lyr.supports("name") and lyr.name == "Conditions":
               self.conditions_layer = obj_Layer.Layer(lyr);

         if self.conditions_layer is None:
            raise arcpy.ExecuteError("Error. Conditions layer not found.");
    def __init__(self, system_cache_layer=None):
        if system_cache_layer is not None:
            self.system_cache_layer = system_cache_layer

        else:
            aprx = arcpy.mp.ArcGISProject("CURRENT")
            map = aprx.listMaps("AllHazardsWasteLogisticsMap")[0]

            for lyr in map.listLayers():

                if lyr.supports("name") and lyr.name == "SystemCache":
                    self.system_cache_layer = obj_Layer.Layer(lyr)

            if self.system_cache_layer is None:
                raise arcpy.ExecuteError("Error. SystemCache layer not found.")

        self.loadSystemCache()
    def __init__(self, scenario_layer=None, scenario_id=None):

        if scenario_layer is not None:
            self.scenario_layer = scenario_layer

        else:
            aprx = arcpy.mp.ArcGISProject("CURRENT")
            map = aprx.listMaps("AllHazardsWasteLogisticsMap")[0]

            for lyr in map.listLayers():

                if lyr.supports("name") and lyr.name == "Scenario":
                    self.scenario_layer = obj_Layer.Layer(lyr)

            if self.scenario_layer is None:
                raise arcpy.ExecuteError("Error. Scenario layer not found.")

        if scenario_id is not None:
            self.loadScenarioID(scenario_id)
    def load_layers(self, ary_layers):

        for lyr in ary_layers:

            if lyr.supports("name") and  \
            ( "AllHazardsWasteLogisticsTool" + '/' + lyr.name == "AllHazardsWasteLogisticsTool" + '/' + "Network" \
              or lyr.longName == "Network" ):

                if lyr.isNetworkAnalystLayer:
                    self.network = obj_Layer.Layer(lyr)

        if self.network is not None:

            network_sublayers = arcpy.na.GetNAClassNames(self.network.lyr())

            for lyr in ary_layers:

                if lyr.supports(
                        "name") and lyr.name == network_sublayers["Incidents"]:
                    self.incidents = obj_Layer.Layer(lyr)

                if lyr.supports("name") and lyr.name == network_sublayers[
                        "Facilities"]:
                    self.facilities = obj_Layer.Layer(lyr)

                if lyr.supports(
                        "name") and lyr.name == network_sublayers["CFRoutes"]:
                    self.routes = obj_Layer.Layer(lyr)

                if lyr.supports(
                        "name") and lyr.name == network_sublayers["Barriers"]:
                    self.point_barriers = obj_Layer.Layer(lyr)

                if lyr.supports("name") and lyr.name == network_sublayers[
                        "PolylineBarriers"]:
                    self.line_barriers = obj_Layer.Layer(lyr)

                if lyr.supports("name") and lyr.name == network_sublayers[
                        "PolygonBarriers"]:
                    self.polygon_barriers = obj_Layer.Layer(lyr)
    def __init__(self):

        self.network = obj_NetworkAnalysisDataset.NetworkAnalysisDataset()

        self.aprx = self.network.aprx
        self.map = self.network.map

        conditions_table = None
        scenario_table = None
        shipment_loading = None
        cplm_unit_rates = None
        fixed_trans_cost = None
        labor_costs = None
        disposal_fees = None
        acceptance_rates = None
        system_cache = None

        for lyr in self.map.listLayers():

            if lyr.supports("name") and lyr.name == "SupportArea":
                self.support_area = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "IncidentArea":
                self.incident_area = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "ScenarioResults":
                self.scenario_results = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "Conditions":
                conditions_table = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "Scenario":
                scenario_table = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "ShipmentLoading":
                shipment_loading = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "CPLMUnitRates":
                cplm_unit_rates = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "FixedTransCost":
                fixed_trans_cost = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "LaborCosts":
                labor_costs = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "DisposalFees":
                disposal_fees = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "AcceptanceRates":
                acceptance_rates = obj_Layer.Layer(lyr)

            if lyr.supports("name") and lyr.name == "SystemCache":
                system_cache = obj_Layer.Layer(lyr)

        if conditions_table is not None:
            self.conditions = obj_Condition.Condition(conditions_table)

        if shipment_loading is not None:
            self.factors = obj_Factors.Factors(
                shipment_loading_layer=shipment_loading,
                cplm_unit_rates_layer=cplm_unit_rates,
                fixed_trans_cost_layer=fixed_trans_cost,
                labor_costs_layer=labor_costs,
                disposal_fees_layer=disposal_fees,
                acceptance_rates_layer=acceptance_rates)

        if system_cache is not None:
            self.system_cache = obj_SystemCache.SystemCache(system_cache)

        if scenario_table is not None:
            self.scenario = obj_Scenario.Scenario(
                scenario_table, self.system_cache.current_scenarioid)