使用产品: iObjects Java 10i(2021) 操作系统:win10 x64
问题详细描述:dwg、dxf、shp三种格式其他互转都可以,dwg和dxf格式转换shp格式后文件夹为空。请教是什么问题?
private Datasource m_desDatasource = null;
public void test() {
// importDWG("D:/supermap/SampleData/DataExchange/Polyline.dwg");
importDXF("D:/supermap/SampleData/DataExchange/Polyline.dxf");
// importShp("D:/supermap/SampleData/DataExchange/ShpImport/Polyline.shp");
exportSHP("D:/supermap/SampleData/DataExchange/ShpExport", "Polyline.shp");
// exportDXF("D:/supermap/SampleData/DataExchange/DxfExport", "Polyline.dxf");
// exportDWG("D:/supermap/SampleData/DataExchange/DwgExport", "Polyline.dwg");
}
private void importDXF(String path) {
try {
ImportSettingDXF importSettingDXF= new ImportSettingDXF();
importSettingDXF.setImportMode(ImportMode.OVERWRITE);
importSettingDXF.setTargetDatasource(m_desDatasource);
importSettingDXF
.setSourceFilePath(path);
DataImport dataImport = new DataImport();
dataImport.getImportSettings().add(importSettingDXF);
dataImport.run();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
private void exportSHP(String path, String name) {
try {
ExportSetting exportSetting = new ExportSetting();
exportSetting.setOverwrite(true);
try{
File file = new File(path);
if(!file.exists()){
file.mkdir();
}
} catch (Exception e) {
e.printStackTrace();
}
exportSetting.setTargetFileType(FileType.SHP);
exportSetting
.setTargetFilePath(path + "/" + name);
exportSetting.setSourceData(m_desDatasource.getDatasets().get("Polyline"));
DataExport dataExport = new DataExport();
dataExport.getExportSettings().add(exportSetting);
dataExport.run();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}