首页 / 浏览问题 / 组件GIS / 问题详情
已经按照您的示范代码,加到程序里去,在Import时返回值为-1
2EXP 2021年01月14日
以下是将要导入的tif文件:

链接:https://pan.baidu.com/s/1kq5t6KH71mwf3vT0gPYvwg
提取码:fafh
复制这段内容后打开百度网盘手机App,操作更方便哦--来自百度网盘超级会员V1的分享

以下是我的代码:

UGWorkspace* pWorkspace = new UGWorkspace();
    UGMap* pMap = qMapControl->GetMap();

    pMap->SetLineSmoothingMode(false);
    if (pWorkspace == NULL || pMap == NULL )
    {
        QMessageBox::critical(this,"ERROR",QString::fromLocal8Bit("初始化失败!"));
        return;
    }

    QString qStrPath = QFileDialog::getOpenFileName(this,("OpenWorkSpace"), "../data", ("SuperMapWorkspace(*.sxwu *.smwu)"));
    if(pWorkspace->Open(Translator::QStr2UGStr(qStrPath)))
    {
        pMap->SetWorkspace(pWorkspace);
    }
    else
    {
        QMessageBox::critical(this,"ERROR",QString::fromLocal8Bit("工作空间打开失败!"));
        return;
    }

    UGWorkspace* m_pWorkspace = pMap->GetWorkspace();
    UGDataExchange exchange = UGDataExchange();
    UGDataSource* ds = m_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("\\home\\wh\\WPT\\Tif\\2007200836.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 = qMapControl->GetMapEditWnd()->m_mapWnd.m_Map.m_Layers.AddDataset(dataset, true);
        //qMapControl->GetMapEditWnd()->m_mapWnd.m_Map.SetViewBounds(layer->GetBounds(), true);
        qMapControl->Refresh();
    }
    else
    {
        //QMessageBox::information(NULL, QString::fromLocal8Bit("导入shp"), QString::fromLocal8Bit("导入失败"), QMessageBox::Close, QMessageBox::Close);
    }

    qMapControl->SetEditEnvironment();
    qMapControl->Refresh();

问题出在:UGint issucceed = exchange.Import(importparams);处,返回值issucceed一直是-1,导入失败

1个回答

测试后给你回复
4,620EXP 2021年01月14日
...