使用产品:iObjectsJava10 操作系统:win11 x64
数据类型:文件型
问题详细描述:我在将udb文件里的二维点数据集进行二维点转三维点操作时,除系统字段外,其他属性都赋不上值,代码如下:
public void point2Dto3D(String udbFile, String srcDataset, String destDataset, String elevationName){
init(udbFile, srcDataset);
if(DatasetType.POINT != dataset.getType()){
throw new RuntimeException("该源数据集不是点数据集,不能进行操作");
}
datasets.delete(destDataset);
// 设置矢量数据集的信息
DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
datasetVectorInfo.setType(DatasetType.POINT3D);
datasetVectorInfo.setEncodeType(EncodeType.NONE);
datasetVectorInfo.setName(destDataset);
datasetVectorInfo.setGeoStoreType(GeoStoreType.DEFAULT);
// 创建三维数据集
DatasetVector datasetVector = datasets.create(datasetVectorInfo);
datasetVector.open();
datasetVector.setPrjCoordSys(dataset.getPrjCoordSys());
datasetVector.setReadOnly(false);
Recordset destRecordset = datasetVector.getRecordset(false, CursorType.DYNAMIC);
// 获取源二维点数据集
Recordset srcRecordset = dataset.getRecordset(false, CursorType.DYNAMIC);
// 拷贝属性
copyField(dataset, datasetVector);
long beginTime = System.currentTimeMillis();
int i = 0;
// 获得记录集对应的批量更新对象
Recordset.BatchEditor editor = destRecordset.getBatch();
// 设置批量更新每次提交的记录数目
editor.setMaxRecordCount(10);
editor.begin();
while(!srcRecordset.isEOF()){
GeoPoint geometry = (GeoPoint) srcRecordset.getGeometry();
Double elevation = NumberUtils.toDouble(srcRecordset.getFieldValue(elevationName).toString(), 0.0D);
Point3D point3D = new Point3D(geometry.getX(), geometry.getY(), elevation);
GeoPoint3D geometry3D = new GeoPoint3D();
geometry3D.setPosition(point3D);
destRecordset.addNew(geometry3D, getFieldMap(srcRecordset));
geometry.dispose();
geometry3D.dispose();
srcRecordset.moveNext();
destRecordset.moveNext();
if(++i == 10){
break;
}
}
// 批量操作统一提交
editor.update();
long endTime = System.currentTimeMillis();
System.out.println("共耗时:" + (endTime - beginTime) / 1000);
}
private Map<String, Object> getFieldMap (Recordset sourRecordset) {
Map<String, Object> map = Maps.newHashMap();
for (int i = 0; i < sourRecordset.getFieldCount(); i++) {
FieldInfo fieldInfo = sourRecordset.getFieldInfos().get(i);
if(fieldInfo.isSystemField() || fieldInfo.getName().equalsIgnoreCase("SmUserID")){
continue;
}
map.put(fieldInfo.getName(), sourRecordset.getFieldValue(fieldInfo.getName()));
}
return map;
}
private void copyField (DatasetVector sourRecordset, DatasetVector destDataset) {
FieldInfos fieldInfos = sourRecordset.getFieldInfos();
FieldInfos fieldInfos1 = destDataset.getFieldInfos();
for (int i = 0; i < fieldInfos.getCount(); i++) {
FieldInfo fieldInfo = fieldInfos.get(i);
if(fieldInfo.isSystemField() || fieldInfo.getName().equalsIgnoreCase("SmUserID")){
continue;
}
fieldInfos1.add(fieldInfos.get(i));
}
}
二维点部分属性表数据为:
转换后的三维点属性表部分数据为:
还请大神帮忙看一下是什么原因!!!!
非常感谢!!!