private IFeatureClass Create_ContourLine(ITin pTin, string WorkSpaceName, string FileName) { int pInterval = 1; IWorkspaceFactory contourWSF = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace contourFWS = (IFeatureWorkspace)contourWSF.OpenFromFile(WorkSpaceName, 0); IFields pFields = CreateShapeFields(esriGeometryType.esriGeometryPolyline); contourFWS.CreateFeatureClass(FileName, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", null); IFeatureClass pContourFeatureClass = contourFWS.OpenFeatureClass(FileName); //生成等高线 ITinSurface pTinSurface = pTin as ITinSurface; pTinSurface.Contour(0, pInterval, pContourFeatureClass, "Contour", 0); return(pContourFeatureClass); }
/// <summary> /// 通过TIN文件,建立*.shp文件 /// </summary> /// <param name="TINDir">TIN文件的文件夹路径</param> private void CreateContourData(string TINDir) { try { IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); CopyFolder(Application.StartupPath + "\\Convert\\TemContour", Application.StartupPath + "\\Convert\\ContourResult\\" + this.Random); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\Convert\\ContourResult\\" + this.Random, 0); IWorkspaceEdit w = pWorkspace as IWorkspaceEdit; IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; IFeatureClass tFeatureClass = pFeatureWorkspace.OpenFeatureClass("Contour.shp"); ITinWorkspace pTinWorkspace; IWorkspace pWS; IWorkspaceFactory pWSFact = new TinWorkspaceFactoryClass(); pWS = pWSFact.OpenFromFile(TINDir, 0); ITin pTin; pTinWorkspace = pWS as ITinWorkspace; w.StartEditing(true); w.StartEditOperation(); if (pTinWorkspace.get_IsTin(this.Random)) { pTin = pTinWorkspace.OpenTin(this.Random); ITinSurface pTinSurface = pTin as ITinSurface; pTinSurface.Contour(0, this.Interval, tFeatureClass, "Z", 0); w.StopEditOperation(); w.StopEditing(true); } } catch (Exception) { } }