ArcEngine加载SDE中的栅格数据的问题

在加载矢量数据时直接转到IFeatureWorkspace接口即可,但是在加载栅格数据时要转到IRasterWorkspaceEx接口。效果图如下,双击即可添加到Globe中。

代码如下:

   public partial class SDEDataViewer : DevComponents.DotNetBar.Office2007Form
    {
        #region 私有变量
        private IWorkspace sdeWorkSpace; //sde工作控件
        private IGlobeControl globecontrol;

        private string selectedVectorName;//待添加矢量
        private string selectedRasterName;
        #endregion

        #region 构造函数
        public SDEDataViewer(IGlobeControl m_globecontrol , IWorkspace workspace)
        {
            this.sdeWorkSpace = workspace;
            this.globecontrol = m_globecontrol;
            InitializeComponent();
        }
        #endregion

        #region load

        private void SDEDataViewer_Load(object sender , EventArgs e)
        {
            IAoInitialize initAO = new AoInitializeClass();
            initAO.Initialize((esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB));
            loadData();
        }
        //获取所有数据
        private void loadData()
        {
            listView_vector.GridLines = true;//表格是否显示网格线
            listView_vector.FullRowSelect = true;//是否选中整行
            listView_vector.View = View.Details;//设置显示方式
            listView_vector.Scrollable = true;//是否自动显示滚动条
            listView_vector.MultiSelect = false;//是否可以选择多行

            listView_raster.GridLines = true;
            listView_raster.FullRowSelect = true;
            listView_raster.View = View.Details;
            listView_raster.Scrollable = true;
            listView_raster.MultiSelect = false;

            //添加表头(列)
            listView_vector.Columns.Add("要素名称" , 150 , HorizontalAlignment.Center);
            listView_vector.Columns.Add("要素类型" , 100 , HorizontalAlignment.Center);
            listView_raster.Columns.Add("数据名称" , 150 , HorizontalAlignment.Center);
            listView_raster.Columns.Add("数据类型" , 100 , HorizontalAlignment.Center);

            try
            {
                IEnumDataset enumDataset = sdeWorkSpace.get_Datasets(esriDatasetType.esriDTAny);
                IDataset dataset = null;
                while ((dataset = enumDataset.Next()) != null)
                {
                    if (dataset.Type == esriDatasetType.esriDTFeatureClass)
                    {
                        ListViewItem item = new ListViewItem();
                        item.SubItems.Clear();
                        item.SubItems[0].Text = dataset.Name;
                        string strFeatureType = GetFeatureType(dataset.Name);
                        item.SubItems.Add(strFeatureType);
                        listView_vector.Items.Add(item);
                    }
                    else if (dataset.Type == esriDatasetType.esriDTRasterDataset)
                    {
                        ListViewItem item = new ListViewItem();
                        item.SubItems.Clear();
                        item.SubItems[0].Text = dataset.Name;
                        item.SubItems.Add("栅格数据集");
                        listView_raster.Items.Add(item);

                    }

                }

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        //获取要素类型
        private string GetFeatureType(string pDataSetName)
        {
            string featureType = "";
            IFeatureWorkspace pFeatureWS = sdeWorkSpace as IFeatureWorkspace;
            IFeatureClass featureClass = pFeatureWS.OpenFeatureClass(pDataSetName);

            switch (featureClass.ShapeType)
            {

                case esriGeometryType.esriGeometryPoint:
                    featureType = "点要素";
                    break;
                case esriGeometryType.esriGeometryPolyline:
                    featureType = "线要素";
                    break;
                case esriGeometryType.esriGeometryPolygon:
                    featureType = "面要素";
                    break;
                default:
                    break;
            }
            // System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureWS);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
            return featureType;
        }

        #endregion

        #region 添加数据

        //添加矢量
        private void listView_vector_MouseDoubleClick(object sender , MouseEventArgs e)
        {

            IFeatureClass featureClass = (sdeWorkSpace as IFeatureWorkspace).OpenFeatureClass(selectedVectorName);
            IFeatureLayer featureLayer = new FeatureLayerClass()
            {
                FeatureClass = featureClass ,
                Name = featureClass.AliasName
            };
            VectorHelper_FeatureOpt VectorAdderHelper = new VectorHelper_FeatureOpt(globecontrol , featureLayer);
            VectorAdderHelper.ShowDialog();
            this.Close();

            //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
            //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureLayer);

        }

        //添加栅格
        private void listView_raster_MouseDoubleClick(object sender , MouseEventArgs e)
        {

            IRasterWorkspaceEx rasterWSEx = sdeWorkSpace as IRasterWorkspaceEx;
            IRasterDataset rasterDataset = rasterWSEx.OpenRasterDataset(selectedRasterName);
            IRasterLayer rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromDataset(rasterDataset);

            RasterHelper_LayerType rasterAdderHelper = new RasterHelper_LayerType(globecontrol , rasterLayer);
            rasterAdderHelper.ShowDialog();
            this.Close();

            //System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterLayer);

        }

        //obtain selected vector
        private void listView_vector_SelectedIndexChanged(object sender , EventArgs e)
        {
            ListViewItem item = new ListViewItem();
            item = listView_vector.SelectedItems[0];
            string featureClassName_temp = item.SubItems[0].ToString();
            int lastIndex_left = featureClassName_temp.LastIndexOf("{");
            int lastIndex_right = featureClassName_temp.LastIndexOf("}");
            selectedVectorName = featureClassName_temp.Substring(lastIndex_left + 1 , lastIndex_right - lastIndex_left - 1);

        }
        //obtain selected raster
        private void listView_raster_SelectedIndexChanged(object sender , EventArgs e)
        {
            ListViewItem item = new ListViewItem();
            item = listView_raster.SelectedItems[0];
            string rasterName_temp = item.SubItems[0].ToString();
            int lastIndex_left = rasterName_temp.LastIndexOf("{");
            int lastIndex_right = rasterName_temp.LastIndexOf("}");
            selectedRasterName = rasterName_temp.Substring(lastIndex_left + 1 , lastIndex_right - lastIndex_left - 1);

        }
        #endregion

    }

欢迎留言交流。

ArcEngine加载SDE中的栅格数据的问题

时间: 2024-11-13 20:23:13

ArcEngine加载SDE中的栅格数据的问题的相关文章

weex 加载 .xcassets 中的图片资源

背景 因为 .xcassets 中的图片资源只能通过 imageNamed: 方法加载,所以需要做一些特殊处理,才能提供给 Weex 使用(PS:纯属娱乐,因为 Weex 跨平台的特性,这种针对某一端做实现的方案实用价值并不大). 方案 观察 WeexSDK 发现有 WXImgLoaderProtocol 这个协议,这个协议包含了下面的方法: - (id<WXImageOperationProtocol>)downloadImageWithURL:(NSString *)url imageFr

Android插件化(二):使用DexClassLoader动态加载assets中的apk

Android插件化(二):使用DexClassLoader动态加载assets中的apk 简介 上一篇博客讲到,我们可以使用MultiDex.java加载离线的apk文件.需要注意的是,apk中的类是加载到当前的PathClassLoader当中的,如果apk文件过多,可能会出现ANR的情况.那么,我们能不能使用DexClassLoader加载apk呢?当然是可以的!首先看一下Doc文档. A class loader that loads classes from .jar and .apk

百度地图 在加载过程中,根据回调函数结果中第一个点设置为中心点

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script&g

加载器中的预编

if (_type == "js") {//js预编译 var _script = "_define(function(exports,module){\n"; _script += "var $parent = \"" + _basePath + "\";\n"; _script += data.replace(/require\(/g, "_require($parent,"); _

spring加载过程中jar包加载不了,解决方法

当我们在开发spring项目时,一般会将jar包放到webInf/lib下,这样是myeclipse自动将jar包加载到tomcat中webapps下,但是当我们新建一个lib文件夹的情况下,我们add building Path时就会出错,这时候我们有个技巧供使用. 1.项目上点击右键搜索de,找到deployment assembly 目的就是将此处添加的jar包添加到系统webINF/lib路径下 来自为知笔记(Wiz) spring加载过程中jar包加载不了,解决方法

正在加载数据中效果

<div id="gcjDhccFullScreen" style="padding-left:45%;padding-top: 30%;display: none;position: absolute;top: 0;left: 0;width: window.document.body.offsetWidth;height: window.document.body.offsetHeight;z-index: 999;"> <table widt

C#加载网页中的图片

需求:在winform程序中加载网页中的验证码 1.打开网页,获取到网页中img的src属性,得到的是图片的base64编码字符串: string base64string= webBrowser1.Document.All["yzm_img"].GetAttribute("src"); 2.将字符串转换为图片: byte[] b = Convert.FromBase64String(base64string); MemoryStream ms = new Memo

教您如何在Word的mathtype加载项中修改章节号

在MathType数学公式编辑器中,公式编号共有五部分内容:分别是章编号(Chapter Number).节编号(Section Number).公式编号(Equation Number).括号(Enclosure). 分隔符(Separator).这五部分内容可以进行自由切换,以实现不同的需要.本文将以Microsoft office为例,教大家如何在word的mathtype加载项中修改章节号. 公式编号的设置方法: 1.单击word文档中的MathType加载项,点击第三列中插入编号的倒置

Android动态加载ListView中的Item

我这周上网看到动态增加listview的每一项item的布局,今天抽空自己写了一个,方便自己日后使用,这个效果还是很不错的,用到了Adapter的notifyDataSetChanged()方法,当点击每一个Item的时候,就通知adapter更新getView,系统得到通知就相应的加载一遍布局,就达到了动态加载item布局的效果.希望给大家带来点启迪,有问题或想要代码的可以留言,欢迎大家留言谈论listview的一些知识,以求共同进步,转载请标明出处: http://blog.csdn.net