/// <Summary> /// Load tin from directory /// ESRI tin is a folder, which contains eight fixed-name ADF files. /// </Summary> /// <Param name = "folder"> Parent directory of tindataset </Param> /// <Param name = "tindataset"> Tindataset name </Param> /// <Returns> </returns> Public Itin gettinlayer ( String Folder, String Tindataset) {iworkspacefactory pwsfact = New Tinworkspacefactoryclass (); iworkspace PWS = Pwsfact. openfromfile (folder, 0 ); Itinworkspace ptinws = PWS As Itinworkspace; itin ptin = Ptinws. opentin (tindataset ); Return Ptin ;}
Li_tindataset = new list <string> {"tdenv. ADF "," tedg. ADF "," thul. ADF "," tmsk. ADF "," tmsx. ADF "," tnod. ADF "," tnxy. ADF "," tnz. ADF "};
/// <Summary> /// Check whether it is Tin Dataset /// </Summary> /// <Param name = "folderpath"> User-selected folder </Param> /// <Returns> </returns> Public Bool Checktindataset ( String Folderpath ){ If (! Directory. exists (folderpath )) Return False ; Directoryinfo di =New Directoryinfo (folderpath); fileinfo [] ar_fi = Di. getfiles ( " *. ADF " ); List < String > Li_tem = New List < String > (); For ( Int I = 0 ; I <= ar_fi.length-1 ; I ++ ) {Li_tem.add (ar_fi [I]. Name );} Int Afirmed = 0 ; For ( Int I = 0 ; I <= li_tindataset.count- 1 ; I ++ ){ If (Li_tem.contains (li_tindataset [I]) afirmed ++ ; Else Break ;} If (Afirmed = 8 ) Return True ; Else Return False ;}
/// <Summary> /// This method uses the entire tin as the computing object. /// </Summary> /// <Param name = "Tin"> Tinlayer </Param> /// <Param name = "planeheight"> Reference height </Param> Public Void Calculateareavolumeisurface (itin tin, Double Planeheight, esriplanereferencetype aboveorbelow,Out Double Projectedarea, Out Double Surfacearea, Out Double Volume) {isurface psurface = Tin As Isurface; projectedarea = Psurface. getprojectedarea (planeheight, aboveorbelow); surfacearea = Psurface. getsurfacearea (planeheight, aboveorbelow); Volume =Psurface. getvolume (planeheight, aboveorbelow); projectedarea = Math. Round (projectedarea, 2 ); // Retain two decimal places Surfacearea = math. Round (surfacearea, 2 ); Volume = Math. Round (volume, 2 );}