【问题标题】:ArcGis Engine, how to highlight some features/shapes?ArcGis 引擎,如何突出显示某些特征/形状?
【发布时间】:2011-07-20 09:59:13
【问题描述】:

在使用 ArcGis 引擎的独立 c#/wpf 应用程序中,我加载了一些形状,selected some features。

现在我想突出显示选定的功能之一。我可以在 IFeatureSelection/Layer 上找到对象/特征,我从 IFeature.Shape 获得了 IGeometry。

有没有一种简单的方法来标记已知的特征/形状,比如用红色或类似的东西?

我有这样的功能:

AxMapControl _mapControl;
IFeatureSelection features = _mapControl.Map.Layer[0] as IFeatureSelection;
ICursor cursor;
features.SelectionSet.Search(null, true, out cursor);
IFeature feature;
while ((feature = ((IFeatureCursor)cursor).NextFeature()) != null)
{
  IGeometry geometry = feature.Shape;
}

我搜索了样本,但找不到我需要的。

【问题讨论】:

标签: .net arcgis


【解决方案1】:
static public void FlashFeature(IFeature feature)
        {
            if (feature == null)
                return;
            IApplication app = ApplicationRef;
            IMxDocument doc = (IMxDocument)(app.Document);

            IFeatureIdentifyObj feature_identify_obj = new FeatureIdentifyObjectClass();
            feature_identify_obj.Feature = feature;
            ((IIdentifyObj)feature_identify_obj).Flash(doc.ActiveView.ScreenDisplay);
        }

ApplicationRef 所在的位置:

static public IApplication ApplicationRef
        {
            get
            {
                Type obj_type = Type.GetTypeFromCLSID(typeof(AppRefClass).GUID);

                IApplication obj = null;
                try
                {
                    obj = (IApplication)Activator.CreateInstance(obj_type);
                }
                catch {}

                return obj;
            }
        }

或者您可以通过在 IGraphicsContainer 中创建图形 IElement 元素来实现,例如:

        void ShowFeature(IFeature feature)
        {
            element.Geometry = geometry.Project(mapSpatialReference, feature.Shape);

            graphicsContainer.AddElement(element, 0);

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            featureHighlighted = true;
        }

        void HideFeature()
        {
            if (!featureHighlighted)
                return;

            graphicsContainer.DeleteElement(element);

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            featureHighlighted = false;
        }

【讨论】:

  • 第一个解决方案不起作用,为 ApplicationRef 调用 Activator.CreateInstance 时出现 COM 异常:80040154 未注册类(HRESULT:0x80040154 (REGDB_E_CLASSNOTREG))。
猜你喜欢
  • 2020-06-08
  • 1970-01-01
  • 2023-03-10
  • 2021-03-10
  • 1970-01-01
  • 2012-06-23
  • 1970-01-01
  • 2013-08-12
  • 1970-01-01
相关资源
最近更新 更多