首页 > 其他 > 详细

ArcEngine由点生成TIN

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

这两天替别人写一个三维校园的展示程序,用的是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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!