主要是用于提取元素插入到图层中:
- 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;
- }