本文整理汇总了C++中Loader::loadTile方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::loadTile方法的具体用法?C++ Loader::loadTile怎么用?C++ Loader::loadTile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::loadTile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void* ExplodeTask::run()
{
Loader ld;
std::string sErrMsg;
std::shared_ptr<Tile> spTile(new Tile);
std::string sOutFile;
std::stringstream ss;
ss << Config::Instance()->getOutDir() << "/" << m_nLevel << "/" << m_nCol;
checkDestination(ss.str());
ss << "/" << m_nRow << "." <<
Config::Instance()->getSuffix();
sOutFile = ss.str();
bool bSuccess = false;
long lCurlcode = 200;
if (R_SUCCESS == ld.loadTile(m_sUrlTemplate, m_nLevel, m_nRow, m_nCol, spTile.get(), lCurlcode))
{
std::string sBuffer((char*)(spTile->pData), spTile->nSize);
std::ofstream streamOutFile(sOutFile, std::ios_base::out | std::ios_base::binary);
streamOutFile << sBuffer;
streamOutFile.close();
bSuccess = true;
}
else
{
// 将获取不到矢量切片直接写入日志
if (lCurlcode == 403 || lCurlcode == 404)
{
sErrMsg = ld.getUrl(m_sUrlTemplate, m_nLevel, m_nRow, m_nCol);
}
else
{
int nSeconds = 0;
while (1)
{
if (nSeconds > 10)
{
sErrMsg = ld.getUrl(m_sUrlTemplate, m_nLevel, m_nRow, m_nCol);
break;
}
Sleep(1000);
if (R_SUCCESS == ld.loadTile(m_sUrlTemplate, m_nLevel, m_nRow, m_nCol, spTile.get(), lCurlcode))
{
std::string sBuffer((char*)(spTile->pData), spTile->nSize);
std::ofstream streamOutFile(sOutFile, std::ios_base::out | std::ios_base::binary);
streamOutFile << sBuffer;
streamOutFile.close();
bSuccess = true;
break;
}
if (lCurlcode == 403 || lCurlcode == 404)
{
sErrMsg = ld.getUrl(m_sUrlTemplate, m_nLevel, m_nRow, m_nCol);
break;
}
++nSeconds;
}
}
}
if (m_pProgress)
{
if (bSuccess)
{
// 成功,设置进度
m_pProgress->addNow(1);
}
else
{
// 失败,设置进度并记录失败的数据
m_pProgress->addFail(1);
// 写一条错误日志
LOG(ERROR) << "下载瓦片失败" << sErrMsg;
}
}
spTile->clear();
return NULL;
}