dmptilematrixset.cpp
2.3 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
/**************************************************************************
* file: dmptilematrixset.cpp
* Author: wanzhongping
* Date: 2021-11-16 15:52:48
* Email: zhongpingw@chinadci.com
* copyright: 广州城市信息研究所有限公司
***************************************************************************/
#include "dmptilematrixset.h"
#include <iostream>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/typeof/typeof.hpp>
DmpTileMatrixSet::DmpTileMatrixSet()
{
tileCols_ = 256;
tileRows_ = 256;
dpi_ = 96;
}
DmpTileMatrixSet::~DmpTileMatrixSet()
{
if (tileOrigin_)
{
delete tileOrigin_;
tileOrigin_ = nullptr;
}
std::vector<TileLevel *>::iterator iter = tileLevels_.begin();
for (; iter != tileLevels_.end(); ++iter)
{
if (*iter != NULL)
{
delete *iter;
*iter = NULL;
}
}
tileLevels_.clear();
}
bool DmpTileMatrixSet::readXml(const boost::property_tree::ptree &matrixSetNode)
{
try
{
id_ = matrixSetNode.get<std::string>("id");
crs_ = matrixSetNode.get<std::string>("crs");
tileCols_ = matrixSetNode.get<int>("tileCols");
tileRows_ = matrixSetNode.get<int>("tileRows");
dpi_ = matrixSetNode.get<int>("dpi");
double x = matrixSetNode.get<double>("tileOrigin.X");
double y = matrixSetNode.get<double>("tileOrigin.Y");
tileOrigin_ = new DmpPoint(x, y);
boost::property_tree::ptree pLevels = matrixSetNode.get_child("levels");
for (BOOST_AUTO(pos, pLevels.begin()); pos != pLevels.end(); ++pos)
{
boost::property_tree::ptree pLevel = pos->second;
TileLevel *tileLevel = new TileLevel();
tileLevel->id = pLevel.get<int>("id");
tileLevel->scaleDenominator = pLevel.get<double>("scaleDenominator");
tileLevel->resolution = pLevel.get<double>("resolution");
tileLevels_.push_back(tileLevel);
}
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
return false;
}
return true;
}
bool DmpTileMatrixSet::writeXml(boost::property_tree::ptree &matrixSetNode)
{
return false;
}