tif数据导入到oracle 数据库demo

package com.supermap.samplecode.conversion;


import com.supermap.data.Datasource;

import com.supermap.data.Workspace;

import com.supermap.data.WorkspaceConnectionInfo;

import com.supermap.data.WorkspaceType;

import com.supermap.data.conversion.DataImport;

import com.supermap.data.conversion.ImportResult;

//import com.supermap.data.conversion.ImportMode;

import com.supermap.data.conversion.ImportSettingTIF;


public class SampleRun {

private Workspace m_workspace = null;//定义的工作空间

private Datasource m_desDatasource = null;//定义的数据源


//构造方法 

public SampleRun(Workspace workspace) {

this.m_workspace = workspace;

initialize();

}


/**

* 初始化相关变量,打开地图

*/

private void initialize() {

try {

WorkspaceConnectionInfo dataExchangeWorkspaceConnectionInfo = new WorkspaceConnectionInfo();//定义的工作空间连接信息类

dataExchangeWorkspaceConnectionInfo.setServer("/root/Desktop/tif/import-tif.smwu");

//设置打开的工作空间的类型

dataExchangeWorkspaceConnectionInfo.setType(WorkspaceType.SMWU);

m_workspace.open(dataExchangeWorkspaceConnectionInfo);

} catch (Exception e) {

e.printStackTrace();

}


m_desDatasource = m_workspace.getDatasources().get("orcl_oracle");//数据源为 工作空间中获取的数据源

if (m_desDatasource != null) 

m_desDatasource.getDatasets().deleteAll();

}


}

public void importTIF() {

try {

ImportSettingTIF importSettingTIF = new ImportSettingTIF();// 实例化一个导入tif信息类

importSettingTIF.setSourceFilePath("/root/Desktop/tif/utm.tif");//设置文件路径

importSettingTIF.setTargetDatasource(m_desDatasource);//设置数据源

importSettingTIF.setPyramidBuilt(true);//自动建立影像金字塔

/* importSettingTIF.setWorldFilePath(null);//导入的坐标参考文件路径

*/ DataImport di = new DataImport();//实例化一个导入数据的方法

di.getImportSettings().add(importSettingTIF);//添加导入信息类

System.out.println("1111111111111111111111111111111");

long begin = System.currentTimeMillis();//取开始时间

ImportResult ir = di.run();//定义的结果数据集

long end = System.currentTimeMillis();//取结束时间

System.out.println("一共运行了" + (end - begin) + "毫秒");

if(ir.getSucceedSettings().length>0)

{

               System.out.println("ImportTIF file to oracle succeed!");

}

else{

System.out.println("ImportTIF file to oracle fail!");

}

} catch (Exception e) {

System.out.println(e.getMessage());//抛出异常

}


}



}


你可能感兴趣的:(tif数据导入到oracle 数据库demo)