Esempio n. 1
0
        public static bool op = false;//fale--单元格数量创建灾区;true--单元格大小创建灾区


        /// <summary>
        /// 生成任务区域
        /// </summary>
        /// <param name="DID">灾区ID</param>
        /// <param name="GridHeight">单元格高度</param>
        /// <param name="GridWidth">单元格长度</param>
        /// <param name="pMapCtr">地图控件</param>
        public static void GenerateTask(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int DID,
                                        double GridWidth, double GridHeight)
        {
            Core.Model.DisaAreaInfo di;
            Core.DAL.DisaAreaInfo   dal = new Core.DAL.DisaAreaInfo();
            try
            {
                di = dal.GetModel(DID);
                if (di == null)
                {
                    throw (new Exception("读取灾区数据时出错"));
                }
                IPoint pnt = new ESRI.ArcGIS.Geometry.Point();
                pnt.X = di.LON;
                pnt.Y = di.LAT;
                Core.Map.MapHelper   maphelper = new Core.Map.MapHelper(pMapCtr);
                System.Drawing.Color color     = Color.Blue;
                ISymbol symbol = maphelper.CreateSimpleFillSymbol(color, 1, esriSimpleFillStyle.esriSFSHollow);
                double  radius = di.AffectedRadius / Core.Generic.SysEnviriment.LengthPerRad;
                MonitorTask.TaskAreaHelper th = new MonitorTask.TaskAreaHelper();
                th.LoadMapData();
                th.SetDisasterArea(di.LON - radius, di.LAT - radius, di.LON + radius, di.LAT + radius);
                th.GenerateTask(GridWidth, GridHeight);

                InitGrid = th.InitGrids;
                DataGrid = th.DataGrids;
                IEnvelope env = new Envelope() as IEnvelope;
                //foreach (MonitorTask.Geometry.Grid grid in InitGrid)
                //{
                //    env = new Envelope() as IEnvelope;
                //    env.XMin = grid.XMin;
                //    env.YMin = grid.YMin;
                //    env.XMax = grid.XMax;
                //    env.YMax = grid.YMax;
                //    maphelper.AddElement(env, symbol, "grid");
                //}
                //color = Color.Brown;
                //symbol = maphelper.CreateSimpleFillSymbol(color, 1, esriSimpleFillStyle.esriSFSDiagonalCross);
                //foreach (MonitorTask.Geometry.Grid grid in DataGrid)
                //{
                //    env = new Envelope() as IEnvelope;
                //    env.XMin = grid.XMin;
                //    env.YMin = grid.YMin;
                //    env.XMax = grid.XMax;
                //    env.YMax = grid.YMax;
                //    maphelper.AddElement(env, symbol, "grid");
                //}
            }
            catch (Exception ex) { throw (ex); }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取交点
        /// </summary>
        /// <param name="pMapCtr"></param>
        /// <param name="id"></param>
        public static void getIntersect(ESRI.ArcGIS.Controls.AxMapControl pMapCtr, int id)
        {
            Core.Map.MapHelper map = new Core.Map.MapHelper(pMapCtr);
            Core.Generic.myXML xml = new Core.Generic.myXML(System.Windows.Forms.Application.StartupPath + "\\Setting.xml");
            try
            {
                IFeatureClass           pFeatureClass = null;
                Core.Model.DisaAreaInfo model         = new Core.Model.DisaAreaInfo();
                Core.DAL.DisaAreaInfo   dal0          = new Core.DAL.DisaAreaInfo();


                Core.Model.DisaCrossPoint gatherPoint = new Core.Model.DisaCrossPoint();
                Core.DAL.DisaCrossPoint   dal         = new Core.DAL.DisaCrossPoint();
                //删除以前生成的交点
                dal.Deletes(id);

                map.getNetWorkData(ref pFeatureClass);

                //pIntersectPoint = new List<IPoint>();
                string   Roadtype    = xml.GetElement("FilterPara", "RoadType");
                string[] typeArray   = Roadtype.Split(',');
                string   whereclause = "";
                if (Roadtype != null)
                {
                    for (int i = 0; i < typeArray.Length; i++)
                    {
                        if (i != (typeArray.Length - 1))
                        {
                            whereclause += "Type=" + typeArray[i] + " or ";
                        }
                        else
                        {
                            whereclause += "Type=" + typeArray[i];
                        }
                    }
                }

                //生成灾区影响范围Geometry
                model = dal0.GetModel(id);
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(model.LON, model.LAT);

                ITopologicalOperator pTopoOp   = default(ITopologicalOperator);
                IGeometry            geoBuffer = null;
                pTopoOp   = pPoint as ITopologicalOperator;
                geoBuffer = pTopoOp.Buffer(model.AffectedRadius / Core.Generic.SysEnviriment.LengthPerRad);

                ISpatialFilter pSpatialfilter = new SpatialFilterClass();
                pSpatialfilter.Geometry      = geoBuffer;
                pSpatialfilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelCrosses;
                pSpatialfilter.WhereClause   = whereclause;
                pSpatialfilter.GeometryField = "Shape";

                IFeatureCursor FeatureCursor = pFeatureClass.Search(pSpatialfilter, false);
                IFeature       pFeature      = FeatureCursor.NextFeature();

                int count = 1;
                while (pFeature != null)
                {
                    IPolyline pPolyline = pFeature.ShapeCopy as IPolyline;

                    ITopologicalOperator pTopologicalOperator = pPolyline as ITopologicalOperator;
                    IGeometry            pGeometry1           =
                        pTopologicalOperator.Intersect(geoBuffer as IPolygon, esriGeometryDimension.esriGeometry0Dimension) as
                        IGeometry;

                    if (!pGeometry1.IsEmpty)
                    {
                        IPointCollection Pc     = pGeometry1 as IPointCollection;
                        ISymbol          symbol = map.CreateSimpleSymbol(Color.Red, 8, ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle);
                        for (int i = 0; i < Pc.PointCount; i++)
                        {
                            //将交点显示在地图上
                            IPoint point = Pc.get_Point(i);

                            map.AddElement(Pc.get_Point(i), symbol, "Intersect|" + id);

                            //将交点存储到数据库中
                            gatherPoint.LON   = point.X;
                            gatherPoint.LAT   = point.Y;
                            gatherPoint.PID   = id;
                            gatherPoint.PName = "交点(" + count++ + ")";
                            dal.Add(gatherPoint);
                            //pIntersectPoint.Add(Pc.get_Point(i));
                        }
                    }
                    pFeature = FeatureCursor.NextFeature();
                }
                pMapCtr.ActiveView.Refresh();
            }
            catch (Exception ex) { throw ex; }
            finally
            {
                TaskAreas = null;
            }
        }