zoukankan      html  css  js  c++  java
  • ArcEngine加载SDE图层

    private void btnAddLayers_Click(object sender, EventArgs e)
            {
                //载入图层
                pWSF = new SdeWorkspaceFactory();

                IPropertySet pPropertySet = new PropertySet();
                pPropertySet.SetProperty("Server", "DU");
                pPropertySet.SetProperty("Instance", "esri_sde");
                pPropertySet.SetProperty("user", "sde");
                pPropertySet.SetProperty("password", "111");
                pPropertySet.SetProperty("version", "sde.DEFAULT");

                IWorkspace pSdeWorkspace = null;//sde工作空间
                IFeatureWorkspace pFeatureWorkspace = null;//矢量工作空间
                IRasterWorkspaceEx pRasterWorkspace = null;//栅格工作空间,注意必须是//IRasterWorkspaceEx
                try//打开工作空间
                {
                    pSdeWorkspace = pWSF.Open(pPropertySet, 0);
                    pFeatureWorkspace = pSdeWorkspace as IFeatureWorkspace;
                    pRasterWorkspace = pSdeWorkspace as IRasterWorkspaceEx;

                    //加载栅格图层
                    IRasterDataset pRasterDataset = (IRasterDataset)

    pRasterWorkspace.OpenRasterDataset("SDE.YJ");
                    IRasterLayer pLayerBackground = new RasterLayerClass();
                    pLayerBackground.CreateFromDataset(pRasterDataset);
                    mapControlMain.AddLayer(pLayerBackground);
                    mapControlOverView.AddLayer(pLayerBackground);//鹰眼

                    //加载矢量图层
                    IFeatureClass pFCBorderArea = pFeatureWorkspace.OpenFeatureClass

    ("Background");
                    IFeatureLayer pFLBorderArea = new FeatureLayer();
                    pFLBorderArea.FeatureClass = pFCBorderArea;
                    pFLBorderArea.Name = "边界面";
                    ILayer pLayerBorderArea = pFLBorderArea as ILayer;
                    mapControlMain.AddLayer(pLayerBorderArea);

                    IFeatureClass pFCDepartmentsArea =

    pFeatureWorkspace.OpenFeatureClass("DepartmentsArea");
                    IFeatureLayer pFLDepartmentsArea = new FeatureLayer();
                    pFLDepartmentsArea.FeatureClass = pFCDepartmentsArea;
                    pFLDepartmentsArea.Name = "主要单位";
                    ILayer pLayerDepartmentsArea = pFLDepartmentsArea as ILayer;
                    mapControlMain.AddLayer(pLayerDepartmentsArea);

                    IFeatureClass pFCRoads = pFeatureWorkspace.OpenFeatureClass

    ("Roads");
                    IFeatureLayer pFLRoads = new FeatureLayer();
                    pFLRoads.FeatureClass = pFCRoads;
                    pFLRoads.Name = "道路";
                    ILayer pLayerRoads = pFLRoads as ILayer;
                    mapControlMain.AddLayer(pLayerRoads);

                    IFeatureClass pFCWaterarea = pFeatureWorkspace.OpenFeatureClass

    ("Waterarea");
                    IFeatureLayer pFLWaterarea = new FeatureLayer();
                    pFLWaterarea.FeatureClass = pFCWaterarea;
                    pFLWaterarea.Name = "水域";
                    ILayer pLayerWaterarea = pFLWaterarea as ILayer;
                    mapControlMain.AddLayer(pLayerWaterarea);

                    IFeatureClass pFCRivers = pFeatureWorkspace.OpenFeatureClass

    ("Rivers");
                    IFeatureLayer pFLRivers = new FeatureLayer();
                    pFLRivers.FeatureClass = pFCRivers;
                    pFLRivers.Name = "河流";
                    ILayer pLayerRivers = pFLRivers as ILayer;
                    mapControlMain.AddLayer(pLayerRivers);

                    IFeatureClass pFCCurlvets = pFeatureWorkspace.OpenFeatureClass

    ("Curlvets");
                    IFeatureLayer pFLCurlvets = new FeatureLayer();
                    pFLCurlvets.FeatureClass = pFCCurlvets;
                    pFLCurlvets.Name = "涵洞";
                    ILayer pLayerCurlvets = pFLCurlvets as ILayer;
                    mapControlMain.AddLayer(pLayerCurlvets);

                    IFeatureClass pFCPumpingStations =

    pFeatureWorkspace.OpenFeatureClass("PumpingStation");
                    IFeatureLayer pFLPumpingStations = new FeatureLayer();
                    pFLPumpingStations.FeatureClass = pFCPumpingStations;
                    pFLPumpingStations.Name = "泵站";
                    ILayer pLayerPumpingStations = pFLPumpingStations as ILayer;
                    mapControlMain.AddLayer(pLayerPumpingStations);


                    IFeatureClass pFCBorder = pFeatureWorkspace.OpenFeatureClass

    ("Border");
                    IFeatureLayer pFLBorder = new FeatureLayer();
                    pFLBorder.FeatureClass = pFCBorder;
                    pFLBorder.Name = "边界线";
                    ILayer pLayerBorder = pFLBorder as ILayer;
                    mapControlMain.AddLayer(pLayerBorder);
                    mapControlOverView.AddLayer(pLayerBorder);

                    mapControlMain.ActiveView.Refresh();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
              
            }

  • 相关阅读:
    Java程序员的成神之路
    es集群搭建(2个节点)
    MySQL主从复制与主主复制
    高并发量服务器架构
    AngularJS跨域问题
    CentOs7.3 搭建 RabbitMQ 3.6 单机服务与使用
    Dubbo的高可用
    Nginx配置性能优化
    从Socket谈到浏览器和服务器之间的关系
    关于数据库死锁
  • 原文地址:https://www.cnblogs.com/suncarry/p/1737323.html
Copyright © 2011-2022 走看看