insertFeatureClass的三种方式

主要是用于提取元素插入到图层中:

[csharp]  view plain  copy
 print ?
  1. private IFeatureClass insertFeature_one( IFeatureClass fclass, IFeature feature){  
  2.         try {  
  3.         IFeatureBuffer pFeatBuf = fclass.createFeatureBuffer();  
  4.         IFeature pFeat = (IFeature) pFeatBuf;  
  5.                  pFeat.setShapeByRef(feature.getShape());     
  6.         IFeatureCursor pFeatCur = fclass.IFeatureClass_insert(true);  
  7.         pFeatCur.insertFeature(pFeatBuf);  
  8.         pFeatCur.flush();  
  9.     } catch (AutomationException e) {  
  10.         e.printStackTrace();  
  11.     } catch (IOException e){  
  12.         e.printStackTrace();  
  13.     }  
  14.     return fclass;    
  15.    }  
  16.      
  17.    private IFeatureClass insertFeature_second(IFeatureClass fclass, IFeature feature){  
  18.        try {  
  19.          IFeature pFeature = fclass.createFeature();  
  20.          pFeature.setShapeByRef(feature.getShape());  
  21.          pFeature.store();  
  22.     } catch (AutomationException e) {  
  23.         e.printStackTrace();  
  24.     } catch (IOException e){  
  25.         e.printStackTrace();  
  26.     }  
  27.     return fclass;  
  28.    }  
  29.      
  30.    private IFeatureClass insertFeatures( IFeatureClass fclass, List<IFeature> features){  
  31.        try {  
  32.         IFeatureBuffer pFeatBuf = null;  
  33.         IFeatureCursor pFeatCur = null;  
  34.         for(int i=0; i<features.size(); i++){  
  35.             pFeatBuf = fclass.createFeatureBuffer();  
  36.             pFeatCur = fclass.IFeatureClass_insert(true);  
  37.             IFeature pFeat = (IFeature) pFeatBuf;  
  38.                      pFeat.setShapeByRef(features.get(i).getShape());     
  39.             pFeatCur.insertFeature(pFeatBuf);  
  40.             if(i/100 == 0){  
  41.                 pFeatCur.flush();  
  42.             }  
  43.         }  
  44.         pFeatCur.flush();  
  45.     } catch (AutomationException e) {  
  46.         e.printStackTrace();  
  47.     } catch (IOException e){  
  48.         e.printStackTrace();  
  49.     }  
  50.     return fclass;  
  51.    }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值