|
|
#include "mapdatamaneger.h"
|
|
|
|
|
|
#include "translator.h"
|
|
|
|
|
|
MapDataManeger::MapDataManeger()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
//工作空间另存为
|
|
|
UGbool MapDataManeger::saveWorkSpace(UGWorkspace *m_pWorkspace, UGString filePath)
|
|
|
{
|
|
|
//工作空间连接信息
|
|
|
UGWorkspaceConnection wsCon;
|
|
|
wsCon.m_nWorkspaceType = UGWorkspace::UGWorkspaceType::WS_Version_SMWU;
|
|
|
wsCon.m_strServer = filePath;
|
|
|
wsCon.m_nVersion = m_pWorkspace->GetVersion();
|
|
|
m_pWorkspace->m_WorkspaceConnection = wsCon; //保存工作空间连接信息
|
|
|
//工作空间另存为
|
|
|
UGbool bSuc = m_pWorkspace->SaveAs(wsCon);
|
|
|
return bSuc;
|
|
|
}
|
|
|
|
|
|
//新建数据源
|
|
|
UGDataSource *MapDataManeger::createDataSource(QString dsAlias, UGEngineType nEngineType, QString filePath)
|
|
|
{
|
|
|
//创建数据源实例对象
|
|
|
UGDataSource* pDataSource = UGDataSourceManager::CreateDataSource(nEngineType);
|
|
|
//设置数据源连接信息
|
|
|
UGDsConnection pCon;
|
|
|
pCon.m_nType = nEngineType;//数据源类型
|
|
|
if(nEngineType == UGEngineType::Spatialite)
|
|
|
pCon.m_strServer = Translator::QStr2UGStr(filePath+dsAlias+".udbx");//udbx地址
|
|
|
pCon.m_strAlias = Translator::QStr2UGStr(dsAlias);
|
|
|
pDataSource->GetConnectionInfo() = pCon;
|
|
|
//创建数据源
|
|
|
UGbool ss = pDataSource->Create();
|
|
|
|
|
|
if(ss)
|
|
|
{
|
|
|
pDataSource->SetPrjCoordSys(UGPrjCoordSys(4326));//设置坐标系为WGS1984
|
|
|
return pDataSource;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//创建矢量数据集
|
|
|
UGDatasetVectorPtr MapDataManeger::createVectorSet(UGDataSource *ds, UGDataset::DatasetType m_nType, UGString alias, int ProjEPSGCode)
|
|
|
{
|
|
|
UGDatasetVectorInfo vectorInfo;
|
|
|
vectorInfo.m_nType = m_nType; //数据集类型
|
|
|
vectorInfo.m_strName = alias; //数据集名称(别名)
|
|
|
vectorInfo.m_nPRJSrid = ProjEPSGCode; //坐标系,默认为WGS-84
|
|
|
return ds->CreateDatasetVector(vectorInfo);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//UGLayer3D *MapDataManeger::createTemporaryLayer3D(UGDataSource *ds, UGLayer3Ds *pLayers, UGint nUGLayerType, UGString datasetName)
|
|
|
//{
|
|
|
|
|
|
//}
|