zoukankan      html  css  js  c++  java
  • 文件图层创建(可用于创建临时图层)

    public void CreateNewLayer(AxMapControl ax, string layerName, esriGeometryType layerType)

    {

       // 空间参考系 得到当前地图的空间参考系

      ISpatialReference spatialReference = ax.ActiveView.FocusMap.SpatialReference;

      // 设定保持的路径

      string strShapeFolder = @"F:\fuzhou\";

      // 设定图层文件名

      string strShapeFile = layerName + ".shp";

      string shapeFileFullName = strShapeFolder + strShapeFile;

      // 定义工作空间

      IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();

      // 矢量工组空间

         IFeatureWorkspace featureWorkspace =(IFeatureWorkspace) workspaceFactory.OpenFromFile(strShapeFolder, 0);

      IFeatureClass featureClass;

      // 如何已存在当前文件

      if (File.Exists(shapeFileFullName))

      {

        featureClass = featureWorkspace.OpenFeatureClass(strShapeFile);

        // 数据集对象的删除

        IDataset dataset = (IDataset)featureClass;

        dataset.Delete();

      }

      // 定义矢量数据的属性字段

      IFields fields = new FieldsClass();

      IFieldsEdit fieldsEdit = (IFieldsEdit)fields;

      IField field = new FieldClass();

      IFieldEdit fieldEdit = (IFieldEdit)field;

      fieldEdit.Name_2 = "SHAPE";

      fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

      IGeometryDefEdit geoDef = new GeometryDefClass();

      IGeometryDefEdit geoDefEdit = (IGeometryDefEdit)geoDef;

      geoDefEdit.GeometryType_2 = layerType;//设置图层类型

      geoDefEdit.SpatialReference_2 = spatialReference;

      fieldEdit.GeometryDef_2 = geoDef;

      fieldsEdit.AddField(field);

      field = new FieldClass();

      fieldEdit = (IFieldEdit)field;

      fieldEdit.Name_2 = "data";

      fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;

      fieldsEdit.AddField(field);

          // 创建对象

      featureClass = featureWorkspace.CreateFeatureClass(strShapeFile, fields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");

      ax.AddShapeFile(strShapeFolder, strShapeFile);

    }

  • 相关阅读:
    OKHttp使用详解
    spring okhttp3
    HTTPS SSL/TLS协议
    springboot @scheduled 并发
    spring @Scheduled 并发
    CORSFilter 跨域资源访问
    定时任务 spring @Scheduled注解
    spring proxy-target-class
    iOS 适用于Pad上的菜单弹出界面-最简单的一种实现记录
    Mac系统清理、占用空间大、空间不够、查看系统文件大小分布
  • 原文地址:https://www.cnblogs.com/oftenlin/p/2672003.html
Copyright © 2011-2022 走看看