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);
    }
}


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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Windows驱动程序开发语言「建议收藏」

    Windows驱动程序开发语言「建议收藏」Windows驱动程序和Win32应用程序一样,都是PE格式,所以说,只要某种语言的编译器能够编译出PE格式的二进制格式文件,并且能够设置驱动程序的入口地址,那么这种语言就可以用来开发Windows驱动程序,所以可以选择C,C++,甚至是Delphi开发。但是由于微软提供的DDK开发环境中的头文件和链接库都是只支持C,C++。因此,大部分时候Windows驱动程序都是用C/C++进行开发的

    2022年10月9日
    2
  • windows server 禁用智能卡服务的步骤

    windows server 禁用智能卡服务的步骤许多用户对于系统中的很多功能都不太了解,其中智能卡服务更是少有人知。智能卡服务就是对插入的智能卡进行管理和访问控制,大多数用户都无需使用此项功能。那么在Win7系统中要怎么取消智能卡服务呢?1.首先

    2022年7月1日
    32
  • MD编辑器设置字体、颜色、大小

    MD编辑器设置字体、颜色、大小颜色:浅红色文字:浅红色文字:深红色文字:深红色文字浅绿色文字:浅绿色文字深绿色文字:深绿色文字浅蓝色文字:浅蓝色文字深蓝色文字:深蓝色文字浅黄色文字:浅黄色文字深黄色文字:深黄色文字浅青色文字:浅青色文字深青色文字:深青色文字浅紫色文字:浅紫色文字深紫色文字:深紫色文字大小:size为1:size为1size为2:size为2size为3:size为3size为4:size为4size为10:size为10字体:我是黑体字我是宋体字我是微软雅黑字我是fanta

    2022年9月15日
    2
  • linux查看网卡实时速率命令_怎么判断网卡速率是否异常

    linux查看网卡实时速率命令_怎么判断网卡速率是否异常Linux下查看网卡速率信息:1、使用ethtool命令ethtoolethx#查看支持的速率ethx为网卡名,使用ifconfig-a,ipa查询。响应数据中:Linkdetected为yes表示网卡已经连接。2、使用mii-tool命令mii-tooleth0#查看eth0网卡信息,这个命令需要root权限,没有上边的好用。3、查看网卡驱动:…

    2022年10月19日
    2
  • 解决H5页面在微信浏览器中打开 input file 在安卓上没有拍照选项

    解决H5页面在微信浏览器中打开 input file 在安卓上没有拍照选项有时候我们会在微信公众号里开发会遇到上传图片的功能,当你写&lt;inputtype="file"&gt;的时候,在IOS上可以成功调起拍照和图库两块,在安卓手机上只能调取图库而没有拍照功能,解决办法:给input加上accept属性&lt;inputtype="file"accept="image/*"/&gt; //调用相机,图片或者相册(两者都行)加上了capture=…

    2022年7月17日
    23

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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