Repository navigation
Expand file tree
/
Copy pathWMTSLevel.cpp
More file actions
84 lines (64 loc) · 1.49 KB
/
Copy pathWMTSLevel.cpp
File metadata and controls
84 lines (64 loc) · 1.49 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
#include "WMTSLevel.h"
#include <math.h>
#include <memory.h>
#include <io.h>
#include "Bundle.h"
#include "BundleReader.h"
#include "bdi/bdiapi.h"
#include "WMTSFactory.h"
#pragma warning(once:4996)
using namespace thp;
WMTSLevel::WMTSLevel(int nLv)
{
m_nLvl = nLv;
memset(m_szPath, 0, THP_MAX_PATH);
m_pszBit = NULL;
}
WMTSLevel::~WMTSLevel()
{
if(NULL != m_pszBit)
{
delete[] m_pszBit;
m_pszBit = NULL;
}
}
bool WMTSLevel::setPath(const char* szPath)
{
unsigned int unLen = strlen(szPath);
if(0 == unLen || unLen > THP_MAX_PATH)
return false;
memcpy(m_szPath, szPath, unLen);
return true;
}
bool thp::WMTSLevel::exist(const TBundleIDex& tbno)
{
return ::isExist(m_pszBit, tbno.tID.unBundleIDinLv);
}
std::tr1::shared_ptr<Bundle> thp::WMTSLevel::getBundle(const TBundleIDex& tbno)
{
// 检查索引,看bundle文件是否存在
if( !::isExist(m_pszBit, tbno.tID.unBundleIDinLv) )
{
std::tr1::shared_ptr<Bundle> sp;
return sp;
}
// 生成新的 bundle 读取 bundle
char szBundleFile[THP_MAX_PATH];
memset(szBundleFile, 0, THP_MAX_PATH);
int nXR = 128 * tbno.nBundleRow;
int nXC = 128 * tbno.nBundleCol;
sprintf(szBundleFile, "%sR%04xC%04x.bundle", m_szPath, nXR, nXC);
std::tr1::shared_ptr<Bundle> sp( WMTSFactory::Instance()->createBundle(tbno) );
sp->open( szBundleFile );
return sp;
}
void WMTSLevel::setBdi(int nSize, unsigned char* szbdi)
{
if( NULL != m_pszBit)
{
delete[] m_pszBit;
m_pszBit = NULL;
}
m_pszBit = new unsigned char[nSize];
memcpy(m_pszBit, szbdi, nSize);
}