码迷,mamicode.com
首页 > 其他好文 > 详细

ArcEngine由点生成TIN

时间:2014-05-15 03:50:55      阅读:529      评论:0      收藏:0      [点我收藏+]

标签:arcengine   gis   tin   scenecontrol   3dgis   

这两天替别人写一个三维校园的展示程序,用的是SceneControl二次开发。需要利用DOM和TIN构建三维地形。现在说下根据高程点生成TIN的过程:

(1)根据高程点文件(Excel)生成点shapefile

(2)使用ITinEdit的AddFromFeatureClass方法生成TIN

高程点数据格式如下:

bubuko.com,布布扣

操作界面如下:

bubuko.com,布布扣

生成TIN效果图:

bubuko.com,布布扣

代码很容易理解,如下:

   #region 创建TIN
        private void button_ok_Click(object sender , EventArgs e)
        {
            try
            {
                strTinName=textBox_TINName.Text;
                outFolder=textBox_outpath.Text;
                if (strTinName=="")
                {
                    MessageBox.Show("请输入TIN名称!");
                } 
                else if (outFolder=="")
                {
                    MessageBox.Show("请选择TIN保存路径");
                }
                else
                {
                    //生成点shape
                    Excel2Shape excel2shape = new Excel2Shape(textBox_point.Text);
                    excel2shape.CreateShapeFromExcel();

                    //获取shapefile
                    string path = excel2shape.path;
                    string name = excel2shape.name;

                    IWorkspaceFactory pWSFac = new ShapefileWorkspaceFactoryClass();
                    IFeatureWorkspace pFeatureWS = pWSFac.OpenFromFile(path , 0) as IFeatureWorkspace;
                    IFeatureClass pFeatureClass = pFeatureWS.OpenFeatureClass(name);
                    IField pField = pFeatureClass.Fields.get_Field(pFeatureClass.FindField("Z"));
                    //创建TIN
                    ITin pTin = Create_TIN(pFeatureClass , pField , outFolder);
                    ITinLayer pTinlayer = new TinLayerClass();
                    pTinlayer.Dataset = pTin;
                    pTinlayer.Name = strTinName;

                    pSceneControl.SceneGraph.Scene.AddLayer(pTinlayer as ILayer , true);

                    this.Close();
                }
              
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "创建TIN失败!");
            }

        }
        /// <summary>
        /// 创建TIN
        /// </summary>
        /// <param name="pFeatureClass">点要素类</param>
        /// <param name="pField">Z字段</param>
        /// <param name="pPath">路径</param>
        public ITin Create_TIN(IFeatureClass pFeatureClass , IField pField , string pPath)
        {
            IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
            ITinEdit pTinEdit = new TinClass();
            pTinEdit.InitNew(pGeoDataset.Extent);
            object pObj = Type.Missing;

            pTinEdit.AddFromFeatureClass(pFeatureClass , null , pField , null ,
            esriTinSurfaceType.esriTinMassPoint , ref pObj);
            if (System.IO.File.Exists(pPath))
            {
                _3DCampus.helper.FolderHelper.DeleteFolder(pPath);
            }
            pTinEdit.SaveAs(pPath , ref pObj);
            pTinEdit.Refresh();
            return pTinEdit as ITin;

        }
        #endregion


ArcEngine由点生成TIN,布布扣,bubuko.com

ArcEngine由点生成TIN

标签:arcengine   gis   tin   scenecontrol   3dgis   

原文地址:http://blog.csdn.net/giser_whu/article/details/25747279

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!