Beispiel #1
0
        /// <summary>
        /// 批量加载任务区 根据任务区所属的灾情id加载
        /// </summary>
        /// <param name="pMapCtr"></param>
        /// <param name="id"></param>
        public static void LoadTaskAreas(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int id)
        {
            //读取并图上显示任务区任务区信息
            Core.Map.MapHelper map = new Core.Map.MapHelper(pMapCtr);
            map.ClearAllElement();
            //灾区
            Core.DAL.TaskAreas t_dal = new Core.DAL.TaskAreas();
            list_model = new List <Core.Model.TaskAreas>();
            //交点
            Core.DAL.DisaCrossPoint          dal    = new Core.DAL.DisaCrossPoint();
            List <Core.Model.DisaCrossPoint> models = new List <Core.Model.DisaCrossPoint>();

            //集结点
            Core.DAL.DisaGatherPoint          g_dal    = new Core.DAL.DisaGatherPoint();
            List <Core.Model.DisaGatherPoint> g_models = new List <Core.Model.DisaGatherPoint>();

            IEnvelope envelope = null;

            try
            {
                list_model = t_dal.GetList(id);
                if (list_model.Count == 0)
                {
                    MessageBox.Show("该灾区尚未生成任务区!");
                    return;
                }
                //加载
                foreach (Core.Model.TaskAreas t_model in list_model)
                {
                    LoadTaskArea(map, t_model);
                    IPolygon pPolygon = Core.Generic.Convertor.ToPolygon(t_model.PolygonString);
                    //获取多个Polygon的Envelope外包矩形
                    if (envelope == null)
                    {
                        envelope = pPolygon.Envelope;
                    }
                    else
                    {
                        envelope.Union(pPolygon.Envelope);
                    }

                    //models = dal.GetList(t_model.ID, id);
                    //foreach (Core.Model.DisaCrossPoint model in models)
                    //{
                    //    LoadCrossPoint(map, model);
                    //}

                    //g_models = g_dal.GetList(t_model.ID, id);
                    //foreach (Core.Model.DisaGatherPoint model in g_models)
                    //{
                    //    LoadGatherPoint(map, model);
                    //}
                }

                if (!envelope.IsEmpty)
                {
                    envelope.Expand(1.1, 1.1, true);
                }
                pMapCtr.Extent = envelope;
                pMapCtr.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误:" + ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 构建监测任务区
        /// </summary>
        /// <param name="pMapCtr"></param>
        public static void BuildTaskArea(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int id)
        {
            if (DataGrid == null)
            {
                MessageBox.Show("您可能尚对灾区进行网格剖分,请先进行网格化剖分后再构建任务区!");
                return;
            }
            //throw new Exception("您可能尚对灾区进行网格剖分,请先进行网格化剖分后再构建任务区!");
            if (DataGrid.Count == 0)
            {
                MessageBox.Show("没有监测要素的单元格!");
                return;
            }
            //throw new Exception("没有监测要素的单元格!");

            TaskAreas = new List <IPolygon>();
            IPolygon area;

            Geometry.Grid _grid;
            try
            {
                foreach (Geometry.Grid grid in DataGrid)
                {
                    _grid = grid;
                    if (grid.isMerged)
                    {
                        continue;                   //如果已经合并过,则跳过
                    }
                    if (!ExistsGridInDataGrid(ref _grid))
                    {
                        continue;                                   //如果不有数据单元格中,则跳过
                    }
                    area          = grid.BuildPolygon();
                    grid.isMerged = true;
                    //SetGridMerged(grid);
                    MergeNN(grid, ref area);
                    TaskAreas.Add(area);
                }

                if (TaskAreas.Count == 0)
                {
                    throw (new Exception("没有成功生成任务区域!"));
                }

                //存储任务区信息
                int i = 1;
                foreach (IPolygon polygon in TaskAreas)
                {
                    Core.Model.TaskAreas model = new Core.Model.TaskAreas();
                    Core.DAL.TaskAreas   dal   = new Core.DAL.TaskAreas();
                    model.Name          = "任务区" + i;
                    model.PID           = id;
                    model.PolygonString = CoScheduling.Core.Generic.Convertor.ToString(polygon);
                    dal.Add(model);
                    i++;
                }
                //显示任务区
                LoadTaskAreas(pMapCtr, id);
                //生成交点
                // getIntersect(TaskAreas, map);
            }
            catch (Exception ex) { MessageBox.Show("错误" + ex.Message); }
            finally
            {
                TaskAreas = null;
            }
        }