`
lorry1113
  • 浏览: 263213 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

insertFeatureClass的三种方式

    博客分类:
  • GIS
 
阅读更多
 private IFeatureClass insertFeature_one( IFeatureClass fclass, IFeature feature){
         try {
        	IFeatureBuffer pFeatBuf = fclass.createFeatureBuffer();
        	IFeature pFeat = (IFeature) pFeatBuf;
        			 pFeat.setShapeByRef(feature.getShape());	
			IFeatureCursor pFeatCur = fclass.IFeatureClass_insert(true);
			pFeatCur.insertFeature(pFeatBuf);
			pFeatCur.flush();
		} catch (AutomationException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		}
		return fclass;	
    }
    
    private IFeatureClass insertFeature_second(IFeatureClass fclass, IFeature feature){
        try {
	       	 IFeature pFeature = fclass.createFeature();
	       	 pFeature.setShapeByRef(feature.getShape());
	       	 pFeature.store();
		} catch (AutomationException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		}
		return fclass;
    }
    
    private IFeatureClass insertFeatures( IFeatureClass fclass, List<IFeature> features){
        try {
        	IFeatureBuffer pFeatBuf = null;
        	IFeatureCursor pFeatCur = null;
        	for(int i=0; i<features.size(); i++){
        		pFeatBuf = fclass.createFeatureBuffer();
        		pFeatCur = fclass.IFeatureClass_insert(true);
            	IFeature pFeat = (IFeature) pFeatBuf;
            			 pFeat.setShapeByRef(features.get(i).getShape());	
    			pFeatCur.insertFeature(pFeatBuf);
    			if(i/100 == 0){
    				pFeatCur.flush();
    			}
        	}
        	pFeatCur.flush();
		} catch (AutomationException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		}
		return fclass;
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics