zoukankan      html  css  js  c++  java
  • 添加、复制、删除feature

    1、插入

    /// <summary>

    ///向featureclass中批量插入features ,批量插入features,用buffer的方法,要比循环一个个Store的方法快

    ///</summary>

    /// <param name="pFeatureClass">操作数据所在的IFeatureClass</param>

    private void InsertFeatures( IFeatureClass pFeatureClass , List< IGeometry> pGeos )

    {

      IFeatureBuffer pFeatBuf = pFeatureClass.CreateFeatureBuffer();

      IFeature pFeat = pFeatBuf;

      IFeatureCursor pFeatCur= pFeatureClass.Insert(true);

      for(int i = 0 ;i< pGeos.Count ;i++)

      {

      pFeat.Shape = pGeos(i);

      pFeatCur.InsertFeature(pFeatBuf);

      //避免一次flush,导致速度过慢

      if (i Mod 100 == 0 )

      {

        pFeatCur.Flush()

      }

      pFeatCur.Flush()

    }

    2、拷贝

    /// <summary>

    ///复制一个IFeatureClass中的要素到另外一个当中

    /// </summary>

    /// <param name="pFromFeatureClass">源数据所在的IFeatureClass</param>       

    /// <param name="pToFeatureClass">目标数据所在的IFeatureClass</param>

    private void CopyFeatureClass(IFeatureClass pFromFeatureClass, IFeatureClass pToFeatureClass)

    {

      try {

        IFeatureCursor pFromFeatureCursor = pFromFeatureClass.Search(null, false);

        IFeatureCursor pToFeatureCursor = pToFeatureClass.Insert(true);

        IFeatureBuffer pFeatureBuffer = pToFeatureClass.CreateFeatureBuffer();

        IFeature pFromFeature = pFromFeatureCursor.NextFeature();

        while (pFromFeature != null)

        {

          int IndexShape = pFeatureBuffer.Fields.FindField("Shape");

          pFeatureBuffer.set_Value(IndexShape, pFromFeature);

          pFeatureBuffer.Shape = pFromFeature.Shape;

          pToFeatureCursor.InsertFeature(pFeatureBuffer);

          pFromFeature = pFromFeatureCursor.NextFeature();

          pFeatureBuffer = pToFeatureClass.CreateFeatureBuffer();

        }

            pToFeatureCursor.Flush();

      }

      catch (Exception ex)

      {

        throw ex;

      }

    }

    3、删除

    ///<summary>删除某featurelayer中所有feature

    /// 该方法可以给一个queryfilter,进行删除符合条件的Ifeatures///</summary>

    /// <param name="pLayer ">:操作的图层</param>

    Private void DeleteAllFeatures(IFeatureLayer pLayer )

    {

      ITable pTable = pLayer.FeatureClass;

      pTable.DeleteSearchedRows(null);

    }

  • 相关阅读:
    JS系列:三元运算符与循环
    浏览器解析js和type判断数据类型
    JS系列:数据类型详细讲解
    JS系列:编程语言
    京东校招面试汇总
    有关axios的request与response拦截
    正则表达式 判断内容是否为合法的url
    H5 小代码(实时更新)
    H5 回到顶部按钮
    图片压缩(js压缩,底部有vue压缩图片依赖使用的教程链接)
  • 原文地址:https://www.cnblogs.com/henyihanwobushi/p/2972415.html
Copyright © 2011-2022 走看看