Arcgis 要素闪烁

12 篇文章 1 订阅

要素闪烁,首先是要找到要素,然后调用IMapControl. FlashShape方法实现闪烁。

查找要素时,要用到IQueryFilter 接口,定义查询条件。然后调用IDisplayTable.SearchDisplayTable方法查询到

IFeatureCursor 要素游标对象,现在就可以调用IFeatureCursor .NextFeature()方法得到要素。

当有多个要素时,可以调用ITopologicalOperator.Union实现组合要素。

  /// <summary>
        /// 闪烁指定的巡查单元
        /// </summary>
        /// <param name="arrayList">巡查单元ID数组</param>
        private void FlashCell(ArrayList arrayList)
        {
            if ((arrayList == null) || (arrayList.Count == 0)) return;

            if (activeView == null)
            {
                activeView = this.MapControl.ActiveView.FocusMap as IActiveView;
            }

            //定义图层
            IFeatureLayer pFeatureLayer = new FeatureLayerClass();

            //网格图层不能为空
            if (m_BgFeatureLayer == null) return;

            pFeatureLayer = m_BgFeatureLayer;

            //IGeoFeatureLayer对象
            IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)pFeatureLayer;

            //IQueryFilter对象,过滤条件。
            IQueryFilter pQueryFilter;

            //IDisplayTable对象,显示表
            IDisplayTable pDisplayTable = pGeoFeatureLayer as IDisplayTable;
            pQueryFilter = new QueryFilterClass();
           
            //where条件语句
            StringBuilder strFilter = new StringBuilder();

            for (int i = 0; i < arrayList.Count; i++)
            {
                //巡查单元ID
                string cellId = arrayList[i].ToString();
                strFilter.Append(UiConst.BGCODE +" = '"+cellId +"' ");
                if (i < arrayList.Count-1)
                {
                    strFilter.Append(" OR ");
                }
            }
            pQueryFilter.WhereClause = strFilter.ToString();
            //IFeatureCursor对象
            IFeatureCursor pFeatureCursor = pDisplayTable.SearchDisplayTable(pQueryFilter, false) as IFeatureCursor;

            //IFeature对象,要素对象。
            IFeature  pFeature = pFeatureCursor.NextFeature();
            //IGeometry对象,图形对象
            IGeometry pGeo =  new PolygonClass();

            //IFields对象,字段对象
            IFields pFields = pFeatureCursor.Fields;
            //字段索引
            int fieldIndex = pFields.FindField(UiConst.BGCODE);

            //填充样式
            ISimpleFillSymbol pFillsy;
            pFillsy = new SimpleFillSymbolClass();
            //pFillsy.Color = GetRgbColor(125, 60, 60);
            pFillsy.Style = esriSimpleFillStyle.esriSFSCross;

            //ITopologicalOperator对象
            ITopologicalOperator topologicalOperator = new PolygonClass();
            //中心点
            IPoint pPoint = new PointClass();
            if (pFeature != null)
            {
                topologicalOperator = pFeature.Shape as ITopologicalOperator;
                if (!topologicalOperator.IsSimple)
                {
                    topologicalOperator.Simplify();
                }
            }
            pFeature = pFeatureCursor.NextFeature();
            while (pFeature != null)
            {
                //组合所有的要素
                pGeo = (IGeometry)topologicalOperator.Union(pFeature.Shape as IGeometry);
                topologicalOperator = pGeo as ITopologicalOperator;
                pFeature = pFeatureCursor.NextFeature();
            }
            if (pGeo != null)
            {
                //放大地图
                //多边形
                IPolygon pPolygon = pGeo as IPolygon;
                //IArea,区域
                IArea pArea = pPolygon as IArea;
                //点
                pPoint = pArea.Centroid;
                if (pPoint != null)
                {
                    this.ChangeEnvelope(pPoint, 0.06, 0.06);
                    Application.DoEvents();
                }

                MapControl.FlashShape(pGeo, 15, 300, pFillsy);
                //样式
                object symbol = pFillsy;
                MapControl.DrawShape(pGeo, ref symbol);
                Application.DoEvents();
            }

        }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值