Esempio n. 1
0
        //初始化道路智能体,获取每个道路智能体的车辆数以及ID、起点、终点、道路等级的信息
        public void InitializeRoadAgent()
        {
            //设置道路智能体属性
            IFeatureLayer  pFeatureLayer  = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\road.shp");
            IFeatureClass  pFeatureClass  = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                RoadNetwork pRoadNetwork = new RoadNetwork();
                pRoadNetwork.ID          = Convert.ToInt32(pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")));
                pRoadNetwork.StartNodeID = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField("StartNodeI")));
                pRoadNetwork.EndNodeID   = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField("EndNodeID")));
                pRoadNetwork.Rank        = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField("Rank")));
                pRoadNetwork.Length      = Convert.ToDouble((pFeature.Shape as IPolyline).Length);
                pRoadAgent.Add(pRoadNetwork);
                pFeature = pFeatureCursor.NextFeature();
            }

            //初始化道路智能体行驶的车辆数
            for (int i = 0; i < pOrdinaryVehicleAgent.Count; i++)
            {
                pRoadAgent[pOrdinaryVehicleAgent[i].Origination].VehicleNumber++;
            }
        }
 //计算污染返现点下游水系
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBox1.Text == "")
         {
             MessageBox.Show("请输入污染发现点数据", "输入污染发现点数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (comboBox2.Text == "")
         {
             MessageBox.Show("请输入河流网络数据", "输入河流网络数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (comboBox3.Text == "")
         {
             MessageBox.Show("请选择输出污染发现点下游水系数据", "输出污染发现点下游水系数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else
         {
             IFeatureLayer    pFeatureLayerPollutionpoint = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
             IFeatureLayer    pFeatureLayerRivernetwork   = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);
             RiverDownstream  riverpath = new RiverDownstream();
             List <IPolyline> listlines = new List <IPolyline>();
             listlines = riverpath.pollutionpointdownstreamriver(pFeatureLayerPollutionpoint, pFeatureLayerRivernetwork);
             SaveVector.polylinetoFeatureLayer(comboBox3.Text, listlines, pFeatureLayerRivernetwork);
             MessageBox.Show("处理完毕!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }
        //获取应急处置空间位置的FID
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入应急处置空间备选数据", "输入应急处置空间备选数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    label2.Enabled    = true;
                    comboBox2.Enabled = true;
                    string currentFieldName = "FID";
                    pFeatureLayerEmergency = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    IFeatureClass   pFeatureClassEmergency  = pFeatureLayerEmergency.FeatureClass;
                    IFeatureCursor  pFeatureCursorEmergency = pFeatureClassEmergency.Search(null, false);
                    IDataStatistics pDataStatistics         = new DataStatistics();
                    pDataStatistics.Field  = currentFieldName;
                    pDataStatistics.Cursor = pFeatureCursorEmergency as ICursor;
                    System.Collections.IEnumerator pEnumerator = pDataStatistics.UniqueValues;
                    while (pEnumerator.MoveNext())
                    {
                        comboBox2.Items.Add(Convert.ToInt32(pEnumerator.Current.ToString()) + 1);
                    }

                    comboBox2.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
        //通过实时监测的数据获取各个应急处置空间位置的信息
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (checkBox2.Checked == true)
                {
                    groupBox3.Enabled = true;
                    button9.Enabled   = true;

                    //将应急处置点序号添加进去
                    string          currentFieldName              = "FID";
                    IFeatureLayer   pFeatureLayerEmergencypoint   = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    IFeatureClass   pFeatureClassEmergencypoint   = pFeatureLayerEmergencypoint.FeatureClass;
                    IFeatureCursor  pFeatureCursorEmergencypoint  = pFeatureClassEmergencypoint.Search(null, false);
                    IDataStatistics pDataStatisticsEmergencypoint = new DataStatistics();
                    pDataStatisticsEmergencypoint.Field  = currentFieldName;
                    pDataStatisticsEmergencypoint.Cursor = pFeatureCursorEmergencypoint as ICursor;
                    System.Collections.IEnumerator pEnumerator = pDataStatisticsEmergencypoint.UniqueValues;
                    while (pEnumerator.MoveNext())
                    {
                        comboBox7.Items.Add(Convert.ToInt32(pEnumerator.Current.ToString()) + 1);
                    }
                    comboBox7.SelectedIndex = 0;
                }
                else
                {
                    groupBox3.Enabled = false;
                    button9.Enabled   = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
 private void button9_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBox1.Text == "")
         {
             MessageBox.Show("请输入可供选择的应急处置空间位置的数据", "输入可供选择的应急处置空间位置的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox2.Text == "")
         {
             MessageBox.Show("请输入河流流速的数据", "输入河流流速的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox3.Text == "")
         {
             MessageBox.Show("请输入河流流量的数据", "输入河流流量的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox4.Text == "")
         {
             MessageBox.Show("请输入河流宽度的数据", "输入河流宽度的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox5.Text == "")
         {
             MessageBox.Show("请输入河流污染物浓度的数据", "输入河流污染物浓度的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox6.Text == "")
         {
             MessageBox.Show("请输入河流总量的数据", "输入河流污染物总量的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else
         {
             IFeatureLayer pFeatureLayerSave = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
             IFeatureClass pFeatureClassSave = pFeatureLayerSave.FeatureClass;
             IQueryFilter  pQueryFilterSave  = new QueryFilterClass();
             pQueryFilterSave.WhereClause = "FID=" + Convert.ToString(Convert.ToInt32(comboBox7.Text) - 1);
             IFeatureCursor pFeatureCursorSave = pFeatureClassSave.Update(pQueryFilterSave, false);
             IFeature       pFeatureSave       = pFeatureCursorSave.NextFeature();
             while (pFeatureSave != null)
             {
                 pFeatureSave.set_Value(pFeatureSave.Fields.FindField("V"), Convert.ToDouble(textBox2.Text));
                 pFeatureSave.set_Value(pFeatureSave.Fields.FindField("Q"), Convert.ToDouble(textBox3.Text));
                 pFeatureSave.set_Value(pFeatureSave.Fields.FindField("L"), Convert.ToDouble(textBox4.Text));
                 pFeatureSave.set_Value(pFeatureSave.Fields.FindField("C"), Convert.ToDouble(textBox5.Text));
                 pFeatureSave.set_Value(pFeatureSave.Fields.FindField("S"), Convert.ToDouble(textBox6.Text));
                 pFeatureCursorSave.UpdateFeature(pFeatureSave);
                 pFeatureSave = pFeatureCursorSave.NextFeature();
             }
             MessageBox.Show("程序运行结束!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add AddBarriesTool.OnClick implementation
            IFeatureLayer pFeatureLayer = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\Barries.shp");

            pFeatureClass = pFeatureLayer.FeatureClass;
            if (pFeatureClass.FeatureCount(null) > 0)
            {
                ITable pTable = pFeatureClass as ITable;
                pTable.DeleteSearchedRows(null);
            }
        }
        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            IFeatureLayer pFeatureLayerEmergencypoint = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
            IFeatureClass pFeatureClassEmergencypoint = pFeatureLayerEmergencypoint.FeatureClass;
            IQueryFilter  pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = "FID=" + Convert.ToString(Convert.ToInt32(comboBox7.Text) - 1);

            IFeatureCursor pFeatureCursoEmergencypoint = pFeatureClassEmergencypoint.Search(pQueryFilter, false);
            IFeature       pFeatureEmergencypoint      = pFeatureCursoEmergencypoint.NextFeature();
            IFields        pFields = pFeatureClassEmergencypoint.Fields;
            IField         pField;

            while (pFeatureEmergencypoint != null)
            {
                for (int i = 0; i < pFields.FieldCount; i++)
                {
                    pField = pFields.get_Field(i);
                    if (pField.Name.ToString() == "V")
                    {
                        textBox2.Text = Convert.ToString(pFeatureEmergencypoint.get_Value(pFeatureEmergencypoint.Fields.FindField("V")));
                    }
                    else if (pField.Name.ToString() == "Q")
                    {
                        textBox3.Text = Convert.ToString(pFeatureEmergencypoint.get_Value(pFeatureEmergencypoint.Fields.FindField("Q")));
                    }
                    else if (pField.Name.ToString() == "L")
                    {
                        textBox4.Text = Convert.ToString(pFeatureEmergencypoint.get_Value(pFeatureEmergencypoint.Fields.FindField("L")));
                    }
                    else if (pField.Name.ToString() == "C")
                    {
                        textBox5.Text = Convert.ToString(pFeatureEmergencypoint.get_Value(pFeatureEmergencypoint.Fields.FindField("C")));
                    }
                    else if (pField.Name.ToString() == "S")
                    {
                        textBox6.Text = Convert.ToString(pFeatureEmergencypoint.get_Value(pFeatureEmergencypoint.Fields.FindField("S")));
                    }
                }
                pFeatureEmergencypoint = pFeatureCursoEmergencypoint.NextFeature();
            }

            if (textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "")
            {
                MessageBox.Show("可选择应急处置空间位置图层,缺少流速、流量、宽度、浓度或总量的字段,请新建该字段!");
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
                textBox6.Text = "";
            }
        }
 //计算污染物排放的空间位置
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBox1.Text == "")
         {
             MessageBox.Show("请输入污染源数据库数据", "输入污染源数据库数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (comboBox2.Text == "")
         {
             MessageBox.Show("请输入污染发现点上游水系数据", "输入污染源发现点上游水系数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (comboBox3.Text == "")
         {
             MessageBox.Show("请输入子流域数据", "输入子流域数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (textBox1.Text == "")
         {
             MessageBox.Show("请输入污染发现点所发生的污染类型", "输入污染发现点所发生的污染类型", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else if (comboBox4.Text == "")
         {
             MessageBox.Show("请输出可能排放污染物的空间位置数据", "输出可能排放污染物的空间位置数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         }
         else
         {
             //将可能已发生污染的水系合并成一个要素
             IFeatureLayer pFeatureLayerline = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);
             IPolyline     polyline          = new PolylineClass();
             polyline = LineUnion(pFeatureLayerline);
             IGeometry pGeometry = polyline as IGeometry;
             //根据可能已发生的污染水系查找其子流域
             IFeatureLayer   pFeatureLayerpolygon = CDataImport.ImportFeatureLayerFromControltext(comboBox3.Text);
             List <IFeature> pFeaturelist         = new List <IFeature>();
             pFeaturelist = GetLineOverlapPolygon(pFeatureLayerpolygon, pGeometry);
             IPolygon polygon = PolygonUnion(pFeaturelist);
             //根据肯能已发生污染的子流域查找其可能引起的污染源的空间位置
             IFeatureLayer   pFeatureLayerpoint = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
             IGeometry       pGeometrypolygon   = polygon as IGeometry;
             List <IFeature> pFeatureListpoint  = new List <IFeature>();
             pFeatureListpoint = GetPolygonContainPoint(pFeatureLayerpoint, pGeometrypolygon, textBox1.Text);
             SaveVector.pointtoFeatureLayer(comboBox4.Text, pFeatureListpoint, pFeatureLayerpoint);
             MessageBox.Show("处理完毕!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "/n" + ex.ToString(), "异常");
     }
 }
Esempio n. 9
0
 private void button8_Click(object sender, EventArgs e)
 {
     try
     {
         Variable.pMapFrm.mainMapControl.CurrentTool = null;
         IGraphicsContainer pGraphicsContainer = Variable.pMapFrm.mainMapControl.ActiveView as IGraphicsContainer;
         pGraphicsContainer.DeleteAllElements();
         IFeatureLayer pFeatureLayer = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\Barries.shp");
         IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
         if (pFeatureClass.FeatureCount(null) > 0)
         {
             ITable pTable = pFeatureClass as ITable;
             pTable.DeleteSearchedRows(null);
         }
         Variable.pMapFrm.mainMapControl.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }
Esempio n. 10
0
        //查找最近某点最近的线
        public IFeature GetNearestFeature(IPoint pPoint)
        {
            try
            {
                double             minDistince, Distiance;
                IFeature           pFeatureNearst, pFeature;
                IProximityOperator pProximityOperator = pPoint as IProximityOperator;
                IFeatureLayer      pFeatureLayer      = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\road.shp");
                IFeatureClass      pFeatureClass      = pFeatureLayer.FeatureClass;
                IFeatureCursor     pFeatureCursor     = pFeatureClass.Search(null, false);
                pFeature = pFeatureNearst = pFeatureCursor.NextFeature();

                if (pFeature == null)
                {
                    return(null);
                }
                minDistince = Distiance = pProximityOperator.ReturnDistance(pFeature.Shape as IGeometry);
                pFeature    = pFeatureCursor.NextFeature();
                while (pFeature != null)
                {
                    Distiance = pProximityOperator.ReturnDistance(pFeature.Shape as IGeometry);
                    if (minDistince > Distiance)
                    {
                        minDistince    = Distiance;
                        pFeatureNearst = pFeature;
                    }
                    pFeature = pFeatureCursor.NextFeature();
                }
                System.GC.Collect();
                System.GC.WaitForPendingFinalizers();

                return(pFeatureNearst);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "异常");
                return(null);
            }
        }
Esempio n. 11
0
        //初始化普通车辆智能体
        //随机产生起点、终点构建车辆智能体
        public void InitializeOrdinaryVehicleAgent(int OrdinaryVehicleNumber)
        {
            IFeatureLayer pFeatureLayer = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\point.shp");
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            int           pointNumber   = pFeatureClass.FeatureCount(null);
            Random        random        = new Random();

            for (int i = 0; i < OrdinaryVehicleNumber; i++)
            {
                OrdinaryVehicle pOrdinaryVehicle = new OrdinaryVehicle();
                pOrdinaryVehicle.ID          = i + 1;
                pOrdinaryVehicle.Origination = random.Next(1, pointNumber);
                pOrdinaryVehicle.Destination = random.Next(1, pointNumber);
                if (pOrdinaryVehicle.Origination != pOrdinaryVehicle.Destination)
                {
                    IQueryFilter pQueryFilterOrigination = new QueryFilterClass();
                    pQueryFilterOrigination.WhereClause = "OBJECTID=" + "'" + pOrdinaryVehicle.Origination + "'";
                    IFeatureCursor pFeatureCursorOrigination = pFeatureClass.Search(pQueryFilterOrigination, false);
                    IFeature       pFeatureOrigination       = pFeatureCursorOrigination.NextFeature();
                    while (pFeatureOrigination != null)
                    {
                        pOrdinaryVehicle.OriginationPoint = pFeatureOrigination.Shape as IPoint;
                        pFeatureOrigination = pFeatureCursorOrigination.NextFeature();
                    }
                    IQueryFilter pQueryFilterDestination = new QueryFilterClass();
                    pQueryFilterDestination.WhereClause = "OBJECTID=" + "'" + pOrdinaryVehicle.Destination + "'";
                    IFeatureCursor pFeatureCursorDestination = pFeatureClass.Search(pQueryFilterDestination, false);
                    IFeature       pFeatureDestination       = pFeatureCursorDestination.NextFeature();
                    while (pFeatureDestination != null)
                    {
                        pOrdinaryVehicle.DestinationPoint = pFeatureDestination.Shape as IPoint;
                        pFeatureDestination = pFeatureCursorDestination.NextFeature();
                    }
                    pOrdinaryVehicleAgent.Add(pOrdinaryVehicle);
                }
            }
        }
Esempio n. 12
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入应急资源仓库数据", "输入应急资源仓库数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox3.Text == "")
                {
                    MessageBox.Show("请输入污染物扩散模拟数据", "输入污染物扩散模拟数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    //获取各个应急资源仓库到达应急处置空间位置的时间
                    pFeatureLayerDepot = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);
                    String pFeatureFID = "FID=" + Convert.ToString(Convert.ToInt32(comboBox4.Text) - 1);
                    EmergencySpaceSelectionDijkstra pEmergencySpaceSelection = new EmergencySpaceSelectionDijkstra();
                    List <Result> resultlist = new List <Result>();
                    resultlist = pEmergencySpaceSelection.DepotToDest(pFeatureLayerDepot, pFeatureLayerDept, pFeatureFID);

                    //判断应急资源需求的种类
                    int EmergencyNumber = 0;
                    if (checkBox1.Checked == true)
                    {
                        EmergencyNumber++;
                    }
                    for (int i = 0; i < pCheckBox.Length; i++)
                    {
                        if (pCheckBox[i].Checked == true)
                        {
                            EmergencyNumber++;
                        }
                    }

                    //获取应急资需求的名称
                    string[] EmergencyVarietyName      = new string[EmergencyNumber];
                    int      EmergencyVarietyNameIndex = 0;
                    if (checkBox1.Checked == true)
                    {
                        int EmergencyVarietyIndex = label8.Text.LastIndexOf(":");
                        EmergencyVarietyName[EmergencyVarietyNameIndex] = label8.Text.Substring(0, EmergencyVarietyIndex);
                        EmergencyVarietyNameIndex++;
                    }
                    for (int j = 0; j < pLabel.Length; j++)
                    {
                        if (pCheckBox[j].Checked == true)
                        {
                            int EmergencyVarietyIndex = pLabel[j].Text.LastIndexOf(":");
                            EmergencyVarietyName[EmergencyVarietyNameIndex] = pLabel[j].Text.Substring(0, EmergencyVarietyIndex);
                            EmergencyVarietyNameIndex++;
                        }
                    }

                    //获取应急处置空间位置应急资源需求
                    pEmergencyDeptResource = new List <EmergencyDeptResource>();
                    int EmergencyDemandResourceNumber = 0;
                    if (checkBox1.Checked == true)
                    {
                        EmergencyDeptResource emergencydeptresource = new EmergencyDeptResource();
                        int EmergencyDemandResourceIndex            = label8.Text.LastIndexOf(":");
                        emergencydeptresource.EmergencyDemandResourceName   = EmergencyVarietyName[EmergencyDemandResourceNumber];
                        emergencydeptresource.EmergencyDemandResourceNumber = Convert.ToDouble(label8.Text.Substring(EmergencyDemandResourceIndex + 1));
                        pEmergencyDeptResource.Add(emergencydeptresource);
                        EmergencyDemandResourceNumber++;
                    }
                    for (int k = 0; k < pLabel.Length; k++)
                    {
                        if (pCheckBox[k].Checked == true)
                        {
                            EmergencyDeptResource emergencydeptresource = new EmergencyDeptResource();
                            int EmergencyDemandResourceIndex            = pLabel[k].Text.LastIndexOf(":");
                            emergencydeptresource.EmergencyDemandResourceName   = EmergencyVarietyName[EmergencyDemandResourceNumber];
                            emergencydeptresource.EmergencyDemandResourceNumber = Convert.ToDouble(pLabel[k].Text.Substring(EmergencyDemandResourceIndex + 1));
                            pEmergencyDeptResource.Add(emergencydeptresource);
                            EmergencyDemandResourceNumber++;
                        }
                    }


                    //获取应急资源仓库存储的的应急资源
                    IFeatureClass  pFeatureClassDepot    = pFeatureLayerDepot.FeatureClass;
                    int            DepotNumber           = pFeatureClassDepot.FeatureCount(null);
                    IFeatureCursor pFeatureCursorDepot   = pFeatureClassDepot.Search(null, false);
                    IFeature       pFeatureDepot         = pFeatureCursorDepot.NextFeature();
                    int            DepotNumberArriveDept = 0;
                    pEmergencyDepotResource = new List <EmergencyDepotResource>();
                    while (pFeatureDepot != null)
                    {
                        EmergencyDepotResource emergencydepotresource = new EmergencyDepotResource();
                        emergencydepotresource.DepotName           = Convert.ToString(pFeatureDepot.get_Value(pFeatureDepot.Fields.FindField("Name")));
                        emergencydepotresource.DepotArriveDeptTime = Math.Round(Convert.ToDouble(resultlist[DepotNumberArriveDept].WeightTime), 4);
                        DepotNumberArriveDept++;
                        emergencydepotresource.EmergencyVarietyNameNumber = new double[EmergencyNumber];
                        emergencydepotresource.EmergencyVarietyName       = new string[EmergencyNumber];
                        for (int k = 0; k < EmergencyNumber; k++)
                        {
                            emergencydepotresource.EmergencyVarietyName[k]       = EmergencyVarietyName[k];
                            emergencydepotresource.EmergencyVarietyNameNumber[k] = Convert.ToDouble(pFeatureDepot.get_Value(pFeatureDepot.Fields.FindField(EmergencyVarietyName[k])));
                        }
                        pEmergencyDepotResource.Add(emergencydepotresource);
                        pFeatureDepot = pFeatureCursorDepot.NextFeature();
                    }



                    //获取污染物扩散到达应急处置空间位置的时间
                    double        pollutionArriveTime = 0.0;
                    IFeatureClass pFeatureClassDept   = pFeatureLayerDept.FeatureClass;
                    IQueryFilter  pQueryFilterDept    = new QueryFilterClass();
                    pQueryFilterDept.WhereClause = "FID=" + Convert.ToString(Convert.ToInt32(comboBox4.Text) - 1);
                    IFeatureCursor pFeatureCursorDept = pFeatureClassDept.Search(pQueryFilterDept, false);
                    IFeature       pFeatureDept       = pFeatureCursorDept.NextFeature();
                    IPoint         point = new PointClass();
                    while (pFeatureDept != null)
                    {
                        point        = pFeatureDept.Shape as IPoint;
                        pFeatureDept = pFeatureCursorDept.NextFeature();
                    }
                    double X = 0.0, Y = 0.0;
                    X = Math.Round(point.X, 4);
                    Y = Math.Round(point.Y, 4);
                    int          column = 0, row = 0;
                    IRasterLayer pRasterLayer = CDataImport.ImportRasterLayerFromControltext(comboBox3.Text);
                    RasterManagement.XYconvertNumber(pRasterLayer, X, Y, ref column, ref row);
                    pollutionArriveTime = Convert.ToDouble(RasterManagement.GetPixelValue(pRasterLayer, 0, column, row));

                    //读取构架应急工程措施的时间
                    double SetProjectTime = Math.Round(Convert.ToDouble(textBox1.Text), 4);

                    //对各个应急资源仓库到达应急处置空间位置的时间进行排序
                    BubbleSort(pEmergencyDepotResource);

                    //进行应急资源调度
                    List <EmergencyResourceResult> pEergencyResourceResult = new List <EmergencyResourceResult>();
                    for (int k = 0; k < DepotNumber; k++)                                                          //按照到达应急处置空间位置的应急仓库进行排序
                    {
                        if (pEmergencyDepotResource[k].DepotArriveDeptTime + SetProjectTime < pollutionArriveTime) //判断到达应急处置空间位置与构建工程时间之和小于污染物扩散到达时间
                        {
                            //创建应急资源调度的结果
                            EmergencyResourceResult emergencyresourceresult = new EmergencyResourceResult();
                            emergencyresourceresult.EmergencyResourceName   = new string[pEmergencyDepotResource[k].EmergencyVarietyName.Length];
                            emergencyresourceresult.EmergencyResourceNumber = new double[pEmergencyDepotResource[k].EmergencyVarietyNameNumber.Length];
                            for (int l = 0; l < pEmergencyDeptResource.Count; l++)                               //应急处置空间位置需要的应急资源种类
                            {
                                for (int h = 0; h < pEmergencyDepotResource[k].EmergencyVarietyName.Length; h++) //对应急资源仓库的应急资源名称进行查找和应急处置空间位置名称相同
                                {
                                    if (pEmergencyDepotResource[k].EmergencyVarietyName[h] == pEmergencyDeptResource[l].EmergencyDemandResourceName && pEmergencyDepotResource[k].EmergencyVarietyNameNumber[h] > 0)
                                    {
                                        emergencyresourceresult.DepotName = pEmergencyDepotResource[k].DepotName;
                                        emergencyresourceresult.EmergencyResourceArriveTime = pEmergencyDepotResource[k].DepotArriveDeptTime;
                                        if (pEmergencyDeptResource[l].EmergencyDemandResourceNumber <= pEmergencyDepotResource[k].EmergencyVarietyNameNumber[h])
                                        {
                                            emergencyresourceresult.EmergencyResourceName[l]          = pEmergencyDeptResource[l].EmergencyDemandResourceName;
                                            emergencyresourceresult.EmergencyResourceNumber[l]        = pEmergencyDeptResource[l].EmergencyDemandResourceNumber;
                                            pEmergencyDepotResource[k].EmergencyVarietyNameNumber[h] -= pEmergencyDeptResource[l].EmergencyDemandResourceNumber;
                                            pEmergencyDepotResource[k].EmergencyDepotBool             = true;
                                            pEmergencyDeptResource[l].EmergencyDemandResourceNumber  -= pEmergencyDeptResource[l].EmergencyDemandResourceNumber;
                                        }
                                        else
                                        {
                                            emergencyresourceresult.EmergencyResourceName[l]         = pEmergencyDeptResource[l].EmergencyDemandResourceName;
                                            emergencyresourceresult.EmergencyResourceNumber[l]       = pEmergencyDepotResource[k].EmergencyVarietyNameNumber[h];
                                            pEmergencyDeptResource[l].EmergencyDemandResourceNumber -= pEmergencyDepotResource[k].EmergencyVarietyNameNumber[l];
                                            pEmergencyDepotResource[k].EmergencyVarietyNameNumber[l] = 0.0;
                                            pEmergencyDepotResource[k].EmergencyDepotBool            = true;
                                        }
                                    }
                                }
                            }


                            //将有应急资源仓库调度资源的显示在ListBox中
                            for (int f = 0; f < emergencyresourceresult.EmergencyResourceNumber.Length; f++)
                            {
                                if (emergencyresourceresult.EmergencyResourceNumber[f] > 0)
                                {
                                    listBox1.Items.Add(pEmergencyDepotResource[k].DepotName);
                                    break;
                                }
                            }


                            //将应急资源调度的结果显示在ListBox
                            for (int a = 0; a < emergencyresourceresult.EmergencyResourceNumber.Length; a++)
                            {
                                if (emergencyresourceresult.EmergencyResourceNumber[a] > 0)
                                {
                                    listBox1.Items.Add(emergencyresourceresult.EmergencyResourceName[a] + ":" + Convert.ToString(emergencyresourceresult.EmergencyResourceNumber[a]));
                                }
                            }
                        }
                        else
                        {
                            //listBox1.Items.Add("其他的应急资源仓库的应急资源无法到达应急处置空间位置!");
                            break;
                        }

                        //如果应急处置空间位置的应急资源满足,则跳出应急资源调度过程
                        int DeptVarietyNumber = 0;
                        for (int b = 0; b < pEmergencyDeptResource.Count; b++)
                        {
                            if (pEmergencyDeptResource[b].EmergencyDemandResourceNumber == 0)
                            {
                                DeptVarietyNumber++;
                                continue;
                            }
                        }
                        if (DeptVarietyNumber == pEmergencyDeptResource.Count)
                        {
                            break;
                        }
                    }

                    //刷新应急处置点信息情况
                    for (int c = 0; c < pEmergencyDeptResource.Count; c++)
                    {
                        for (int d = 0; d < pLabel.Length; d++)
                        {
                            string VarietyName = pLabel[d].Text.Substring(0, pLabel[d].Text.LastIndexOf(":"));
                            if (VarietyName == pEmergencyDeptResource[c].EmergencyDemandResourceName)
                            {
                                pLabel[d].Text = pEmergencyDeptResource[c].EmergencyDemandResourceName + ":" + pEmergencyDeptResource[c].EmergencyDemandResourceNumber.ToString();
                                break;
                            }
                        }
                    }
                    groupBox4.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
        //根据应急资源需求类型,创建设置资源量的textbox
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox7.Text == "")
                {
                    MessageBox.Show("请资源需求类型", "输入资源需求类型", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    comboBox3.Items.Clear();
                    pFeatureLayerEmergency = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    //读取输入应急处置点图层的字段
                    IFeatureClass pFeatureClassField = pFeatureLayerEmergency.FeatureClass;
                    IFields       pFields            = pFeatureClassField.Fields;
                    IField        pField;
                    for (int j = 0; j < pFields.FieldCount; j++)
                    {
                        pField = pFields.get_Field(j);
                        comboBox3.Items.Add(pField.Name.ToString());
                    }

                    textBox1.Enabled  = true;
                    label3.Enabled    = true;
                    label5.Enabled    = true;
                    label6.Enabled    = true;
                    comboBox3.Enabled = true;
                    int number = Convert.ToInt32(textBox7.Text) - 1;
                    combobox = new ComboBox[number];
                    label    = new Label[number];
                    textbox  = new TextBox[number];
                    for (int i = 0; i < combobox.Length; i++)
                    {
                        if (i < 2)
                        {
                            combobox[i]               = new ComboBox();
                            combobox[i].Size          = comboBox3.Size;
                            combobox[i].DropDownStyle = comboBox3.DropDownStyle;
                            combobox[i].Location      = new System.Drawing.Point(comboBox3.Location.X, comboBox3.Location.Y + (i + 1) * 25);
                            for (int k = 0; k < pFields.FieldCount; k++)
                            {
                                pField = pFields.get_Field(k);
                                combobox[i].Items.Add(pField.Name.ToString());
                            }
                            groupBox2.Controls.Add(combobox[i]);
                            label[i]          = new Label();
                            label[i].Size     = label3.Size;
                            label[i].Text     = ":";
                            label[i].Location = new System.Drawing.Point(label3.Location.X, label3.Location.Y + (i + 1) * 25);
                            groupBox2.Controls.Add(label[i]);
                            textbox[i]          = new TextBox();
                            textbox[i].Size     = textBox1.Size;
                            textbox[i].Location = new System.Drawing.Point(textBox1.Location.X, textBox1.Location.Y + (i + 1) * 25);
                            groupBox2.Controls.Add(textbox[i]);
                        }
                        else if (1 < i && i < 5)
                        {
                            if (i == 2)
                            {
                                Label pLabel1 = new Label();
                                pLabel1.Size     = label5.Size;
                                pLabel1.Text     = label5.Text;
                                pLabel1.Location = new System.Drawing.Point(label5.Location.X + 250, label5.Location.Y);
                                groupBox2.Controls.Add(pLabel1);
                                Label pLabel2 = new Label();
                                pLabel2.Size     = label6.Size;
                                pLabel2.Text     = label6.Text;
                                pLabel2.Location = new System.Drawing.Point(label6.Location.X + 250, label6.Location.Y);
                                groupBox2.Controls.Add(pLabel2);
                            }

                            combobox[i]               = new ComboBox();
                            combobox[i].Size          = comboBox3.Size;
                            combobox[i].DropDownStyle = comboBox3.DropDownStyle;
                            combobox[i].Location      = new System.Drawing.Point(comboBox3.Location.X + 250, comboBox3.Location.Y + (i - 2) * 25);
                            for (int k = 0; k < pFields.FieldCount; k++)
                            {
                                pField = pFields.get_Field(k);
                                combobox[i].Items.Add(pField.Name.ToString());
                            }
                            groupBox2.Controls.Add(combobox[i]);
                            label[i]          = new Label();
                            label[i].Size     = label3.Size;
                            label[i].Text     = ":";
                            label[i].Location = new System.Drawing.Point(label3.Location.X + 250, label3.Location.Y + (i - 2) * 25);
                            groupBox2.Controls.Add(label[i]);
                            textbox[i]          = new TextBox();
                            textbox[i].Size     = textBox1.Size;
                            textbox[i].Location = new System.Drawing.Point(textBox1.Location.X + 250, textBox1.Location.Y + (i - 2) * 25);
                            groupBox2.Controls.Add(textbox[i]);
                        }
                    }
                    comboBox3.SelectedIndex = 0;
                    for (int l = 0; l < number; l++)
                    {
                        combobox[l].SelectedIndex         = 0;
                        combobox[l].SelectedIndexChanged += new EventHandler(FrmSetEmergencyResourceDemand_SelectedIndexChanged);
                    }

                    IFeatureClass pFeatureClassIndex = pFeatureLayerEmergency.FeatureClass;
                    IQueryFilter  pQueryFilterIndex  = new QueryFilterClass();
                    pQueryFilterIndex.WhereClause = "FID=" + Convert.ToString(Convert.ToInt32(comboBox2.Text) - 1);
                    IFeatureCursor pFeatureCursorIndex = pFeatureClassIndex.Search(pQueryFilterIndex, false);
                    IFeature       pFeatureIndex       = pFeatureCursorIndex.NextFeature();
                    while (pFeatureIndex != null)
                    {
                        for (int i = 0; i < combobox.Length; i++)
                        {
                            textbox[i].Text = Convert.ToString(pFeatureIndex.get_Value(pFeatureIndex.Fields.FindField(combobox[i].Text)));
                        }
                        pFeatureIndex = pFeatureCursorIndex.NextFeature();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Esempio n. 14
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入应急资源仓库数据", "输入应急资源仓库数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入应急处置空间位置数据", "输入应急处置空间位置数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    IFeatureLayer pFeatureLayerDepot = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);

                    List <IPoint>  Depotpoint          = new List <IPoint>();
                    IFeatureClass  pFeatureClassDepot  = pFeatureLayerDepot.FeatureClass;
                    IFeatureCursor pFeatureCursorDepot = pFeatureClassDepot.Search(null, false);
                    IFeature       pFeatureDepot       = pFeatureCursorDepot.NextFeature();
                    while (pFeatureDepot != null)
                    {
                        Depotpoint.Add(pFeatureDepot.Shape as IPoint);
                        pFeatureDepot = pFeatureCursorDepot.NextFeature();
                    }

                    IFeatureLayer pFeatureLayerDept = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);

                    List <IPoint>  Deptpoint          = new List <IPoint>();
                    IFeatureClass  pFeatureClassDept  = pFeatureLayerDept.FeatureClass;
                    IFeatureCursor pFeatureCursorDept = pFeatureClassDept.Search(null, false);
                    IFeature       pFeatureDept       = pFeatureCursorDept.NextFeature();
                    while (pFeatureDept != null)
                    {
                        Deptpoint.Add(pFeatureDept.Shape as IPoint);
                        pFeatureDept = pFeatureCursorDept.NextFeature();
                    }

                    //获取应急资源仓库到达应急处置空间位置的路径
                    DijkstraClass.DynamicRoutePlanDijkstra pDynamicRoutePlan = new DijkstraClass.DynamicRoutePlanDijkstra();
                    List <Result> resultlist = new List <Result>();
                    resultlist = pDynamicRoutePlan.DepotToDest(pFeatureLayerDepot, pFeatureLayerDept, pRoadAgent);

                    //将路网初始化成IPolyline
                    Collection <RouteNode> routeNodes = new Collection <RouteNode>();//存储某起点和终点最短路径网络所经过的结点
                    List <IPolyline>       routeroad  = new List <IPolyline>();
                    RouteResult = new List <List <VehicleRouteResult> >();
                    for (int i = 0; i < resultlist.Count; i++)
                    {
                        foreach (string str in resultlist[i].StrResultNode)
                        {
                            DynamicRoutePlanDijkstra.addRouteNodes(routeNodes, str);
                        }
                        DynamicRoutePlanDijkstra.addRouteNodes(routeNodes, resultlist[i].EndNodeID);
                        List <VehicleRouteResult> ListVehicleRouteResult = new List <VehicleRouteResult>();
                        ListVehicleRouteResult = pDynamicRoutePlan.GetVehicleRoad(routeNodes, Depotpoint[i], Deptpoint[0]);
                        RouteResult.Add(ListVehicleRouteResult);
                        ListVehicleRouteResult = null;

                        //显示路线在主页面上
                        pDynamicRoutePlan.GetIElement(routeNodes);
                        routeroad.Add(Variable.PElement.Geometry as IPolyline);

                        routeNodes.Clear();
                    }
                    //显示路线在主页面上
                    DynamicRoutePlanDijkstra.GetIElement(routeroad);
                    DynamicRoutePlanDijkstra.displayElement();


                    //道路智能体的初始化



                    //进行车辆智能体的运行
                    for (int k = 0; k < Depotpoint.Count; k++)
                    {
                        EmergencyVehicle emergencyVehicle = new EmergencyVehicle();
                        emergencyVehicle.OriginationPoint = Depotpoint[k];
                        emergencyVehicle.DestinationPoint = Deptpoint[0];
                        emergencyVehicle.PlanRouteResult  = RouteResult[k];
                        pEmergencyVehicleAgent.Add(emergencyVehicle);
                    }

                    VehicleCount  = pEmergencyVehicleAgent.Count;
                    ProgressCount = new int[VehicleCount];

                    //初始化车辆所在的路网中
                    for (int j = 0; j < VehicleCount; j++)
                    {
                        ProgressCount[j] = 0;
                    }

                    //获取车辆当前所在路网的路段
                    for (int a = 0; a < VehicleCount; a++)
                    {
                        pEmergencyVehicleAgent[a].RunVehicleLine     = pEmergencyVehicleAgent[a].PlanRouteResult[ProgressCount[a]].pLine;
                        pEmergencyVehicleAgent[a].CurrentLine        = pEmergencyVehicleAgent[a].PlanRouteResult[ProgressCount[a]].pLine;
                        pEmergencyVehicleAgent[a].CurrentOrigination = pEmergencyVehicleAgent[a].PlanRouteResult[ProgressCount[a]].Startpoint;
                        pEmergencyVehicleAgent[a].CurrentDestination = pEmergencyVehicleAgent[a].PlanRouteResult[ProgressCount[a]].Endpoint;
                        pEmergencyVehicleAgent[a].Distance           = 1550.5;
                    }

                    //获取车辆所在的路网的的点
                    for (int b = 0; b < VehicleCount; b++)
                    {
                        if (pEmergencyVehicleAgent[b].CurrentLine.FromPoint.X == pEmergencyVehicleAgent[b].CurrentOrigination.X && pEmergencyVehicleAgent[b].CurrentLine.FromPoint.Y == pEmergencyVehicleAgent[b].CurrentOrigination.Y)
                        {
                            pEmergencyVehicleAgent[b].CurrentPoint = pEmergencyVehicleAgent[b].CurrentLine.FromPoint;
                        }
                        else
                        {
                            pEmergencyVehicleAgent[b].CurrentPoint = pEmergencyVehicleAgent[b].CurrentLine.ToPoint;
                        }
                    }
                    for (int c = 0; c < VehicleCount; c++)
                    {
                        DrawPointElement(pEmergencyVehicleAgent[c].CurrentPoint);
                    }


                    timer1.Enabled  = true;
                    timer1.Interval = 1500;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
        //保存应急处置空间位置的信息
        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入可供选择的应急处置空间位置的数据", "输入可供选择的应急处置空间位置的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入河流流速的数据", "输入河流流速的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox3.Text == "")
                {
                    MessageBox.Show("请输入河流流量的数据", "输入河流流量的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox4.Text == "")
                {
                    MessageBox.Show("请输入河流宽度的数据", "输入河流宽度的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox5.Text == "")
                {
                    MessageBox.Show("请输入河流污染物浓度的数据", "输入河流污染物浓度的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox6.Text == "")
                {
                    MessageBox.Show("请输入河流总量的数据", "输入河流污染物总量的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    IRasterLayer   pVRasterLayer      = CDataImport.ImportRasterLayerFromControltext(comboBox2.Text);
                    IRasterLayer   pQRasterLayer      = CDataImport.ImportRasterLayerFromControltext(comboBox3.Text);
                    IRasterLayer   pLRasterLayer      = CDataImport.ImportRasterLayerFromControltext(comboBox4.Text);
                    IRasterLayer   pCRasterLayer      = CDataImport.ImportRasterLayerFromControltext(comboBox5.Text);
                    IRasterLayer   pSRasterLayer      = CDataImport.ImportRasterLayerFromControltext(comboBox6.Text);
                    IFeatureLayer  pFeatureLayerSave  = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    IFeatureClass  pFeatureClassSave  = pFeatureLayerSave.FeatureClass;
                    IFeatureCursor pFeatureCursorSave = pFeatureClassSave.Update(null, false);
                    IFeature       pFeatureSave       = pFeatureCursorSave.NextFeature();
                    IPoint         point = new PointClass();
                    double         X = 0.0, Y = 0.0;
                    int            column = 0, row = 0;
                    while (pFeatureSave != null)
                    {
                        point = pFeatureSave.Shape as IPoint;
                        X     = point.X;
                        Y     = point.Y;
                        RasterManagement.XYconvertNumber(pVRasterLayer, X, Y, ref column, ref row);
                        pFeatureSave.set_Value(pFeatureSave.Fields.FindField("V"), Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pVRasterLayer, 0, column, row)), 4));

                        RasterManagement.XYconvertNumber(pQRasterLayer, X, Y, ref column, ref row);
                        pFeatureSave.set_Value(pFeatureSave.Fields.FindField("Q"), Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pQRasterLayer, 0, column, row)), 4));

                        RasterManagement.XYconvertNumber(pLRasterLayer, X, Y, ref column, ref row);
                        pFeatureSave.set_Value(pFeatureSave.Fields.FindField("L"), Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pLRasterLayer, 0, column, row)), 4));

                        RasterManagement.XYconvertNumber(pCRasterLayer, X, Y, ref column, ref row);
                        pFeatureSave.set_Value(pFeatureSave.Fields.FindField("C"), Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pCRasterLayer, 0, column, row)), 4));

                        RasterManagement.XYconvertNumber(pSRasterLayer, X, Y, ref column, ref row);
                        pFeatureSave.set_Value(pFeatureSave.Fields.FindField("S"), Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pSRasterLayer, 0, column, row)), 4));

                        pFeatureCursorSave.UpdateFeature(pFeatureSave);
                        pFeatureSave = pFeatureCursorSave.NextFeature();
                    }

                    MessageBox.Show("程序运行完成!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Esempio n. 16
0
        //通过第一处置点和即将污染的水系,把第一处置点下游按照应急处置空间位置相距进行切分,获得每段的中心点
        //并判断这些点是否在可供选择的应急处置河段,则获得可供选择的应急处置空间位置
        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入可供选择的首个应急处置空间位置数据", "输入可供选择的首个应急处置空间位置数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入即将污染的河流数据", "输入即将污染的河流数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox3.Text == "")
                {
                    MessageBox.Show("请输入可选择应急处置河段数据", "输入可选择应急处置河段数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (textBox1.Text == "")
                {
                    MessageBox.Show("请输入应急处置空间位置相距的距离", "输入应急处置空间位置相距的距离", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox6.Text == "")
                {
                    MessageBox.Show("请输出应急处置空间位置的数据", "输出应急处置空间位置的数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    IFeatureLayer  pFeatureLayerSpacepoint  = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    IFeatureClass  pFeatureClassSpacepoint  = pFeatureLayerSpacepoint.FeatureClass;
                    IFeatureCursor pFeatureCursorSpacepoint = pFeatureClassSpacepoint.Search(null, false);
                    IFeature       pFeatureSpacepoint       = pFeatureCursorSpacepoint.NextFeature();
                    IPoint         pFirstpoint = new PointClass();
                    while (pFeatureSpacepoint != null)
                    {
                        pFirstpoint        = pFeatureSpacepoint.Shape as IPoint;
                        pFeatureSpacepoint = pFeatureCursorSpacepoint.NextFeature();
                    }

                    //根据应急处置点最短的距离,获取即将污染河流分段的各个点
                    double         distance  = Convert.ToDouble(textBox1.Text);
                    List <IPoint>  pointlist = new List <IPoint>();
                    IFeatureLayer  pFeatureLayerPollutionRiver  = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);
                    IFeatureClass  pFeatureClassPollutionRiver  = pFeatureLayerPollutionRiver.FeatureClass;
                    IFeatureCursor pFeatureCursorPollutionRiver = pFeatureClassPollutionRiver.Search(null, false);
                    IFeature       pFeaturePollutionRiver       = pFeatureCursorPollutionRiver.NextFeature();
                    while (pFeaturePollutionRiver != null)
                    {
                        IPolyline pLine = new PolylineClass();
                        pLine = pFeaturePollutionRiver.Shape as IPolyline;
                        pLine = GetPointSplitAtPoint(pLine, pFirstpoint);
                        IPolyline retureline  = new PolylineClass();
                        IPoint    returepoint = new PointClass();
                        for (double i = distance; i < pLine.Length;)
                        {
                            GetPointSplitAtDistance(pLine, i, ref retureline, ref returepoint);
                            pLine = retureline;
                            pointlist.Add(returepoint);
                        }

                        pFeaturePollutionRiver = pFeatureCursorPollutionRiver.NextFeature();
                    }

                    //SaveVector.pointtoFeatureLayer(comboBox6.Text, pointlist, pFeatureLayerPollutionRiver);

                    //根据可供选择的河段和即将污染的河流分段的点,获取可供选择的应急处置空间位置点
                    List <IPoint> pointresultlist = new List <IPoint>();
                    IFeatureLayer pFeatureLayerPossibleSelectionRiver = CDataImport.ImportFeatureLayerFromControltext(comboBox3.Text);
                    for (int j = 0; j < pointlist.Count; j++)
                    {
                        if (LineContainPoint(pointlist[j], pFeatureLayerPossibleSelectionRiver) == true)
                        {
                            pointresultlist.Add(pointlist[j]);
                        }
                    }

                    SaveVector.pointtoFeatureLayer(comboBox6.Text, pointresultlist, pFeatureLayerPossibleSelectionRiver);
                    MessageBox.Show("程序运行结束!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Esempio n. 17
0
        //进行计算时间上可行的第一个空间位置
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入应急资源仓库数据", "输入应急资源仓库数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入道路网络数据", "输入道路网络数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox3.Text == "")
                {
                    MessageBox.Show("请输入污染物扩散模拟过程数据", "输入污染物扩散模拟过程数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (textBox1.Text == "")
                {
                    MessageBox.Show("请输入应急处置工程建设时间(单位:分钟):", "输入应急处置工程建设时间(单位:分钟):", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox4.Text == "")
                {
                    MessageBox.Show("请输出可供选择首个应急处置空间位置", "输出可供选择首个应急处置空间位置", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    int    row = 0, column = 0;
                    double X = 0.0, Y = 0.0;
                    double pixelvalue = 0.0;

                    IRasterLayer  pRasterLayer       = CDataImport.ImportRasterLayerFromControltext(comboBox3.Text);
                    IFeatureLayer pFeatureLayerDepot = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    IFeatureLayer pFeatureLayerroad  = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text);
                    //获取污染物模拟河流的外包络线
                    IRaster      pRaster      = pRasterLayer.Raster;
                    IRasterProps pRasterprops = pRaster as IRasterProps;
                    IEnvelope    pEnvelope    = pRasterprops.Extent;
                    IPoint       p1           = new PointClass();
                    IPoint       p2           = new PointClass();
                    IPoint       p3           = new PointClass();
                    IPoint       p4           = new PointClass();
                    p1 = pEnvelope.UpperLeft;
                    p2 = pEnvelope.LowerLeft;
                    p3 = pEnvelope.LowerRight;
                    p4 = pEnvelope.UpperRight;
                    IPointCollection pointCollection = new PolygonClass();
                    object           missing         = Type.Missing;
                    pointCollection.AddPoint(p1, ref missing, ref missing);
                    pointCollection.AddPoint(p2, ref missing, ref missing);
                    pointCollection.AddPoint(p3, ref missing, ref missing);
                    pointCollection.AddPoint(p4, ref missing, ref missing);
                    pointCollection.AddPoint(p1, ref missing, ref missing);
                    IPolygon  polygon   = (IPolygon)pointCollection;
                    IGeometry pGeometry = new PolygonClass();
                    pGeometry = polygon as IGeometry;
                    //获取应急资源仓库到达各个节点的最短路径
                    List <IFeature> listFeature = new List <IFeature>();
                    listFeature = GetPolygonFeatureList(pFeatureLayerroad, pGeometry);
                    RoutePlanResult startNoderesult = null, EndNoderesult = null, minStartNodeResult = null, minEndNodeResult = null;
                    DijkstraDepotToAllNodeMethod path = new DijkstraDepotToAllNodeMethod();
                    path.InitializationRoadNetwork(pFeatureLayerDepot);
                    List <PlanCourse> resultplancourse = path.DepotToAllNode();

                    RasterManagement.GetRasterCount(pRasterLayer, ref row, ref column);
                    double[] desttime = new double[2];
                    int      sign     = 0;
                    //IFeature pFeature = null;
                    string    strStartID = null, strEndID = null;
                    double    time = 0.0;
                    double    returnX = 0.0, returnY = 0.0;
                    double    pFrompointToOutpointLength = 0.0, pOutpointToEndpointLength = 0.0;
                    IPolyline polyline = new PolylineClass();
                    //对污染物模拟栅格从[0,0]进行循环,选取从时间上作为应急处置空间位置的可行性的点
                    for (int i = 0; i < row; i++)
                    {
                        for (int j = 0; j < column; j++)
                        {
                            pixelvalue = Convert.ToDouble(RasterManagement.GetPixelValue(pRasterLayer, 0, j, i));
                            if (pixelvalue != 0)
                            {
                                IFeature pFeature = null;
                                RasterManagement.NumbercovertXY(pRasterLayer, ref X, ref Y, j, i);
                                IPoint point = new PointClass();
                                point.PutCoords(X, Y);

                                IPoint ppoint = new PointClass();
                                GetMindistanceandpoint(point, listFeature, ref returnX, ref returnY, ref pFeature, ref pFrompointToOutpointLength);
                                ppoint.PutCoords(returnX, returnY);
                                strStartID = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField("StartNodeI")));
                                strEndID   = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField("EndNodeID")));
                                time       = Convert.ToDouble(pFeature.get_Value(pFeature.Fields.FindField("Minutes")));
                                polyline   = pFeature.Shape as IPolyline;
                                pOutpointToEndpointLength = polyline.Length - pFrompointToOutpointLength;
                                //获取应急仓库到达应急处置点最短时间的点
                                minStartNodeResult = startNoderesult = RoutePlanner.GetResult(resultplancourse[0], strStartID);
                                minEndNodeResult   = EndNoderesult = RoutePlanner.GetResult(resultplancourse[0], strEndID);
                                for (int m = 1; m < resultplancourse.Count; m++)
                                {
                                    startNoderesult = RoutePlanner.GetResult(resultplancourse[m], strStartID);
                                    EndNoderesult   = RoutePlanner.GetResult(resultplancourse[m], strEndID);
                                    if (minStartNodeResult.WeightValues > startNoderesult.WeightValues)
                                    {
                                        minStartNodeResult = startNoderesult;
                                    }
                                    if (minEndNodeResult.WeightValues > EndNoderesult.WeightValues)
                                    {
                                        minEndNodeResult = EndNoderesult;
                                    }
                                }
                                desttime[0] = time * (pFrompointToOutpointLength / (pFrompointToOutpointLength + pOutpointToEndpointLength));
                                desttime[1] = time - desttime[0];
                                //判断污染物到达该应急处置空间位置的时间是否大于应急资源调度时间与工程措施建设时间之和
                                if (minStartNodeResult.WeightValues + desttime[0] > minEndNodeResult.WeightValues + desttime[1])
                                {
                                    if ((minEndNodeResult.WeightValues + desttime[1] + Convert.ToDouble(textBox1.Text)) < pixelvalue)
                                    {
                                        List <IPoint> pointlist = new List <IPoint>();
                                        pointlist.Add(point);
                                        SaveVector.pointtoFeatureLayer(comboBox4.Text, pointlist, pFeatureLayerDepot);
                                        sign = 1;
                                        break;
                                    }
                                }
                                else
                                {
                                    if ((minStartNodeResult.WeightValues + desttime[0] + Convert.ToDouble(textBox1.Text)) < pixelvalue)
                                    {
                                        List <IPoint> pointlist = new List <IPoint>();
                                        pointlist.Add(point);
                                        SaveVector.pointtoFeatureLayer(comboBox4.Text, pointlist, pFeatureLayerDepot);
                                        sign = 1;
                                        break;
                                    }
                                }
                            }
                        }
                        if (sign == 1)
                        {
                            break;
                        }
                    }
                    MessageBox.Show("处理完毕!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Esempio n. 18
0
        //进行应急资源调度模型的计算
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("请输入应急资源仓库数据", "输入应急资源仓库数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox2.Text == "")
                {
                    MessageBox.Show("请输入应急处置空间位置数据", "输入应急处置空间位置数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else if (comboBox3.Text == "")
                {
                    MessageBox.Show("请输入污染物扩散模拟过程数据", "输入污染物扩散模拟过程数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    //初始化应急处置空间位置应急资源调度到达时间
                    IFeatureLayer             pFeatureLayerDepot = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);//获取应急仓库图层
                    IFeatureClass             pFeatureClassDepot = pFeatureLayerDepot.FeatureClass;
                    int                       DepotCount         = pFeatureClassDepot.FeatureCount(null);
                    int                       DepotFieldCount    = pFeatureClassDepot.Fields.FieldCount;
                    IFeatureLayer             pFeatureLayerDest  = CDataImport.ImportFeatureLayerFromControltext(comboBox2.Text); //获取应急处置空间位置图层
                    IFeatureClass             pFeatureClassDest  = pFeatureLayerDest.FeatureClass;
                    int                       DestCount          = pFeatureClassDest.FeatureCount(null);
                    int                       DestFieldCount     = pFeatureClassDest.Fields.FieldCount;
                    DijkstraDepotToDestMethod path       = new DijkstraDepotToDestMethod();
                    List <Result>             resultlist = new List <Result>();
                    resultlist = path.DepotToDest(pFeatureLayerDepot, pFeatureLayerDest);
                    //获取应急资源仓库到达应急处置空间位置的时间
                    double[,] materialArrivetime = new double[DepotCount, DestCount];
                    int count = 0;
                    for (int m = 0; m < DepotCount; m++)
                    {
                        for (int n = 0; n < DestCount; n++)
                        {
                            materialArrivetime[m, n] = resultlist[count].WeightTime;
                            count++;
                        }
                    }

                    double[,] materialdemand = new double[DestCount, DestFieldCount - 4];
                    List <DestProperty> pMaterialdemand = new List <DestProperty>();
                    string[]            pFieldName      = new string[DestFieldCount - 4];
                    //获取应急资源名称
                    int namecount = 0;
                    for (int i = 0; i < DestFieldCount; i++)
                    {
                        IField pField = new FieldClass();
                        pField = pFeatureLayerDest.FeatureClass.Fields.get_Field(i);
                        if (pField.Name.ToUpper() == "FID" || pField.Name.ToUpper() == "SHAPE" || pField.Name.ToUpper() == "NAME" || pField.Name.ToUpper() == "PROJECT")
                        {
                            continue;
                        }
                        else
                        {
                            pFieldName[namecount] = pField.Name;
                            namecount++;
                        }
                    }
                    double[,] materialstore = new double[DepotCount, pFieldName.Length];
                    List <DepotProperty> pERDepot            = new List <DepotProperty>();
                    IFeatureCursor       pFeatureCursorDepot = pFeatureClassDepot.Search(null, false);
                    IFeature             pFeatureDepot       = pFeatureCursorDepot.NextFeature();
                    int pdepotcount = 0;
                    while (pFeatureDepot != null)
                    {
                        for (int i = 0; i < pFieldName.Length; i++)
                        {
                            materialstore[pdepotcount, i] = Convert.ToDouble(pFeatureDepot.get_Value(pFeatureDepot.Fields.FindField(pFieldName[i])));
                            DepotProperty erdepot = new DepotProperty();
                            erdepot.Resourcename = pFieldName[i];
                            erdepot.Depotname    = Convert.ToString(pFeatureDepot.get_Value(pFeatureDepot.Fields.FindField("Name")));
                            erdepot.Row          = pdepotcount;
                            erdepot.Column       = i;
                            erdepot.Number       = Convert.ToDouble(pFeatureDepot.get_Value(pFeatureDepot.Fields.FindField(pFieldName[i])));
                            pERDepot.Add(erdepot);
                        }
                        pdepotcount++;
                        pFeatureDepot = pFeatureCursorDepot.NextFeature();
                    }
                    //污染物扩散过程到达应急处置空间位置的时间
                    IRasterLayer   pRasterLayer       = CDataImport.ImportRasterLayerFromControltext(comboBox3.Text);
                    IFeatureCursor pFeatureCursorDest = pFeatureClassDest.Search(null, false);
                    IFeature       pFeatureDest       = pFeatureCursorDest.NextFeature();
                    IPoint         pointDest          = new PointClass();
                    List <PollutionArriveDestProperty> PollutionArriveTime = new List <PollutionArriveDestProperty>();
                    List <PollutionArriveDestProperty> ProjectTime         = new List <PollutionArriveDestProperty>();
                    int pdestcount = 0;
                    while (pFeatureDest != null)
                    {
                        //获取污染物到达应急处置空间位置的时间,即为应急处置的最高时间
                        string destname = Convert.ToString(pFeatureDest.get_Value(pFeatureDest.Fields.FindField("Name")));
                        double X = 0.0, Y = 0.0;
                        int    column = 0, row = 0;
                        pointDest = pFeatureDest.Shape as IPoint;
                        X         = pointDest.X;
                        Y         = pointDest.Y;
                        RasterManagement.XYconvertNumber(pRasterLayer, X, Y, ref column, ref row);
                        PollutionArriveDestProperty pullutionarrivetime = new PollutionArriveDestProperty();
                        pullutionarrivetime.Arrivetime = Math.Round(Convert.ToDouble(RasterManagement.GetPixelValue(pRasterLayer, 0, column, row)), 2);
                        pullutionarrivetime.Destname   = destname;
                        pullutionarrivetime.Sequence   = pdestcount + 1;
                        PollutionArriveTime.Add(pullutionarrivetime);
                        //获取应急处置空间位置应急物资需求
                        for (int i = 0; i < pFieldName.Length; i++)
                        {
                            materialdemand[pdestcount, i] = Convert.ToDouble(pFeatureDest.get_Value(pFeatureDest.Fields.FindField(pFieldName[i])));
                            DestProperty erdest = new DestProperty();
                            erdest.Resourcename = pFieldName[i];
                            erdest.Destname     = destname;
                            erdest.Row          = pdestcount;
                            erdest.Column       = i;
                            erdest.Number       = Convert.ToDouble(pFeatureDest.get_Value(pFeatureDest.Fields.FindField(pFieldName[i])));
                            pMaterialdemand.Add(erdest);
                        }
                        PollutionArriveDestProperty projecttime = new PollutionArriveDestProperty();
                        projecttime.Arrivetime = Convert.ToDouble(pFeatureDest.get_Value(pFeatureDest.Fields.FindField("Project")));
                        projecttime.Destname   = destname;
                        ProjectTime.Add(projecttime);
                        pdestcount++;
                        pFeatureDest = pFeatureCursorDest.NextFeature();
                    }
                    BubbleSort(PollutionArriveTime);
                    List <EmergencyScheduleArriveProperty> ERSTime = new List <EmergencyScheduleArriveProperty>();
                    //根据污染物到达应急处置空间位置先后顺序进行应急资源调度
                    for (int j = 0; j < PollutionArriveTime.Count; j++)
                    {
                        listBox1.Items.Add(PollutionArriveTime[j].Destname + "应急资源的调度情况:");
                        listBox1.Items.Add("");
                        ERSTime.Clear();
                        int destsequence = (PollutionArriveTime[j].Sequence - 1) * pFieldName.Length;

                        //对应急物资资源库到达应急处置空间位置的时间进行排序,以便从最短的应急资源仓库进行调度
                        int pdestsequence = PollutionArriveTime[j].Sequence - 1;
                        for (int n = 0; n < DepotCount; n++)
                        {
                            EmergencyScheduleArriveProperty pertime = new EmergencyScheduleArriveProperty();
                            pertime.TotalTime = resultlist[pdestsequence].WeightTime + ProjectTime[PollutionArriveTime[j].Sequence - 1].Arrivetime;
                            pertime.Sequence  = n + 1;
                            ERSTime.Add(pertime);
                            pdestsequence += DestCount;
                        }
                        BubbleSort(ERSTime);
                        //根据应急处置点需求的应急资源进行处置
                        for (int m = 0; m < pFieldName.Length; m++)
                        {
                            listBox1.Items.Add(pFieldName[m] + "需求量为:" + pMaterialdemand[destsequence].Number.ToString());

                            //根据应急资源需求的紧迫度,进行应急资源的调度
                            if (pMaterialdemand[destsequence].Number > 0)
                            {
                                for (int k = 0; k < ERSTime.Count; k++)
                                {
                                    if (ERSTime[k].TotalTime > PollutionArriveTime[j].Arrivetime)
                                    {
                                        listBox1.Items.Add("剩余的应急资源物资无法在指定时间范围内到该应急处置空间位置!");
                                        break;
                                    }
                                    else if (pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number > pMaterialdemand[destsequence].Number && ERSTime[k].TotalTime <= PollutionArriveTime[j].Arrivetime)
                                    {
                                        string strNumber = (pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number - pMaterialdemand[destsequence].Number).ToString("N2");
                                        pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number = Convert.ToDouble(strNumber);
                                        listBox1.Items.Add(pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Depotname + "→" + pMaterialdemand[destsequence].Destname + ":" + pMaterialdemand[destsequence].Number.ToString());
                                        Result pResult = new Result();
                                        pResult.DepotName = pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Depotname;
                                        pResult.DestName  = pMaterialdemand[destsequence].Destname;
                                        for (int x = 0; x < resultlist.Count; x++)
                                        {
                                            if (resultlist[x].DepotName == pResult.DepotName && resultlist[x].DestName == pResult.DestName)
                                            {
                                                if (resultlist[x].dynamicschedule == false)
                                                {
                                                    resultlist[x].dynamicschedule = true;
                                                }
                                            }
                                        }
                                        pMaterialdemand[destsequence].Number = 0.0;
                                        break;
                                    }
                                    else if (pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number > 0 && pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number < pMaterialdemand[destsequence].Number && ERSTime[k].TotalTime <= PollutionArriveTime[j].Arrivetime)
                                    {
                                        string strNumber = (pMaterialdemand[destsequence].Number - pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number).ToString("N2");
                                        pMaterialdemand[destsequence].Number = Convert.ToDouble(strNumber);
                                        listBox1.Items.Add(pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Depotname + "→" + pMaterialdemand[destsequence].Destname + ":" + pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number.ToString());
                                        Result pResult = new Result();
                                        pResult.DepotName = pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Depotname;
                                        pResult.DestName  = pMaterialdemand[destsequence].Destname;
                                        for (int x = 0; x < resultlist.Count; x++)
                                        {
                                            if (resultlist[x].DepotName == pResult.DepotName && resultlist[x].DestName == pResult.DestName)
                                            {
                                                if (resultlist[x].dynamicschedule == false)
                                                {
                                                    resultlist[x].dynamicschedule = true;
                                                }
                                            }
                                        }
                                        pERDepot[(ERSTime[k].Sequence - 1) * pFieldName.Length + m].Number = 0.0;
                                        if (k == ERSTime.Count - 1 && pMaterialdemand[destsequence].Number != 0)
                                        {
                                            listBox1.Items.Add("应急资源仓库的存储应急资源物资不足!");
                                        }
                                    }
                                }
                            }
                            destsequence++;
                            listBox1.Items.Add("");
                        }
                        listBox1.Items.Add("应急资源调度路线:");
                    }


                    Collection <RouteNode> routeNodes = new Collection <RouteNode>();       //存储某起点和终点最短路径网络所经过的结点

                    List <IPolyline> routeroad = new List <IPolyline>();

                    string r;
                    for (int y = 0; y < resultlist.Count; y++)
                    {
                        r = null;
                        if (resultlist[y].dynamicschedule == true)
                        {
                            foreach (string str in resultlist[y].StrResultNode)
                            {
                                r += str + "→";
                                DijkstraDepotToDestMethod.addRouteNodes(routeNodes, str);
                            }
                            r += resultlist[y].EndNodeID;
                            DijkstraDepotToDestMethod.addRouteNodes(routeNodes, resultlist[y].EndNodeID);
                            listBox1.Items.Add(r);
                            path.GetIElement(routeNodes);
                            routeroad.Add(Variable.PElement.Geometry as IPolyline);
                            routeNodes.Clear();
                        }
                        else
                        {
                            continue;
                        }
                    }
                    //获取
                    DijkstraDepotToDestMethod.GetIElement(routeroad);
                    DijkstraDepotToDestMethod.displayElement();
                    //IFeatureLayer comboBoxFeature=CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text);
                    //SaveVector.polylinetoFeatureLayer(comboBox4.Text, routeroad, comboBoxFeature);
                    MessageBox.Show("处理完毕!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }