zoukankan      html  css  js  c++  java
  • ArcGIS中对一组查询结果同时闪烁的实现

     

    单个要素闪烁很简单,关于多要素同时闪烁主要参考这两篇资源
    Arcgis 要素闪烁
    http://blog.csdn.net/chyocean/archive/2008/04/28/2337418.aspx
    /// <summary>
            /// Defining a renderer for your layer
            /// </summary>
            /// <param name="pGeoFeatureLayer">图层</param>
            /// <param name="fieldName">sde数据库中字段名</param>
            /// <param name="pQueryFilter">过滤条件</param>
            private void DefineUniqueValueRenderer(IGeoFeatureLayer pGeoFeatureLayer, string fieldName, IQueryFilter pQueryFilter)
            {
                // IRandomColorRamp 对象
                IRandomColorRamp pRandomColorRamp = new RandomColorRampClass();
                //Make the color ramp for the symbols in the renderer.
                pRandomColorRamp.MinSaturation = 20;
                pRandomColorRamp.MaxSaturation = 40;
                pRandomColorRamp.MinValue = 85;
                pRandomColorRamp.MaxValue = 100;
                pRandomColorRamp.StartHue = 76;
                pRandomColorRamp.EndHue = 188;
                pRandomColorRamp.UseSeed = true;
                pRandomColorRamp.Seed = 43;
    
                //Make the renderer.
                IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass();
    
                //填充样式
                ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                pSimpleFillSymbol.Outline.Width = 0.4;
    
                //These properties should be set prior to adding values.
                pUniqueValueRenderer.FieldCount = 1;
                pUniqueValueRenderer.set_Field(0, fieldName);
                pUniqueValueRenderer.DefaultSymbol = pSimpleFillSymbol as ISymbol;
                pUniqueValueRenderer.UseDefaultSymbol = true;
    
                //显示表
                IDisplayTable pDisplayTable = pGeoFeatureLayer as IDisplayTable;
                //IFeatureCursor 对象
                IFeatureCursor pFeatureCursor = pDisplayTable.SearchDisplayTable(pQueryFilter, false) as IFeatureCursor;
                //IFeature对象
                IFeature pFeature = pFeatureCursor.NextFeature();
    
                //bool对象,pUniqueValueRenderer中是否找到字段值
                bool ValFound;
                //字段索引号
                int fieldIndex;
                //IFields对象
                IFields pFields = pFeatureCursor.Fields;
                fieldIndex = pFields.FindField(fieldName);
                while (pFeature != null)//要素存在
                {
                    //填充样式
                    ISimpleFillSymbol pClassSymbol = new SimpleFillSymbolClass();
                    pClassSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                    pClassSymbol.Outline.Width = 0.4;
    
                    //字段值
                    string classValue;
                    classValue = pFeature.get_Value(fieldIndex) as string;
    
                    //Test to see if this value was added
                    //to the renderer. If not, add it.
                    ValFound = false;
                    for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++)
                    {
                        if (pUniqueValueRenderer.get_Value(i) == classValue)
                        {
                            ValFound = true;
                            break; //Exit the loop if the value was found.
                        }
                    }
                    //If the value was not found, it is new and it will be added.
                    if (ValFound == false)
                    {
                        pUniqueValueRenderer.AddValue(classValue, fieldName, pClassSymbol as ISymbol);
                        pUniqueValueRenderer.set_Label(classValue, classValue);
                        pUniqueValueRenderer.set_Symbol(classValue, pClassSymbol as ISymbol);
                    }
                    pFeature = pFeatureCursor.NextFeature();
                }
                //Since the number of unique values is known,
                //the color ramp can be sized and the colors assigned.
                pRandomColorRamp.Size = pUniqueValueRenderer.ValueCount;
                //ok
                bool bOK;
                pRandomColorRamp.CreateRamp(out bOK);
                //IEnumColors 对象, 颜色集合
                IEnumColors pEnumColors = pRandomColorRamp.Colors;
                pEnumColors.Reset();
                for (int j = 0; j <= pUniqueValueRenderer.ValueCount - 1; j++)
                {
                    //value值
                    string xv;
                    xv = pUniqueValueRenderer.get_Value(j);
                    if (xv != "")
                    {
                        //填充样式
                        ISimpleFillSymbol pSimpleFillColor = pUniqueValueRenderer.get_Symbol(xv) as ISimpleFillSymbol;
                        pSimpleFillColor.Color = pEnumColors.Next();
                        pUniqueValueRenderer.set_Symbol(xv, pSimpleFillColor as ISymbol);
    
                    }
                }
    
                //'** If you didn't use a predefined color ramp
                //'** in a style, use "Custom" here. Otherwise,
                //'** use the name of the color ramp you selected.
                pUniqueValueRenderer.ColorScheme = "Custom";
                //ITable对象
                ITable pTable = pDisplayTable as ITable;
                //是否string
                bool isString = pTable.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString;
                pUniqueValueRenderer.set_FieldType(0, isString);
                pGeoFeatureLayer.Renderer = pUniqueValueRenderer as IFeatureRenderer;
    
            }
    关于查询后feature闪烁的问题
    http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=57376

    [新提问] 关于查询后feature闪烁的问题

    在实现属性到图的查询后,将查询结果闪烁显示,polygon内部并填充,下面贴出代码:
    while (pFeature != null)
                {
                    pMap.SelectFeature(pFeatureLayer, pFeature);
                    pFeature = pFeatureCursor.NextFeature();
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    pActiveView.ScreenDisplay.UpdateWindow();
                    if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IGeometryCollection pGeometryCollection;
                        pGeometry = pFeature.Shape;
                        pGeometryCollection = new PolylineClass();
                        object Missing1 = Type.Missing;
                        object Missing2 = Type.Missing;
    pGeometryCollection.AddGeometry(pGeometry, ref Missing1, ref Missing2);
                        pCartographicLineSymbol = new CartographicLineSymbol();
                        pSymbol = (ISymbol)pCartographicLineSymbol;
                        pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                        pCartographicLineSymbol.Width = Size;
                        pCartographicLineSymbol.Color = pColor;
                        pMapControl.FlashShape((IGeometry)pGeometryCollection, 2, 150, pSymbol);
                    }
                    else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        pGeometry = pFeature.Shape;
                        IGeometryCollection pGeometryCollection;
                        pGeometryCollection = new PolygonClass();
                        object Missing1 = Type.Missing;
                        object Missing2 = Type.Missing;
    pGeometryCollection.AddGeometry(pGeometry, ref Missing1, ref Missing2);
                        pSimpleFillSymbol = new SimpleFillSymbol();
                        pSymbol = (ISymbol)pSimpleFillSymbol;
                        pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                        pSimpleFillSymbol.Color = pColor;
                        pMapControl.FlashShape((IGeometry)pGeometryCollection, 2, 150, pSymbol);
                    }
                    else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint || pFeature.Shape.GeometryType == esriGeometryType.esriGeometryMultipoint)
                    {
                        pGeometry = pFeature.Shape;
                        IGeometryCollection pGeometryCollection;
                        pGeometryCollection = new MultipointClass();
                        pSimpleMarkersymbol = new SimpleMarkerSymbol();
                        object Missing1 = Type.Missing;
                        object Missing2 = Type.Missing;
    pGeometryCollection.AddGeometry(pGeometry, ref Missing1, ref Missing2);
                        pSymbol = (ISymbol)pSimpleMarkersymbol;
                        pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                        pSimpleMarkersymbol.Color = pColor;
                        pSimpleMarkersymbol.Size = 8;
                        pMapControl.FlashShape((IGeometry)pGeometryCollection, 2, 150, pSymbol);
                    }
    红色代码处出现问题,提示说参数类型错误,各位高手和大侠们帮忙看看应该如何修改?  谢谢!!!!!!

    3# JinDin 不是说对于多要素的闪烁要用到IGeometryCollection的么?

    5#把要素存到IArray里.然后用IHookActions.DoActionOnMultiple 方法试试.

    6#同意LS方法,将波涛的书里也是用该方法,可以闪烁多个要素

    7#这个功能终于搞定了,线和面我的是 pGeometryCollection.AddGeometryCollection((IGeometryCollection)pGeometry);点用的是pGeometryCollection.AddGeometry(pGeometry, ref obj, ref obj),不知道为什么点线面不能用同样的方法添加要素?还有一个问题就是关于一直闪烁,FlashShape()中第二个闪烁次数的参数,似乎不敢设置太大,否则就会一直执行到闪烁完才可以执行后面的代码,是不是用Timer可以解决这个问题呢?试试先

    ESRI中国社区 ( 京ICP备05021261号)|联系我们 |Archiver|

    GMT+8, 2010-1-4 22:04.

    Powered by Discuz! 7.0.0 Licensed

    © 2001-2009 Comsenz Inc.

  • 相关阅读:
    Java Output流写入包装问题
    SpringBoot项目单元测试不经过过滤器问题
    SpringSecurity集成启动报 In the composition of all global method configuration, no annotation support was actually activated 异常
    JWT jti和kid属性的说明
    Maven 排除依赖
    第五章 基因概念的发现
    第三章 孟德尔遗传的拓展
    第二章 孟德尔遗传
    第一章 引言
    GWAS全基因组关联分析
  • 原文地址:https://www.cnblogs.com/flyingfish/p/1639222.html
Copyright © 2011-2022 走看看