zoukankan      html  css  js  c++  java
  • ArcEngine下一个TIN生成的轮廓

    太晚了,直接连接的源代码:

        /// <summary>
            /// TIN生成等高线
            /// </summary>
            /// <param name="pInterval">等高线间距</param>
            public void Tin2Contour(string path_,string name_,double pInterval)
            {
                //获取TIN
                ITinLayer pTinlayer = GetLayerByName(pScene , comboBox_TIN.Text) as ITinLayer;
                ITin pTin = pTinlayer.Dataset as ITin;
    
                //创建Contour shape
                IWorkspaceFactory pWSFac = new ShapefileWorkspaceFactoryClass();
                IFeatureWorkspace pFeatureWS = pWSFac.OpenFromFile(path_ , 0) as IFeatureWorkspace;
                if (System.IO.File.Exists(path_+"\"+name_+".shp"))
                {
                    System.IO.File.Delete(path_ + "\" + name_ + ".shp");
                    System.IO.File.Delete(path_ + "\" + name_ + ".dbf");
                    System.IO.File.Delete(path_ + "\" + name_ + ".shx");
                }
                IFields pFields = CreateShapeFields(esriGeometryType.esriGeometryPolyline);
                pFeatureWS.CreateFeatureClass(name_ , pFields , null , null , esriFeatureType.esriFTSimple , "Shape" , null);
               
                IFeatureClass pContourFeatureClass = pFeatureWS.OpenFeatureClass(name_);
             
                //生成等高线
                ITinSurface pTinSurface = pTin as ITinSurface;
                pTinSurface.Contour(0 , pInterval , pContourFeatureClass , "Contour" , 0);
    
                //加入等高线图层
                IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                pFeatureLayer.FeatureClass = pContourFeatureClass;
              
                IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
                pGeoFeatureLayer.DisplayAnnotation = true;
                pGeoFeatureLayer.DisplayField = "Contour";
                pGeoFeatureLayer.Name = pContourFeatureClass.AliasName + "_Contour";
    
                //设置线样式
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pLineSymbol.Color = GetRGBColor(32 , 47 , 247);
                pLineSymbol.Width = 2;
                ISimpleRenderer pRender = pGeoFeatureLayer.Renderer as ISimpleRenderer;
                pRender.Symbol = pLineSymbol as ISymbol;
    
                pScene.AddLayer(pFeatureLayer as ILayer);
    
            }
          #region 创建几何字段
    
            /// <summary>
            /// 创建几何字段
            /// </summary>
            /// <param name="p_esriGeotype"></param>
            /// <returns></returns>
            public IFields CreateShapeFields(esriGeometryType p_esriGeotype)
            {
    
                IFields pFields = new FieldsClass();
                IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
    
                IGeometryDef pGeoDef = new GeometryDefClass();
                IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;
                pGeoDefEdit.GeometryType_2 = p_esriGeotype;
                pGeoDefEdit.SpatialReference_2 = (ISpatialReference) new UnknownCoordinateSystem();
    
                IField pFld = new FieldClass();
                IFieldEdit pFldEdit = pFld as IFieldEdit;
                pFldEdit.Name_2 = "shape";
                pFldEdit.IsNullable_2 = false;
                pFldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                pFldEdit.GeometryDef_2 = pGeoDef;
    
                pFieldsEdit.AddField(pFld);
    
                return pFields;
            }
    
            #endregion
           
            #region 依据名称获取图层
    
            //依据名称获取图层
            public ILayer GetLayerByName(IScene scene , string strLayerName)
            {
                ILayer pLayer = null;
                for (int i = 0;i < scene.LayerCount;i++)
                {
                    pLayer = scene.get_Layer(i);
                    if (strLayerName == pLayer.Name)
                    {
                        break;
                    }
                }
                return pLayer;
            }
            #endregion

    Contour功能说明参考帮助文档。

    版权声明:本文博主原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    数据绑定表达式语法(Eval,Bind区别)
    使用博客园的第一件事 自定义主题
    sql2000 跨服务器复制表数据
    使用UpdatePanel 局部刷新出现中文乱码的解决方法!!
    MMC不能打开文件MSC文件
    sql 日期 、时间相关
    loaded AS2 swf call function in AS3 holder
    Rewrite the master page form action attribute in asp.net 2.0
    100万个不重复的8位的随机数
    flash 中实现斜切变型
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4758350.html
Copyright © 2011-2022 走看看