zoukankan      html  css  js  c++  java
  • 镶嵌数据集添加过滤

    public static List<ILayer> LoadGdbRasterLayer(string dataYear, List<string> regionCodes)
    {
    string gdbPath = AppConfig.MapMineThemePicPath;
    if (!Directory.Exists(gdbPath)) return null;
    List<ILayer> allLayer = new List<ILayer>();
    try
    {
    IWorkspaceFactory gdbWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
    IWorkspace pWorkspace = gdbWorkspaceFactory.OpenFromFile(gdbPath, 0);
    IEnumDataset pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTAny);
    pEnumDataset.Reset();
    IDataset pDataset = pEnumDataset.Next();
    while (pDataset != null)
    {
    if (pDataset is IRasterDataset) //栅格数据集
    {

    if (!(pDataset.Name.Contains(dataYear.Trim())))
    {
    pDataset = pEnumDataset.Next();
    continue;
    }
    IRasterWorkspaceEx pRasterWorkspace = (IRasterWorkspaceEx)pWorkspace;
    IRasterDataset pRasterDataset = pRasterWorkspace.OpenRasterDataset(pDataset.Name);
    //影像金字塔判断与创建
    IRasterPyramid3 pRasPyrmid;
    pRasPyrmid = pRasterDataset as IRasterPyramid3;
    if (pRasPyrmid != null)
    {
    if (!pRasPyrmid.Present)
    {
    pRasPyrmid.Create(); //创建金字塔
    }
    }

    ILayer mosaicLayer = RasterFilter(pWorkspace, pDataset.Name) as ILayer;
    allLayer.Add(mosaicLayer);
    }
    pDataset = pEnumDataset.Next();
    }
    return allLayer;
    }
    catch (Exception e)
    {
    Console.WriteLine(e);
    return null;
    }
    }

    /// <summary>
    /// 过滤图层显示内容
    /// </summary>
    private static IMosaicLayer RasterFilter(IWorkspace fgdbWorkspace, string CurrentMosaicDsName)
    {

    IMosaicDataset mosaicDataset = GetMosaicDataset(fgdbWorkspace, CurrentMosaicDsName);
    IMosaicLayer pmoslyr = new MosaicLayerClass();
    pmoslyr.CreateFromMosaicDataset(mosaicDataset);
    ITableDefinition pTbldef = pmoslyr as ITableDefinition;
    pTbldef.DefinitionExpression = StageHelper.CurrentDataParams.ToRasterFilterSql(); //Query Expression
    pmoslyr.FootprintLayer.Visible = false;
    return pmoslyr;
    }


    public static IMosaicDataset GetMosaicDataset(IWorkspace fgdbWorkspace, string CurrentMosaicDsName)
    {

    IMosaicWorkspaceExtensionHelper mosaicExtHelper = new MosaicWorkspaceExtensionHelperClass();
    //根据扩展选择合适的工作空间
    IMosaicWorkspaceExtension mosaicExt = mosaicExtHelper.FindExtension(fgdbWorkspace);
    //使用IMosaicWorkspaceExtension接口和ICreateMosaicDatasetParameters参数来创建镶嵌数据集
    IMosaicDataset theMosaicDataset = null;
    try
    {
    theMosaicDataset = mosaicExt.OpenMosaicDataset(CurrentMosaicDsName);
    }
    catch (Exception ex)
    {
    Commons.PublicMethods.CommonMethod.AbnormalLog(ex);
    }
    return theMosaicDataset;
    }

  • 相关阅读:
    Nginx自动加载配置文件方案
    git使用说明
    zabbix监控项截图整理
    Redhat 6.7 x64升级SSH到OpenSSH_7.4p1完整文档
    一次完整的浏览器请求流程
    JavaScript
    模块
    常用模块学习
    jenkins+Gitlab+maven+tomcat实现自动集成、打包、部署
    在线抠图网站速抠图sukoutu.com全面技术解析之canvas应用
  • 原文地址:https://www.cnblogs.com/liuyongpingblog/p/7605324.html
Copyright © 2011-2022 走看看