-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWMTSRepository.cpp
More file actions
138 lines (115 loc) · 2.77 KB
/
WMTSRepository.cpp
File metadata and controls
138 lines (115 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "StdAfx.h"
#include <io.h>
#include <sstream>
#include "WMTSRepository.h"
#include "WMTSLayer.h"
#include "Tile.h"
#include "WMTSLevel.h"
#include <iostream>
#include <algorithm>
#include "WMTSConfig.h"
#include <CLogThreadMgr.h>
#include "curl/curl.h"
#include "json/json.h"
#pragma warning(once:4996)
using namespace thp;
WMTSRepository::WMTSRepository()
{
m_layers = NULL;
_initLogWriter();
}
WMTSRepository::~WMTSRepository()
{
struct TLayerHashTableNode* s = NULL;
struct TLayerHashTableNode* tmp = NULL;
HASH_ITER(hh, m_layers, s, tmp)
{
std::cout << "释放图层[" << s->szName << "]资源" << std::endl;
HASH_DEL(m_layers, s);
WMTSLayer* pLayer = s->pLayer;
delete pLayer;
free(s);
}
}
bool WMTSRepository::_initLogWriter()
{
// 获取写日志对象
m_pLogWriter = CLogThreadMgr::instance()->getLogWriter("WMTSRepository.log");
// 如果不存在,创建日志文件,加载日志配置
if (m_pLogWriter == NULL)
{
CLogAppender * pLogAppender = new CLogAppender("WMTSRepository", "WMTSRepository.log", "", "DebugLog");
// 获取写日志对象
m_pLogWriter = CLogThreadMgr::instance()->createLogWriter(pLogAppender);
}
return true;
}
unsigned int thp::WMTSRepository::getTile(const std::string& strLayer, int nLvl, int nRow, int nCol, QByteArray& arTile, int& nDetail)
{
TLayerHashTableNode* pLyrNode = NULL;
HASH_FIND_STR(m_layers, strLayer.c_str(), pLyrNode);
if(NULL == pLyrNode)
return 0;
WMTSLayer* pLayer = pLyrNode->pLayer;
if(NULL == pLayer)
{
m_pLogWriter->errorLog("资源错误");
return 0;
}
return pLayer->getTile(nLvl, nRow, nCol, arTile, nDetail);
}
//int thp::WMTSRepository::loadData(const std::string& strLayer, int nLvl)
//{
// TLayerHashTableNode* pLyrNode = NULL;
// HASH_FIND_STR(m_layers, strLayer.c_str(), pLyrNode);
// if(NULL == pLyrNode)
// {
// return 2;
// }
//
// WMTSLayer* pLayer = pLyrNode->pLayer;
// if(NULL == pLayer)
// {
// return 2;
// }
//
// return pLayer->loadData(nLvl);
//}
std::string thp::WMTSRepository::getCapabilities()
{
QString qsPath = WMTSConfig::Instance()->getDataDir();
std::string sPath = (const char*)qsPath.toLocal8Bit();
sPath.append(WMTS_REQUEST_VL_CAPABILITIES);
sPath.append(".xml");
return sPath;
}
void thp::WMTSRepository::showStatus()
{
TLayerHashTableNode* p = NULL,* pTemp = NULL;
HASH_ITER(hh, m_layers, p, pTemp)
{
WMTSLayer* pLayer = p->pLayer;
pLayer->showStatus();
}
}
int thp::WMTSRepository::getLayerCount() const
{
int nLayerCount = HASH_COUNT(m_layers);
return nLayerCount;
}
WMTSLayer* thp::WMTSRepository::getLayer(int nIndex) const
{
WMTSLayer* pLayer = NULL;
int i = 0;
TLayerHashTableNode* p = NULL,* pTemp = NULL;
HASH_ITER(hh, m_layers, p, pTemp)
{
if(i == nIndex)
{
pLayer = p->pLayer;
break;
}
++i;
}
return pLayer;
}