C#之ArcGIS二次开发

C#之ArcGIS二次开发根据图层名称获取图层publicIFeatureLayergetLayer(AxMapControlaxMapControl,stringlayerName){if(axMapControl.LayerCount>0){for(inti=0;i

大家好,又见面了,我是你们的朋友全栈君。

根据图层名称获取图层

public IFeatureLayer getLayer(AxMapControl axMapControl, string layerName)
{
    if (axMapControl.LayerCount > 0)
    {
        for (int i = 0; i < axMapControl.LayerCount; i++)
        {
            ILayer pLayer = axMapControl.get_Layer(i);
            if (pLayer.Name == layerName)
                return pLayer as FeatureLayer;
        }
    }
    return null;
}

按条件查询图层要素,并闪烁

public void searchFeatures(AxMapControl mapControl,string sqlfilter,IFeatureLayer pFeatureLayer)
{
    IFeatureLayer pFeatLyr = pFeatureLayer;
    IQueryFilter pFilter = new QueryFilterClass();
    pFilter.WhereClause = sqlfilter;
    IFeatureCursor pFeatCursor = pFeatLyr.Search(pFilter,true);
    IFeature pFeat = pFeatCursor.NextFeature();
    while (pFeat != null)
    {
        if (pFeat != null)
        {
            ISimpleFillSymbol pFillsyl = new SimpleFillSymbolClass();
            RgbColor pRgbColor=new RgbColor();
            pRgbColor.Red=255;
            pRgbColor.Green=0;
            pRgbColor.Blue=0;
            pFillsyl.Color = pRgbColor;
            object oFillsyl = pFillsyl;
            IPolygon pPolygon = pFeat.Shape as IPolygon;
            mapControl.FlashShape(pPolygon, 15, 20, pFillsyl);
            mapControl.DrawShape(pPolygon, ref oFillsyl);
        }
        pFeat = pFeatCursor.NextFeature();
    }
}

sqlfilter为查询条件,如查询layer图层中,属性字段ID<10的要素:searchFeatures(axMapControl1, “ID < 10”, layer);

建立缓冲区,并添加到图层

public void SetBuffer(AxMapControl m_map, string LayerName, double bufferDistance,string OutputPath)
{
    try
    {
        IFeatureLayer layer = getLayer(m_map,LayerName);
        if (layer == null)
        {
            LogHelper.Debug("图层不存在");  #这里是自己写的日志记录方法
            return;
        }
        Geoprocessor gp = new Geoprocessor();
        gp.OverwriteOutput = true;
     
        ESRI.ArcGIS.AnalysisTools.Buffer buffer = new ESRI.ArcGIS.AnalysisTools.Buffer(layer, OutputPath, bufferDistance.ToString() + " Meters");
        IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(buffer, null);
        if (results.Status != esriJobStatus.esriJobSucceeded)
        {
            LogHelper.Debug("为图层" + layer.Name + "建立缓冲区失败\r\n");
        }

        int k = OutputPath.LastIndexOf('\\');
        string pOutFeatclsName = OutputPath.Substring((k + 1)).Trim();
        string strFolder = OutputPath.Substring(0, k);
        m_map.AddShapeFile(strFolder, pOutFeatclsName);   #添加到图层
    }
    catch (Exception ex)
    {
        LogHelper.Error(ex.Message);
    }
}


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/148699.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 深度学习 CNN卷积神经网络 LeNet-5详解

    深度学习 CNN卷积神经网络 LeNet-5详解卷积神经网络(ConvolutionalNeuralNetwork,CNN):是一种常见的深度学习架构,受生物自然视觉认知机制(动物视觉皮层细胞负责检测光学信号)启发而来,是一种特殊的多层前馈神经网络。它的人工神经元可以响应一部分覆盖范围内的周围单元,对于大型图像处理有出色表现。一般神经网络VS卷积神经网络:相同点:卷积神经网络也使用

  • 细说SDRAM控制器

    细说SDRAM控制器SDRAM的基本概念SDRAM凭借其极高的性价比,广泛应用于高速数据存储、实时图像处理等设计当中,但是相对于SRAM、FIFO等其他存储器件,SDRAM的控制相对复杂。虽说是复杂,但也不代表没办法实现,仔细梳理一下,发现SDRAM的控制其实也没这么难。本文就SDRAM的基本概念以及其工作流程做简要介绍。SDRAM的基本信号:SDRAM的基本信号(电源以及地线在这里不讨论)可以…

  • bitnami redmine mysql_Bitnami Redmine相关配置

    bitnami redmine mysql_Bitnami Redmine相关配置下载安装文件bitnami-redmine-3.3.1-0-linux-x64-installer.run官方下载链接:https://bitnami.com/stack/redmine/installer百度网盘链接:http://pan.baidu.com/s/1eRZsfmU密码:iorm一、给文件赋可执行权限。chmod777bitnami-redmine-3.3.1-0-linux…

  • java基本数据类型有哪些_java中有八种基本数据类型

    java基本数据类型有哪些_java中有八种基本数据类型在java中有八种基本数据类型对应每种基本类型又有八种包装类型:基本类型:boolean,char,int,byte,short,long,float,double包装器类型:Boolean,Character,Integer,Byte,Short,Long,Float,Double从上面我们可以看到除了char和int其它的包装类型名称和对应的基本类型一样只是首字母大写了。既然有了基本…

  • 极电竞比分网(js逆向,webpack)「建议收藏」

    目标网站:https://www.jdj007.com/目标参数:sign全局搜索sign在第一个js文件里找到可疑加密位置通过观察sign参数可以猜到加密的最后一步可能用到了url编码,而这里可以看到encodeURIComponent,因此断定这里是加密位置。s.a.stringify(n)是加密的关键,因此首先我们要找的就是n,可以看到n=i()(t),通过断点我们可以看到t=“timestamp=1604631529347&secret=aHVheWluZ19zZWNy

  • Xshell出现要继续使用此程序必须应用到最新的更新或使用新版本

    Xshell出现要继续使用此程序必须应用到最新的更新或使用新版本

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号