zoukankan      html  css  js  c++  java
  • ArcGIS AddIN Sample学习笔记

    1.AddInEditorExtension

    功能描述:编辑器扩展,实现在编辑要素,对编辑事件的监听,及对新创建的要素的处理

    核心代码:

    void Events_OnStartEditing()
            {
                //Since features of shapefiles, coverages etc cannot be validated, ignore wiring events for them
                if (ArcMap.Editor.EditWorkspace.Type != esriWorkspaceType.esriFileSystemWorkspace)
                {
                    //wire OnCreateFeature Edit event
                    Events.OnCreateFeature += new IEditEvents_OnCreateFeatureEventHandler(Events_OnCreateChangeFeature);
                    //wire onChangeFeature Edit Event
                    Events.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(Events_OnCreateChangeFeature);
                }
            }
            //Invoked at the end of Editor session (Editor->Stop Editing)
            void Events_OnStopEditing(bool Save)
            {
                //Since features of shapefiles, coverages etc cannot be validated, ignore wiring events for them
                if (ArcMap.Editor.EditWorkspace.Type != esriWorkspaceType.esriFileSystemWorkspace)
                {
                    //unwire OnCreateFeature Edit event
                    Events.OnCreateFeature -= new IEditEvents_OnCreateFeatureEventHandler(Events_OnCreateChangeFeature);
                    //unwire onChangeFeature Edit Event
                    Events.OnChangeFeature -= new IEditEvents_OnChangeFeatureEventHandler(Events_OnCreateChangeFeature);
                }
            }
    
            void Events_OnCreateChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
            {
                IFeature inFeature = (IFeature)obj;
                if (inFeature.Class is IValidation)
                {
                    IValidate validate = (IValidate)inFeature;
                    string errorMessage;
                    //Validates connectivity rules, relationship rules, topology rules etc
                    bool bIsvalid = validate.Validate(out errorMessage);
                    if (!bIsvalid)
                    {
                        System.Windows.Forms.MessageBox.Show("Invalid Feature
    
    " + errorMessage);
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Valid Feature");
                    }
                }       
            }

    注:具体工具的ProgId在这里查询 https://www.cnblogs.com/gisoracle/p/5971974.html 

    2.AddInExtensionPersist

    功能描述:ArcMap扩展,实现对ArcMap事件的监听

    比如启动,加载,保存等事件

    3.AddInReportManager

    功能说明:ESRI自带的一种报表导出方案

    主要接口IReportDataSource,IReportTemplate

    需要提前做好.rlf文件

    4.AddInTimeSeriesGraph

    功能描述:折线图 Tool

    示例数据路径:C:Program Files (x86)ArcGISDeveloperKit10.1SamplesdataStreamflowDateTime

    相关接口

    IIdentify :Provides access to members that identify features,相关矢量图层

    IDisplayTable :Provides access to members that work with the display table associated with a standalone table. 该接口包含Joined 字段

    IFeatureLayerDefinition:

    ILookupSymbol .LookupSymbol ():Returns a reference to the renderer's symbol for the input feature.查询某个要素的Symbol

    IDataGraphWindow2 :Provides access to members that control the DataGraph Window. ESRI自带的专题图窗口,可以使用下述代码调用显示

    pDGWin = new DataGraphWindowClass();
    pDGWin.DataGraphBase = pDataGraphBase;
    pDGWin.Application = ArcMap.Application;
    pDGWin.Show(true);
    
    pDataGraphs.AddDataGraph(pDataGraphBase);

    设置Title,坐标轴显示内容等

    pDataGraphT = new DataGraphTClass();
                    pDataGraphBase = (IDataGraphBase)pDataGraphT;
    
                    // load template from <ARCGISHOME>GraphTemplates
                    string strPath = null;
                    strPath = Environment.GetEnvironmentVariable("ARCGISHOME");
                    try
                    {
                        pDataGraphT.LoadTemplate(strPath + @"GraphTemplates	imeseries.tee");
                    }
                    catch
                    { }
    
                    // graph, axis and legend titles. Substitute them for different input layer
                    pDataGraphT.GeneralProperties.Title = "Daily Streamflow for Guadalupe Basin in 1999";
                    pDataGraphT.LegendProperties.Title = "Monitoring Point";
                    pDataGraphT.get_AxisProperties(0).Title = "Streamflow (cfs)";
                    pDataGraphT.get_AxisProperties(0).Logarithmic = true;
                    pDataGraphT.get_AxisProperties(2).Title = "Date";
                    pDataGraphBase.Name = layerName;

    设置绘图内容:

    ISeriesProperties pSP = null;
                pSP = pDataGraphT.AddSeries("line:vertical");
                pSP.ColorType = esriGraphColorType.esriGraphColorCustomAll;
                pSP.CustomColor = pSymbol.Color.RGB;
                pSP.WhereClause = whereClause;
                pSP.InLegend = true;
                pSP.Name = gageID;
    
                pSP.SourceData = pLayer;
                pSP.SetField(0, timefldName);
                pSP.SetField(1, dataFldName);
                IDataSortSeriesProperties pSortFlds = null;
                pSortFlds = (IDataSortSeriesProperties)pSP;
                int idx = 0;
                pSortFlds.AddSortingField(timefldName, true, ref idx);
    
    
                pDataGraphBase.UseSelectedSet = true;
    
                ITrackCancel pCancelTracker = null;
                pCancelTracker = new CancelTracker();
                pDataGraphT.Update(pCancelTracker);

    其他代码片段:

    以下代码实现在检索时,先检测定义查询的Sql语句,如果有内容,则与新的查询语句And,没有,则直接使用新的查询语句

    IFeatureLayerDefinition pFeatureLayerDef = null;
                pFeatureLayerDef = (IFeatureLayerDefinition)pLayer;
                string definitionExpression = null;
                definitionExpression = pFeatureLayerDef.DefinitionExpression;
    
                string whereClause = null;
                if (definitionExpression == "")
                    whereClause = "[" + gageIDFldName + "] = '" + gageID + "'";
                else
                    whereClause = "[" + gageIDFldName + "] = '" + gageID + "' AND " + definitionExpression;

     5.AlgorithmicColorRamp

    功能说明:

    接口:

    IContentsView: Provides access to members that control table of contents views,

    Used to manage a contents view. The tabs in ArcMap's Table of Contents (TOC) are examples of a contents view.

    示例用法:判断TOC中选中的内容

    IContentsView ContentsView = null;
          ContentsView = ArcMap.Document.CurrentContentsView;
    if (ContentsView is TOCDisplayView)
          {
            if (ContentsView.SelectedItem is DBNull)
            {
              //
              // If we don't have anything selected.
              //
              MessageBox.Show("SelectedItem is Null C#." + "Select a layer in the Table of Contents.", "No Layer Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
              return;
            }
            //
            // Get the selected Item.
            //
            VarSelectedItem = ContentsView.SelectedItem;
            //
            // Selected Item should implement the IGeoFeatureLayer interface - therefore we
            // have selected a feature layer with a Renderer property (Note: Other interfaces
            // also have a Renderer property, which may behave differently.
            //
            if (VarSelectedItem is IGeoFeatureLayer)
            {
           //....
          }

     6.AngleAngleConstructor

    接口

    IEditSketch3:Provides access to members that access and manipulate the edit sketch. 

    2.Brushing

  • 相关阅读:
    REDIS缓存穿透,缓存击穿,缓存雪崩
    spring 自动装配
    SpringBoot @Condition
    【Azure 环境】在Azure虚拟机(经典) 的资源中,使用SDK导出VM列表的办法
    【Azure Developer】使用Microsoft Graph API 批量创建用户,先后遇见的三个错误及解决办法
    【Azure 环境】基于Azure搭建企业级内部站点, 配置私有域名访问的详细教程 (含演示动画)
    【Azure Function】Function App和Powershell 集成问题, 如何安装PowerShell的依赖模块
    【Azure 应用服务】Python3.7项目在引用pandas 模块后,部署报错 
    【Azure 应用服务】部署Azure Web App时,是否可以替换hostingstart.html文件呢?
    【Azure 应用服务】添加自定义域时,Domain ownership 验证无法通过 
  • 原文地址:https://www.cnblogs.com/DayDreamEveryWhere/p/7994712.html
Copyright © 2011-2022 走看看