ArcEngine由點產生TIN

來源:互聯網
上載者:User

這兩天替別人寫一個三維校園的展示程式,用的是SceneControl二次開發。需要利用DOM和TIN構建三維地形。現在說下根據高程點產生TIN的過程:

(1)根據高程點檔案(Excel)產生點shapefile

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

高程點資料格式如下:

操作介面如下:

:

產生TIN:


代碼很容易理解,如下:

   #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


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.