主要是用于提取元素插入到图层中:
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;
}
本文介绍了一种在ArcGIS中将元素插入特定图层的方法。提供了三种不同的实现方式:单个元素插入、单个元素插入第二种方式及批量元素插入。通过创建特征缓冲区或直接创建特征对象,并设置形状属性来完成插入操作。
2610

被折叠的 条评论
为什么被折叠?



