需要将tif数据导入到数据源中,如果这个操作是一次性的,建议直接在idesktop中先将数据导入,地图制作好,组件直接打开地图进行渲染即可,如果需要在c++组件层去实现,可以参考下面的代码:
// TODO: 在此添加命令处理程序代码
UGWorkspace* pWorkspace = (UGWorkspace*)m_pMapControl->GetMapEditWnd()->m_mapWnd.m_Map.GetWorkspace();
UGDataExchange exchange = UGDataExchange();
UGDataSource* ds = pWorkspace->GetDataSource(0);
if (!ds)
{
return;
}
int issu = exchange.AttachDataSource(ds);
UGGTiffImportParams importparams = UGGTiffImportParams();
UGString NAME = ds->GetUnoccupiedDatasetName(_U("TIF"));
importparams.SetDestDTName(NAME);
importparams.SetFilePathName(_U("C:\\Users\\86182\\Desktop\\c++导入数据测试数据\\data\\tif\\dsm_4.tif"));
UGint ii = importparams.GetFileType();
int ss = UGExchangeParamsManager::IsValidImportParams(ii, importparams);
UGint issucceed = exchange.Import(importparams);
if (issucceed == 1)
{
UGDatasetRaster* dataset = (UGDatasetRaster*)ds->GetDataset(NAME);
dataset->BuildPyramid(false);
UGLayer* layer = m_pMapControl->GetMapEditWnd()->m_mapWnd.m_Map.m_Layers.AddDataset(dataset, true);
m_pMapControl->GetMapEditWnd()->m_mapWnd.m_Map.SetViewBounds(layer->GetBounds(), true);
m_pMapControl->Refresh();
}
else
{
//QMessageBox::information(NULL, QString::fromLocal8Bit("导入shp"), QString::fromLocal8Bit("导入失败"), QMessageBox::Close, QMessageBox::Close);
}