提交 8dd6afff55ae40496c2835c1cf5d86dc41e999b7
Merge branch 'master' of http://gitlab.ctune.cn/DMapServer/DMapServer4.1
正在显示
21 个修改的文件
包含
866 行增加
和
72 行删除
@@ -41,9 +41,9 @@ bool DmpTileLayer::readXml(const boost::property_tree::ptree &layerNode) | @@ -41,9 +41,9 @@ bool DmpTileLayer::readXml(const boost::property_tree::ptree &layerNode) | ||
41 | extent_ = DmpXmlUtils::readRectangle(pExtent); | 41 | extent_ = DmpXmlUtils::readRectangle(pExtent); |
42 | style_ = layerNode.get<std::string>("style"); | 42 | style_ = layerNode.get<std::string>("style"); |
43 | format_ = layerNode.get<std::string>("format"); | 43 | format_ = layerNode.get<std::string>("format"); |
44 | - vector_ = layerNode.get<std::string>("vector"); | 44 | + vector_ = layerNode.get<std::string>("vendor"); |
45 | datasource_ = layerNode.get<std::string>("datasource"); | 45 | datasource_ = layerNode.get<std::string>("datasource"); |
46 | - | 46 | + if(strcmp(vector_.c_str(),"QGIS")==0)return true; |
47 | boost::property_tree::ptree pMatrixSets = layerNode.get_child("tileMatrixSets"); | 47 | boost::property_tree::ptree pMatrixSets = layerNode.get_child("tileMatrixSets"); |
48 | for (BOOST_AUTO(pos, pMatrixSets.begin()); pos != pMatrixSets.end(); ++pos) | 48 | for (BOOST_AUTO(pos, pMatrixSets.begin()); pos != pMatrixSets.end(); ++pos) |
49 | { | 49 | { |
@@ -72,11 +72,23 @@ bool DmpTileLayer::writeXml(boost::property_tree::ptree &layerNode) | @@ -72,11 +72,23 @@ bool DmpTileLayer::writeXml(boost::property_tree::ptree &layerNode) | ||
72 | { | 72 | { |
73 | return false; | 73 | return false; |
74 | } | 74 | } |
75 | -std::string DmpTileLayer::GetVector() | 75 | +std::string DmpTileLayer::getVector() |
76 | { | 76 | { |
77 | return vector_; | 77 | return vector_; |
78 | } | 78 | } |
79 | -std::string DmpTileLayer::GetDataSource() | 79 | +std::string DmpTileLayer::getDataSource() |
80 | { | 80 | { |
81 | return datasource_; | 81 | return datasource_; |
82 | -} | ||
82 | +} | ||
83 | +void DmpTileLayer::getTileMatrixSets(std::vector<DmpTileMatrixSet*>& tileMatrixSets ) | ||
84 | +{ | ||
85 | + tileMatrixSets=tileMatrixSets_; | ||
86 | +} | ||
87 | +std::string DmpTileLayer::getFormat() | ||
88 | +{ | ||
89 | + return format_; | ||
90 | +} | ||
91 | +std::string DmpTileLayer::getStyle() | ||
92 | +{ | ||
93 | + return style_; | ||
94 | +} |
@@ -22,8 +22,11 @@ public: | @@ -22,8 +22,11 @@ public: | ||
22 | 22 | ||
23 | bool readXml(const boost::property_tree::ptree &layerNode); | 23 | bool readXml(const boost::property_tree::ptree &layerNode); |
24 | bool writeXml(boost::property_tree::ptree &layerNode); | 24 | bool writeXml(boost::property_tree::ptree &layerNode); |
25 | - std::string GetVector(); | ||
26 | - std::string GetDataSource(); | 25 | + std::string getVector(); |
26 | + std::string getDataSource(); | ||
27 | + void getTileMatrixSets(std::vector<DmpTileMatrixSet*>& tileMatrixSets); | ||
28 | + std::string getFormat(); | ||
29 | + std::string getStyle(); | ||
27 | 30 | ||
28 | private: | 31 | private: |
29 | std::string style_; | 32 | std::string style_; |
@@ -37,6 +37,8 @@ SET (DMAP_SERVER_SRCS | @@ -37,6 +37,8 @@ SET (DMAP_SERVER_SRCS | ||
37 | python/dmppythonutils.cpp | 37 | python/dmppythonutils.cpp |
38 | python/dmpserverwrapper.cpp | 38 | python/dmpserverwrapper.cpp |
39 | dmppgsqlutils.cpp | 39 | dmppgsqlutils.cpp |
40 | + dmphttpbase.cpp | ||
41 | + dmphttputils.cpp | ||
40 | ) | 42 | ) |
41 | 43 | ||
42 | SET (DMAP_SERVER_HDRS | 44 | SET (DMAP_SERVER_HDRS |
@@ -66,6 +68,8 @@ SET (DMAP_SERVER_HDRS | @@ -66,6 +68,8 @@ SET (DMAP_SERVER_HDRS | ||
66 | dmpserverregistry.h | 68 | dmpserverregistry.h |
67 | python/dmppythonutils.h | 69 | python/dmppythonutils.h |
68 | dmppgsqlutils.h | 70 | dmppgsqlutils.h |
71 | + dmphttpbase.h | ||
72 | + dmphttputils.h | ||
69 | ) | 73 | ) |
70 | 74 | ||
71 | ############################################################# | 75 | ############################################################# |
src/server/dmphttpbase.cpp
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmphttpbase.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmphttpbase.h" | ||
10 | + | ||
11 | +#define HTTP_JSON_BEGIN ("[") | ||
12 | +#define HTTP_JSON_END ("]") | ||
13 | + | ||
14 | +DmpHttp::DmpHttpBase::DmpHttpBase(){} | ||
15 | +DmpHttp::DmpHttpBase::~DmpHttpBase(){} | ||
16 | +int DmpHttp::DmpHttpBase::parseUrl(const std::string& url, std::string& out_server, | ||
17 | + std::string& out_port, std::string& out_path){ | ||
18 | +const std::string& http_ = "http://"; | ||
19 | +const std::string& https_ = "https://"; | ||
20 | +std::string temp_data = url; | ||
21 | +if (temp_data.find(http_) == 0) { | ||
22 | + temp_data = temp_data.substr(http_.length()); | ||
23 | + } | ||
24 | + else if (temp_data.find(https_) == 0) { | ||
25 | + temp_data = temp_data.substr(https_.length()); | ||
26 | + } | ||
27 | + else { | ||
28 | + return HTTP_ERROR_HTTP_HEAD; | ||
29 | + } | ||
30 | + // 解析域名 | ||
31 | + std::size_t idx = temp_data.find('/'); | ||
32 | + // 解析 域名后的page | ||
33 | + if (std::string::npos == idx) { | ||
34 | + out_path = "/"; | ||
35 | + idx = temp_data.size(); | ||
36 | + } | ||
37 | + else { | ||
38 | + out_path = temp_data.substr(idx); | ||
39 | + } | ||
40 | + // 解析域名 | ||
41 | + out_server = temp_data.substr(0, idx); | ||
42 | + // 解析端口 | ||
43 | + idx = out_server.find(':'); | ||
44 | + if (std::string::npos == idx) { | ||
45 | + out_port = "80"; | ||
46 | + } | ||
47 | + else { | ||
48 | + out_port = out_server.substr(idx + 1); | ||
49 | + out_server = out_server.substr(0, idx); | ||
50 | + } | ||
51 | + return HTTP_SUCCESS; | ||
52 | +} | ||
53 | + | ||
54 | +int DmpHttp::DmpHttpBase::buildPostRequest(const std::string& server, const std::string& path, | ||
55 | + std::ostream& out_request) { | ||
56 | + // 分割path中的json数据 | ||
57 | + std::string temp_path(path), temp_json; | ||
58 | + int json_pos_begin = temp_path.find(HTTP_JSON_BEGIN) + 1; | ||
59 | + int json_pos_end = temp_path.find(HTTP_JSON_END); | ||
60 | + if (json_pos_begin != std::string::npos) { | ||
61 | + // 计算json的长度 | ||
62 | + int temp_json_lenth = std::string::npos; | ||
63 | + if (json_pos_end != temp_json_lenth) { | ||
64 | + temp_json_lenth = (json_pos_end - json_pos_begin); | ||
65 | + } | ||
66 | + temp_json = temp_path.substr(json_pos_begin, temp_json_lenth); | ||
67 | + temp_path = temp_path.substr(0, (json_pos_begin - 1)); | ||
68 | + } | ||
69 | + out_request << "POST " << temp_path.c_str() << " HTTP/1.0\r\n"; | ||
70 | + out_request << "Host: " << server.c_str() << "\r\n"; | ||
71 | + out_request << "Content-Length: " << temp_json.length() << "\r\n"; | ||
72 | + out_request << "Content-Type: application/x-www-form-urlencoded\r\n"; | ||
73 | + out_request << "Accept: */*\r\n"; | ||
74 | + out_request << "Connection: close\r\n\r\n"; | ||
75 | + out_request << temp_json.c_str(); | ||
76 | + return HTTP_SUCCESS; | ||
77 | +} | ||
78 | + | ||
79 | +int DmpHttp::DmpHttpBase::buildGetRequest(const std::string& server, const std::string& path, | ||
80 | + std::ostream& out_request) { | ||
81 | + out_request << "GET " << path.c_str() << " HTTP/1.0\r\n"; | ||
82 | + out_request << "Host: " << server.c_str() << "\r\n"; | ||
83 | + out_request << "Accept: */*\r\n"; | ||
84 | + out_request << "Connection: close\r\n\r\n"; | ||
85 | + return HTTP_SUCCESS; | ||
86 | +} |
src/server/dmphttpbase.h
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmphttpbase.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmphttpbase_h__ | ||
10 | +#define __dmphttpbase_h__ | ||
11 | +#include <iostream> | ||
12 | +#include <boost/asio.hpp> | ||
13 | +namespace DmpHttp | ||
14 | +{ | ||
15 | + #define HTTP_SUCCESS (0) // 操作成功 | ||
16 | + #define HTTP_ERROR_UNKNOWN (-1) // 未知的错误 | ||
17 | + #define HTTP_ERROR_NETWORK (-2) // 网络连接失败 | ||
18 | + #define HTTP_ERROR_HTTP_HEAD (-3) // 未找到协议头 http || https | ||
19 | + | ||
20 | + #define HTTP_ERROR_SERVICE (-1000) // 服务器请求失败 | ||
21 | + #define HTTP_ERROR_LOGIN (-1001) // 登录失败 | ||
22 | + #define HTTP_ERROR_ID (-1002) // 企业ID错误 | ||
23 | + #define HTTP_ERROR_USER (-1003) // 帐号不存在 | ||
24 | + #define HTTP_ERROR_PASSWORD (-1004) // 密码错误 | ||
25 | + | ||
26 | + #define HTTP_ERROR_PARAMETER (1) // 参数错误 | ||
27 | + #define HTTP_ERROR_PHONE (2) // 电话号码错误 | ||
28 | + #define HTTP_ERROR_MESSAGE (3) // 短信有屏蔽字段 | ||
29 | + #define HTTP_ERROR_FUNCTION (4) // 当前平台不支持这个功能 | ||
30 | + | ||
31 | + class DmpHttpBase | ||
32 | + { | ||
33 | + public: | ||
34 | + DmpHttpBase(); | ||
35 | + virtual ~DmpHttpBase(); | ||
36 | + // Post请求 | ||
37 | + virtual int post(const std::string& url) = 0; | ||
38 | + // get请求 | ||
39 | + virtual int get(const std::string& url) = 0; | ||
40 | + virtual std::string getResponse(void) = 0; | ||
41 | + | ||
42 | + protected: | ||
43 | + typedef int(*pBuildRequest)(const std::string&, const std::string&,std::ostream&); | ||
44 | + | ||
45 | + static int parseUrl(const std::string& url, std::string& out_server, | ||
46 | + std::string& out_port, std::string& out_path); | ||
47 | + static int buildPostRequest(const std::string& server, const std::string& path, | ||
48 | + std::ostream& out_request); | ||
49 | + static int buildGetRequest(const std::string& server, const std::string& path, | ||
50 | + std::ostream& out_request); | ||
51 | + }; | ||
52 | +} | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | + | ||
57 | +#endif //__dmphttpbase_h__ |
src/server/dmphttputils.cpp
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmphttputils.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmphttputils.h" | ||
10 | +#include <boost/bind.hpp> | ||
11 | + | ||
12 | +DmpHttp::DmpHttpUtils::DmpHttpUtils(boost::asio::io_service& io_service) | ||
13 | +: resolver_(io_service), socket_(io_service) {} | ||
14 | +DmpHttp::DmpHttpUtils::~DmpHttpUtils() {} | ||
15 | + | ||
16 | +int DmpHttp::DmpHttpUtils::post(const std::string& url) | ||
17 | +{ | ||
18 | + handle_request_resolve(url, DmpHttpBase::buildPostRequest); | ||
19 | + return HTTP_SUCCESS; | ||
20 | +} | ||
21 | +int DmpHttp::DmpHttpUtils::get(const std::string& url) | ||
22 | +{ | ||
23 | + handle_request_resolve(url, DmpHttpBase::buildGetRequest); | ||
24 | + return HTTP_SUCCESS; | ||
25 | +} | ||
26 | +void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuildRequest func) { | ||
27 | + try { | ||
28 | + responseData_.clear(); | ||
29 | + // 解析URL | ||
30 | + std::string server, port, path; | ||
31 | + parseUrl(url, server, port, path); | ||
32 | + | ||
33 | + std::ostream request_stream(&request_); | ||
34 | + // 合成请求 | ||
35 | + func(server, path, request_stream); | ||
36 | + | ||
37 | + // 解析服务地址\端口 | ||
38 | + boost::asio::ip::tcp::resolver::query query(server, port); | ||
39 | + resolver_.async_resolve(query, | ||
40 | + boost::bind(&DmpHttpUtils::handle_resolve, this, | ||
41 | + boost::asio::placeholders::error, | ||
42 | + boost::asio::placeholders::iterator)); | ||
43 | + } | ||
44 | + catch (std::exception& e) { | ||
45 | + socket_.close(); | ||
46 | + std::cout << "Exception: " << e.what() << "\n"; | ||
47 | + } | ||
48 | + return; | ||
49 | +} | ||
50 | +void DmpHttp::DmpHttpUtils::handle_resolve(const boost::system::error_code& err, | ||
51 | + boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { | ||
52 | + if (err) { | ||
53 | + std::cout << "Error: " << err << "\n"; | ||
54 | + return; | ||
55 | + } | ||
56 | + // 尝试连接 | ||
57 | + boost::asio::async_connect(socket_, endpoint_iterator, | ||
58 | + boost::bind(&DmpHttpUtils::handle_connect, this, | ||
59 | + boost::asio::placeholders::error)); | ||
60 | +} | ||
61 | +void DmpHttp::DmpHttpUtils::handle_connect(const boost::system::error_code& err) { | ||
62 | + if (err) { | ||
63 | + std::cout << "Error: " << err << "\n"; | ||
64 | + return; | ||
65 | + } | ||
66 | + // 发送request请求 | ||
67 | + boost::asio::async_write(socket_, request_, | ||
68 | + boost::bind(&DmpHttpUtils::handle_write_request, this, | ||
69 | + boost::asio::placeholders::error)); | ||
70 | +} | ||
71 | +void DmpHttp::DmpHttpUtils::handle_write_request(const boost::system::error_code& err) { | ||
72 | + if (err) { | ||
73 | + std::cout << "Error: " << err << "\n"; | ||
74 | + return; | ||
75 | + } | ||
76 | + // 异步持续读数据到response_,直到接收协议符号 \r\n 为止 | ||
77 | + boost::asio::async_read_until(socket_, response_, "\r\n", | ||
78 | + boost::bind(&DmpHttpUtils::handle_read_status_line, this, | ||
79 | + boost::asio::placeholders::error)); | ||
80 | +} | ||
81 | +void DmpHttp::DmpHttpUtils::handle_read_status_line(const boost::system::error_code& err) { | ||
82 | + if (err) { | ||
83 | + std::cout << "Error: " << err << "\n"; | ||
84 | + return; | ||
85 | + } | ||
86 | + // 解析buff | ||
87 | + std::istream response_stream(&response_); | ||
88 | + unsigned int status_code; | ||
89 | + std::string http_version, status_message; | ||
90 | + response_stream >> http_version; | ||
91 | + response_stream >> status_code; | ||
92 | + std::getline(response_stream, status_message); | ||
93 | + | ||
94 | + // 核对是否是正确返回 | ||
95 | + if (!response_stream || http_version.substr(0, 5) != "HTTP/") { | ||
96 | + std::cout << "错误的响应数据\n"; | ||
97 | + return; | ||
98 | + } | ||
99 | + if (status_code != 200) { | ||
100 | + std::cout << "服务器响应的状态码: " << status_code << "\n"; | ||
101 | + return; | ||
102 | + } | ||
103 | + // 读取响应头,直到接收协议符号 \r\n\r\n 为止 | ||
104 | + boost::asio::async_read_until(socket_, response_, "\r\n\r\n", | ||
105 | + boost::bind(&DmpHttpUtils::handle_read_headers, this, | ||
106 | + boost::asio::placeholders::error)); | ||
107 | +} | ||
108 | + | ||
109 | +void DmpHttp::DmpHttpUtils::handle_read_headers(const boost::system::error_code& err) { | ||
110 | + if (err) { | ||
111 | + std::cout << "Error: " << err << "\n"; | ||
112 | + return; | ||
113 | + } | ||
114 | + // 输出响应头 | ||
115 | + std::istream response_stream(&response_); | ||
116 | + std::string header; | ||
117 | + while (std::getline(response_stream, header) && header != "\r") { | ||
118 | +#ifdef _DEBUG | ||
119 | + std::cout << header << "\n"; | ||
120 | +#endif | ||
121 | + } | ||
122 | +#ifdef _DEBUG | ||
123 | + std::cout << "\n"; | ||
124 | +#endif | ||
125 | + | ||
126 | + // 写完所有剩余的内容 | ||
127 | + if (response_.size() > 0) { | ||
128 | + boost::asio::streambuf::const_buffers_type cbt = response_.data(); | ||
129 | + responseData_ += std::string(boost::asio::buffers_begin(cbt), boost::asio::buffers_end(cbt)); | ||
130 | +#ifdef _DEBUG | ||
131 | + std::cout << &response_; | ||
132 | +#endif | ||
133 | + } | ||
134 | + | ||
135 | + // 开始读取剩余所有内容 | ||
136 | + boost::asio::async_read(socket_, response_, | ||
137 | + boost::asio::transfer_at_least(1), | ||
138 | + boost::bind(&DmpHttpUtils::handle_read_content, this, | ||
139 | + boost::asio::placeholders::error)); | ||
140 | +} | ||
141 | +void DmpHttp::DmpHttpUtils::handle_read_content(const boost::system::error_code& err) { | ||
142 | + if (!err) { | ||
143 | + | ||
144 | + // 输出读到的数据 | ||
145 | + boost::asio::streambuf::const_buffers_type cbt = response_.data(); | ||
146 | + | ||
147 | + responseData_ = std::string(boost::asio::buffers_begin(cbt), boost::asio::buffers_end(cbt)); | ||
148 | +#ifdef _DEBUG | ||
149 | + std::cout << &response_; | ||
150 | +#endif | ||
151 | + | ||
152 | + // 继续读取剩余内容,直到读到EOF | ||
153 | + boost::asio::async_read(socket_, response_, | ||
154 | + boost::asio::transfer_at_least(1), | ||
155 | + boost::bind(&DmpHttpUtils::handle_read_content, this, | ||
156 | + boost::asio::placeholders::error)); | ||
157 | + | ||
158 | + } | ||
159 | + else if (err != boost::asio::error::eof) { | ||
160 | + std::cout << "Error: " << err << "\n"; | ||
161 | + } | ||
162 | + else { | ||
163 | + socket_.close(); | ||
164 | + resolver_.cancel(); | ||
165 | + std::cout << "读取响应数据完毕." << std::endl; | ||
166 | + //std::cout << responseData_; | ||
167 | + } | ||
168 | +} | ||
169 | + | ||
170 | + | ||
171 | +std::string DmpHttp::post(std::string url) { | ||
172 | + boost::asio::io_service io; | ||
173 | + DmpHttp::DmpHttpUtils c(io); | ||
174 | + c.post(url); | ||
175 | + io.run(); | ||
176 | + return c.getResponse(); | ||
177 | +} | ||
178 | + | ||
179 | +std::string DmpHttp::get(std::string url) { | ||
180 | + boost::asio::io_service io; | ||
181 | + DmpHttp::DmpHttpUtils c(io); | ||
182 | + c.get(url); | ||
183 | + io.run(); | ||
184 | + return c.getResponse(); | ||
185 | +} |
src/server/dmphttputils.h
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmphttputils.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmppghttputils_h__ | ||
10 | +#define __dmppghttputils_h__ | ||
11 | +#include <iostream> | ||
12 | +#include <boost/asio.hpp> | ||
13 | +#include "dmphttpbase.h" | ||
14 | + | ||
15 | +namespace DmpHttp | ||
16 | +{ | ||
17 | + class DmpHttpUtils : public DmpHttpBase | ||
18 | + { | ||
19 | + public: | ||
20 | + DmpHttpUtils(boost::asio::io_service& io_service); | ||
21 | + virtual ~DmpHttpUtils(); | ||
22 | + virtual int post(const std::string& url); | ||
23 | + virtual int get(const std::string& url); | ||
24 | + | ||
25 | + virtual std::string getResponse(void) {return responseData_;} | ||
26 | + private: | ||
27 | + // 建立请求 | ||
28 | + void handle_request_resolve(const std::string& url, pBuildRequest func); | ||
29 | + // 解析后 | ||
30 | + void handle_resolve(const boost::system::error_code& err, | ||
31 | + boost::asio::ip::tcp::resolver::iterator endpoint_iterator); | ||
32 | + // 连接后 | ||
33 | + void handle_connect(const boost::system::error_code& err); | ||
34 | + // 发送请求后 | ||
35 | + void handle_write_request(const boost::system::error_code& err); | ||
36 | + // 读取响应后 | ||
37 | + void handle_read_status_line(const boost::system::error_code& err); | ||
38 | + // 读取响应头后 | ||
39 | + void handle_read_headers(const boost::system::error_code& err); | ||
40 | + // 读取正文数据后 | ||
41 | + void handle_read_content(const boost::system::error_code& err); | ||
42 | + private: | ||
43 | + // 解析器 | ||
44 | + boost::asio::ip::tcp::resolver resolver_; | ||
45 | + // 套接字 | ||
46 | + boost::asio::ip::tcp::socket socket_; | ||
47 | + // 请求缓冲区 | ||
48 | + boost::asio::streambuf request_; | ||
49 | + // 响应缓冲区 | ||
50 | + boost::asio::streambuf response_; | ||
51 | + // 响应数据 | ||
52 | + std::string responseData_; | ||
53 | + }; | ||
54 | + std::string post(std::string url); | ||
55 | + std::string get(std::string url); | ||
56 | +} | ||
57 | + | ||
58 | +#endif //__dmphttpsutils_h__ |
@@ -8,10 +8,15 @@ | @@ -8,10 +8,15 @@ | ||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | #include "dmpservermanager.h" | 9 | #include "dmpservermanager.h" |
10 | #include "dmpserver.h" | 10 | #include "dmpserver.h" |
11 | +#include "dmphttputils.h" | ||
11 | #include <memory> | 12 | #include <memory> |
12 | #include <boost/property_tree/ptree.hpp> | 13 | #include <boost/property_tree/ptree.hpp> |
13 | #include <boost/property_tree/json_parser.hpp> | 14 | #include <boost/property_tree/json_parser.hpp> |
14 | #include <boost/property_tree/xml_parser.hpp> | 15 | #include <boost/property_tree/xml_parser.hpp> |
16 | +#include <sstream> | ||
17 | +#include <fstream> | ||
18 | + | ||
19 | + | ||
15 | 20 | ||
16 | DmpServerManager::DmpServerManager() | 21 | DmpServerManager::DmpServerManager() |
17 | { | 22 | { |
@@ -43,7 +48,7 @@ void DmpServerManager::init(const boost::filesystem::path &modulePath) | @@ -43,7 +48,7 @@ void DmpServerManager::init(const boost::filesystem::path &modulePath) | ||
43 | { | 48 | { |
44 | serverRegistry_->init(modulePath); | 49 | serverRegistry_->init(modulePath); |
45 | 50 | ||
46 | - //LoadServices(); | 51 | + LoadServices(); |
47 | //LoadDmpServices(); | 52 | //LoadDmpServices(); |
48 | } | 53 | } |
49 | 54 | ||
@@ -137,4 +142,42 @@ bool DmpServerManager::startService(const std::string &serverName, const std::st | @@ -137,4 +142,42 @@ bool DmpServerManager::startService(const std::string &serverName, const std::st | ||
137 | bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName) | 142 | bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName) |
138 | { | 143 | { |
139 | return serverRegistry_->getServer(serverName)->stop(serviceName); | 144 | return serverRegistry_->getServer(serverName)->stop(serviceName); |
145 | +} | ||
146 | +bool DmpServerManager::LoadServices() | ||
147 | +{ | ||
148 | + boost::property_tree::ptree pt_,ptList_; | ||
149 | + | ||
150 | + const std::string url_="http://172.26.60.100:8841/API/Service/TileService/Reload"; | ||
151 | + std::string strContent_=DmpHttp::get(url_); | ||
152 | + if(strContent_.length()==0) | ||
153 | + { | ||
154 | + return false; | ||
155 | + } | ||
156 | + | ||
157 | + ////测试响应内容写入文本 | ||
158 | + // std::ofstream examplefile ("/mnt/d/example.txt"); | ||
159 | + // if (examplefile.is_open()) { | ||
160 | + // examplefile << DmpHttp::get(url_); | ||
161 | + // examplefile.close(); | ||
162 | + // } | ||
163 | + //boost::property_tree::read_json("./example.txt", pt_); | ||
164 | + | ||
165 | + std::stringstream ssData_; | ||
166 | + ssData_<<strContent_.c_str(); | ||
167 | + boost::property_tree::read_json(ssData_, pt_); | ||
168 | + int iCount_ = std::atoi(pt_.get<std::string>("data.count").c_str()); | ||
169 | + if(iCount_>0) | ||
170 | + { | ||
171 | + ptList_=pt_.get_child("data.list"); | ||
172 | + for (auto& e : ptList_) | ||
173 | + { | ||
174 | + std::string name_=e.second.get<std::string>("name"); | ||
175 | + std::string title_ = e.second.get<std::string>("title"); | ||
176 | + std::string type_ = e.second.get<std::string>("type"); | ||
177 | + int capabilities_ =e.second.get<int>("capabilities"); | ||
178 | + std::string project_ = e.second.get<std::string>("project"); | ||
179 | + this->publish(type_,name_,capabilities_,project_); | ||
180 | + } | ||
181 | + } | ||
182 | + return true; | ||
140 | } | 183 | } |
@@ -37,6 +37,7 @@ public: | @@ -37,6 +37,7 @@ public: | ||
37 | DmpProject* getProject(const std::string& serviceName); | 37 | DmpProject* getProject(const std::string& serviceName); |
38 | bool removeProject(const std::string& serviceName); | 38 | bool removeProject(const std::string& serviceName); |
39 | std::string getCapabilities(); | 39 | std::string getCapabilities(); |
40 | + bool LoadServices(); | ||
40 | 41 | ||
41 | private: | 42 | private: |
42 | typedef std::map<std::string, DmpProject*, ci_less> ProjectMap; | 43 | typedef std::map<std::string, DmpProject*, ci_less> ProjectMap; |
@@ -44,5 +45,13 @@ private: | @@ -44,5 +45,13 @@ private: | ||
44 | ProjectMap projects_; | 45 | ProjectMap projects_; |
45 | DmpServerRegistry *serverRegistry_; | 46 | DmpServerRegistry *serverRegistry_; |
46 | }; | 47 | }; |
48 | +struct ServicesData | ||
49 | +{ | ||
50 | + std::string name; | ||
51 | + std::string title; | ||
52 | + std::string type; | ||
53 | + std::string capabilities; | ||
54 | + std::string project; | ||
55 | +}; | ||
47 | 56 | ||
48 | #endif // __dmpservermanager_h__ | 57 | #endif // __dmpservermanager_h__ |
@@ -77,6 +77,9 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | @@ -77,6 +77,9 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | ||
77 | else if(OperationId().compare("updatecache") == 0) { | 77 | else if(OperationId().compare("updatecache") == 0) { |
78 | UpdateCache(context); | 78 | UpdateCache(context); |
79 | } | 79 | } |
80 | + else if(OperationId().compare("reloadservices") == 0) { | ||
81 | + reloadServices(context); | ||
82 | + } | ||
80 | else { | 83 | else { |
81 | context.response()->write("not find oparation: " + OperationId()); | 84 | context.response()->write("not find oparation: " + OperationId()); |
82 | } | 85 | } |
@@ -428,16 +431,7 @@ void DmpManagerApiHandler::UpdateCache(const DmpServerApiContext &context)const | @@ -428,16 +431,7 @@ void DmpManagerApiHandler::UpdateCache(const DmpServerApiContext &context)const | ||
428 | return; | 431 | return; |
429 | } | 432 | } |
430 | } | 433 | } |
431 | - // if(context.manager()->UpdateCache(serviceName_)) | ||
432 | - // { | ||
433 | - // LOGGER_INFO("服务缓存更新成功"); | ||
434 | - // context.response()->write("{\"status\":\"true\",\"message\":\"服务缓存更新成功\"}"); | ||
435 | - // } | ||
436 | - // else | ||
437 | - // { | ||
438 | - // LOGGER_INFO("服务缓存更新失败"); | ||
439 | - // context.response()->write("{\"status\":\"true\",\"message\":\"服务缓存更新失败\"}"); | ||
440 | - // } | 434 | + |
441 | break; | 435 | break; |
442 | } | 436 | } |
443 | case DmpServerRequest::Method::POST_METHOD: | 437 | case DmpServerRequest::Method::POST_METHOD: |
@@ -475,17 +469,7 @@ void DmpManagerApiHandler::DeleteCache(const DmpServerApiContext &context)const | @@ -475,17 +469,7 @@ void DmpManagerApiHandler::DeleteCache(const DmpServerApiContext &context)const | ||
475 | return; | 469 | return; |
476 | } | 470 | } |
477 | } | 471 | } |
478 | - // if(context.manager()->DeleteCache(serviceName_)) | ||
479 | - // { | ||
480 | - // LOGGER_INFO("删除服务缓存成功"); | ||
481 | - // context.response()->write("{\"status\":\"true\",\"message\":\"删除服务缓存成功\"}"); | ||
482 | - // } | ||
483 | - // else | ||
484 | - // { | ||
485 | - // LOGGER_INFO("删除服务缓存失败"); | ||
486 | - // context.response()->write("{\"status\":\"true\",\"message\":\"删除服务缓存失败\"}"); | ||
487 | - // } | ||
488 | - //context.response()->write("{\"status\":\"true\",\"message\":\"删除缓存——————GET\"}"); | 472 | + |
489 | break; | 473 | break; |
490 | } | 474 | } |
491 | case DmpServerRequest::Method::POST_METHOD: | 475 | case DmpServerRequest::Method::POST_METHOD: |
@@ -505,3 +489,28 @@ void DmpManagerApiHandler::getCapabilities(const DmpServerApiContext &context) c | @@ -505,3 +489,28 @@ void DmpManagerApiHandler::getCapabilities(const DmpServerApiContext &context) c | ||
505 | std::string strJson = context.manager()->getCapabilities(); | 489 | std::string strJson = context.manager()->getCapabilities(); |
506 | context.response()->write(strJson); | 490 | context.response()->write(strJson); |
507 | } | 491 | } |
492 | +void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) const | ||
493 | +{ | ||
494 | + switch (context.request()->method()) | ||
495 | + { | ||
496 | + case DmpServerRequest::Method::GET_METHOD: | ||
497 | + { | ||
498 | + if(context.manager()->LoadServices()) { | ||
499 | + context.response()->write("{\"status\":\"true\",\"message\":\"重载服务成功\"}"); | ||
500 | + }else{ | ||
501 | + context.response()->write("{\"status\":\"false\",\"message\":\"重载服务失败\"}"); | ||
502 | + } | ||
503 | + break; | ||
504 | + | ||
505 | + } | ||
506 | + case DmpServerRequest::Method::POST_METHOD: | ||
507 | + { | ||
508 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务重载——————POST\"}"); | ||
509 | + break; | ||
510 | + } | ||
511 | + default: | ||
512 | + { | ||
513 | + | ||
514 | + } | ||
515 | + } | ||
516 | +} |
@@ -53,6 +53,7 @@ public: | @@ -53,6 +53,7 @@ public: | ||
53 | void DeleteCache(const DmpServerApiContext &context)const; | 53 | void DeleteCache(const DmpServerApiContext &context)const; |
54 | 54 | ||
55 | void getCapabilities(const DmpServerApiContext &context)const; | 55 | void getCapabilities(const DmpServerApiContext &context)const; |
56 | + void reloadServices(const DmpServerApiContext &context)const; | ||
56 | 57 | ||
57 | }; | 58 | }; |
58 | 59 |
@@ -5,12 +5,12 @@ SET (TILESERVER_SRCS | @@ -5,12 +5,12 @@ SET (TILESERVER_SRCS | ||
5 | dmptileserver.cpp | 5 | dmptileserver.cpp |
6 | wmts/dmpwmts.cpp | 6 | wmts/dmpwmts.cpp |
7 | wmts/dmpwmtsparameters.cpp | 7 | wmts/dmpwmtsparameters.cpp |
8 | - # dmpcapabilitiesoperation.cpp | ||
9 | wmts/dmptileproviderfactory.cpp | 8 | wmts/dmptileproviderfactory.cpp |
10 | wmts/dmpesritileprovider.cpp | 9 | wmts/dmpesritileprovider.cpp |
11 | wmts/dmpesribundlev1provider.cpp | 10 | wmts/dmpesribundlev1provider.cpp |
12 | wmts/dmpesribundlev2provider.cpp | 11 | wmts/dmpesribundlev2provider.cpp |
13 | wmts/dmpabstractesribundleprovider.cpp | 12 | wmts/dmpabstractesribundleprovider.cpp |
13 | + wmts/dmpcapabilitiesoperation.cpp | ||
14 | # dmpwmtsservice.cpp | 14 | # dmpwmtsservice.cpp |
15 | wmts/dmpwmtsutils.cpp | 15 | wmts/dmpwmtsutils.cpp |
16 | tms/dmptms.cpp | 16 | tms/dmptms.cpp |
@@ -19,19 +19,18 @@ SET (TILESERVER_SRCS | @@ -19,19 +19,18 @@ SET (TILESERVER_SRCS | ||
19 | SET (TILESERVER_HDRS | 19 | SET (TILESERVER_HDRS |
20 | dmptileserver.h | 20 | dmptileserver.h |
21 | wmts/dmpwmtsparameters.h | 21 | wmts/dmpwmtsparameters.h |
22 | - # dmpcapabilitiesoperation.h | ||
23 | wmts/dmptileprovider.h | 22 | wmts/dmptileprovider.h |
24 | wmts/dmptileproviderfactory.h | 23 | wmts/dmptileproviderfactory.h |
25 | wmts/dmpesritileprovider.h | 24 | wmts/dmpesritileprovider.h |
26 | wmts/dmpesribundlev1provider.h | 25 | wmts/dmpesribundlev1provider.h |
27 | wmts/dmpesribundlev2provider.h | 26 | wmts/dmpesribundlev2provider.h |
28 | wmts/dmpabstractesribundleprovider.h | 27 | wmts/dmpabstractesribundleprovider.h |
28 | + wmts/dmpcapabilitiesoperation.h | ||
29 | + wmts/dmpcapabilitiesprovider.h | ||
29 | # dmpwmtsservice.h | 30 | # dmpwmtsservice.h |
30 | wmts/dmpwmtsutils.h | 31 | wmts/dmpwmtsutils.h |
31 | - # dmpcapabilitiesprovider.h | ||
32 | tms/dmptms.h | 32 | tms/dmptms.h |
33 | ) | 33 | ) |
34 | - | ||
35 | ######################################################## | 34 | ######################################################## |
36 | # Build | 35 | # Build |
37 | 36 |
1 | +/************************************************************************** | ||
2 | +* file: dmpserverparameters.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include <iostream> | ||
10 | +#include <boost/lexical_cast.hpp> | ||
11 | +#include <boost/algorithm/string.hpp> | ||
12 | +#include "dmplogger.h" | ||
13 | +#include "dmpserverutils.h" | ||
14 | +#include "dmptmsparameters.h" | ||
15 | + | ||
16 | + | ||
17 | +namespace DmpTms | ||
18 | +{ | ||
19 | + DmpTmsParameters::DmpTmsParameters(const DmpServerParameters ¶meters) | ||
20 | + { | ||
21 | + params_ = parameters.Parameters(); | ||
22 | + } | ||
23 | + DmpTmsParameters::DmpTmsParameters() : DmpServerParameters() | ||
24 | + { | ||
25 | + | ||
26 | + } | ||
27 | + int DmpTmsParameters::TileMatrix() const | ||
28 | + { | ||
29 | + std::map<std::string, std::string>::const_iterator iter; | ||
30 | + iter = params_.find("TILEMATRIX"); | ||
31 | + if (iter != params_.end()) | ||
32 | + { | ||
33 | + try | ||
34 | + { | ||
35 | + int num_tile_atrix = boost::lexical_cast<int>(iter->second); | ||
36 | + return num_tile_atrix; | ||
37 | + } | ||
38 | + catch (boost::bad_lexical_cast &e) | ||
39 | + { | ||
40 | + LOGGER_ERROR(e.what()); | ||
41 | + } | ||
42 | + } | ||
43 | + return -1; | ||
44 | + } | ||
45 | + int DmpTmsParameters::TileRow() const | ||
46 | + { | ||
47 | + std::map<std::string, std::string>::const_iterator iter; | ||
48 | + iter = params_.find("TILEROW"); | ||
49 | + if (iter != params_.end()) | ||
50 | + { | ||
51 | + try | ||
52 | + { | ||
53 | + int num_tile_row = boost::lexical_cast<int>(iter->second); | ||
54 | + return num_tile_row; | ||
55 | + } | ||
56 | + catch (boost::bad_lexical_cast &e) | ||
57 | + { | ||
58 | + LOGGER_ERROR(e.what()); | ||
59 | + } | ||
60 | + } | ||
61 | + return -1; | ||
62 | + } | ||
63 | + int DmpTmsParameters::TileCol() const | ||
64 | + { | ||
65 | + std::map<std::string, std::string>::const_iterator iter; | ||
66 | + iter = params_.find("TILECOL"); | ||
67 | + if (iter != params_.end()) | ||
68 | + { | ||
69 | + try | ||
70 | + { | ||
71 | + int num_tile_col = boost::lexical_cast<int>(iter->second); | ||
72 | + return num_tile_col; | ||
73 | + } | ||
74 | + catch (boost::bad_lexical_cast &e) | ||
75 | + { | ||
76 | + LOGGER_ERROR(e.what()); | ||
77 | + } | ||
78 | + } | ||
79 | + return -1; | ||
80 | + } | ||
81 | + | ||
82 | + std::string DmpTmsParameters::TileMatrixSet() const | ||
83 | + { | ||
84 | + std::string tile_matrix_set; | ||
85 | + std::map<std::string, std::string>::const_iterator iter; | ||
86 | + iter = params_.find("TILEMATRIXSET"); | ||
87 | + if (iter != params_.end()) | ||
88 | + { | ||
89 | + tile_matrix_set = iter->second; | ||
90 | + } | ||
91 | + return tile_matrix_set; | ||
92 | + } | ||
93 | + std::string DmpTmsParameters::Layer() const | ||
94 | + { | ||
95 | + std::string layer; | ||
96 | + std::map<std::string, std::string>::const_iterator iter; | ||
97 | + iter = params_.find("LAYER"); | ||
98 | + if (iter != params_.end()) | ||
99 | + { | ||
100 | + layer = iter->second; | ||
101 | + } | ||
102 | + return layer; | ||
103 | + } | ||
104 | + | ||
105 | + DmpTmsParameters::Format DmpTmsParameters::ImageFormat() const | ||
106 | + { | ||
107 | + std::string frm; | ||
108 | + std::map<std::string, std::string>::const_iterator iter; | ||
109 | + iter = params_.find("format"); | ||
110 | + if (iter != params_.end()) | ||
111 | + { | ||
112 | + frm = iter->second; | ||
113 | + if (frm.empty()) { | ||
114 | + return Format::NONE; | ||
115 | + } | ||
116 | + Format f = Format::PNG; | ||
117 | + boost::to_lower(frm); | ||
118 | + if (frm.compare("jpg") == 0 || frm.compare("jpeg") == 0 || frm.compare("image/jpeg") == 0 ) { | ||
119 | + f = Format::JPG; | ||
120 | + } | ||
121 | + return f; | ||
122 | + } | ||
123 | + return Format::NONE; | ||
124 | + } | ||
125 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpserverparameters.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmptmsparameters_h__ | ||
10 | +#define __dmptmsparameters_h__ | ||
11 | + | ||
12 | +#include "dmpserverparameters.h" | ||
13 | +namespace DmpTms | ||
14 | +{ | ||
15 | + class DmpTmsParameters : public DmpServerParameters | ||
16 | + { | ||
17 | + public: | ||
18 | + enum class Format | ||
19 | + { | ||
20 | + NONE, | ||
21 | + JPG, | ||
22 | + PNG | ||
23 | + }; | ||
24 | + DmpTmsParameters(const DmpServerParameters ¶meters); | ||
25 | + DmpTmsParameters(); | ||
26 | + virtual ~DmpTmsParameters() = default; | ||
27 | + std::string Layer() const; | ||
28 | + Format ImageFormat() const; | ||
29 | + std::string TileMatrixSet() const; | ||
30 | + int TileMatrix() const; | ||
31 | + int TileRow() const; | ||
32 | + int TileCol() const; | ||
33 | + }; | ||
34 | +} | ||
35 | +#endif //__dmptmsparameters_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmptmstileprovider.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmptmstileprovider.h" | ||
10 | +#include "dmpserverresponse.h" | ||
11 | +namespace DmpTms | ||
12 | +{ | ||
13 | + DmpTmsTileProvider::DmpTmsTileProvider(const std::string& root_path) | ||
14 | + { | ||
15 | + file_rootPath=root_path; | ||
16 | + } | ||
17 | + void DmpTmsTileProvider::WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) | ||
18 | + { | ||
19 | + std::string tile_path = file_rootPath+"/"+std::to_string(level)+"/"+std::to_string(row)+"/"+std::to_string(col)+"."+format; | ||
20 | + std::ifstream fread(tile_path, std::ifstream::binary); | ||
21 | + if(!fread) | ||
22 | + { | ||
23 | + | ||
24 | + response.sendError(500, "找不到瓦片:("); | ||
25 | + return; | ||
26 | + } | ||
27 | + fread.seekg(0,fread.end); | ||
28 | + int length = fread.tellg(); | ||
29 | + if(length > 0) | ||
30 | + { | ||
31 | + fread.seekg(0,fread.beg); | ||
32 | + char* buff = new char[length]; | ||
33 | + fread.read(buff,length); | ||
34 | + | ||
35 | + std::string f = (format == "jpg") ? "image/jpg" : "image/png"; | ||
36 | + response.setHeader("Content-Type", f); | ||
37 | + response.writeContent(buff, length); | ||
38 | + | ||
39 | + delete buff; | ||
40 | + } | ||
41 | + else | ||
42 | + { | ||
43 | + response.sendError(500, "找不到瓦片:("); | ||
44 | + } | ||
45 | + fread.close(); | ||
46 | + } | ||
47 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmptmstileprovider.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmptmstileprovider_h__ | ||
10 | +#define __dmptmstileprovider_h__ | ||
11 | + | ||
12 | +#include <string> | ||
13 | +#include "dmpserverresponse.h" | ||
14 | + | ||
15 | +namespace DmpTms | ||
16 | +{ | ||
17 | + class DmpTmsTileProvider | ||
18 | + { | ||
19 | + public: | ||
20 | + DmpTmsTileProvider(const std::string& root_path); | ||
21 | + void WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) ; | ||
22 | + protected: | ||
23 | + std::string file_rootPath; | ||
24 | + }; | ||
25 | +} | ||
26 | +#endif |
1 | +/************************************************************************** | ||
2 | +* file: dmpcapabilitiesoperation.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
1 | #include <iostream> | 9 | #include <iostream> |
2 | #include <boost/property_tree/ptree.hpp> | 10 | #include <boost/property_tree/ptree.hpp> |
3 | #include <boost/property_tree/xml_parser.hpp> | 11 | #include <boost/property_tree/xml_parser.hpp> |
@@ -6,7 +14,6 @@ | @@ -6,7 +14,6 @@ | ||
6 | #include <fstream> | 14 | #include <fstream> |
7 | #include "dmpcapabilitiesoperation.h" | 15 | #include "dmpcapabilitiesoperation.h" |
8 | #include "dmpserverresponse.h" | 16 | #include "dmpserverresponse.h" |
9 | -//#include "dmppgsqlutils.h" | ||
10 | 17 | ||
11 | 18 | ||
12 | using namespace std; | 19 | using namespace std; |
@@ -34,8 +41,8 @@ namespace DmpWmts | @@ -34,8 +41,8 @@ namespace DmpWmts | ||
34 | char* buff = new char[length]; | 41 | char* buff = new char[length]; |
35 | fread.read(buff,length); | 42 | fread.read(buff,length); |
36 | 43 | ||
37 | - response.SetHeader("Content-Type", "application/xml"); | ||
38 | - response.WriteContent(buff, length); | 44 | + response.setHeader("Content-Type", "application/xml"); |
45 | + response.writeContent(buff, length); | ||
39 | 46 | ||
40 | delete buff; | 47 | delete buff; |
41 | } | 48 | } |
@@ -45,7 +52,7 @@ namespace DmpWmts | @@ -45,7 +52,7 @@ namespace DmpWmts | ||
45 | return; | 52 | return; |
46 | } | 53 | } |
47 | } | 54 | } |
48 | - void DmpCapabiliTilesOperation::WriteCapabilities(boost::property_tree::ptree& pt_ ,const std::string& host_,const std::string& servicename,DmpServerResponse& response) | 55 | + void DmpCapabiliTilesOperation::WriteCapabilities(boost::property_tree::ptree& pt_,const std::string& host_,const std::string& servicename,DmpServerResponse& response) |
49 | { | 56 | { |
50 | //构建能力文档 | 57 | //构建能力文档 |
51 | boost::property_tree::ptree pt_root_,pt_TileMatrix_; | 58 | boost::property_tree::ptree pt_root_,pt_TileMatrix_; |
@@ -54,10 +61,10 @@ namespace DmpWmts | @@ -54,10 +61,10 @@ namespace DmpWmts | ||
54 | pt_root_.add("Capabilities.Contents.Layer.ows:Abstract",pt_.get<std::string>("Layer.ows:Abstract")); | 61 | pt_root_.add("Capabilities.Contents.Layer.ows:Abstract",pt_.get<std::string>("Layer.ows:Abstract")); |
55 | pt_root_.add("Capabilities.Contents.Layer.ows:Identifier",pt_.get<std::string>("Layer.ows:Identifier")); | 62 | pt_root_.add("Capabilities.Contents.Layer.ows:Identifier",pt_.get<std::string>("Layer.ows:Identifier")); |
56 | //pt_root_.add("Capabilities.Contents.Layer.Style.<xmlattr>.isDefault",pt_.get<std::string>("Layer.Style.<xmlattr>.isDefault")); | 63 | //pt_root_.add("Capabilities.Contents.Layer.Style.<xmlattr>.isDefault",pt_.get<std::string>("Layer.Style.<xmlattr>.isDefault")); |
57 | - pt_root_.add("Capabilities.Contents.Layer.Style",pt_.get<std::string>("Layer.Style.<xmlattr>.isDefault")); | 64 | + pt_root_.add("Capabilities.Contents.Layer.Style",pt_.get<std::string>("Layer.Style")); |
58 | pt_root_.add("Capabilities.Contents.Layer.Format",pt_.get<std::string>("Layer.Format")); | 65 | pt_root_.add("Capabilities.Contents.Layer.Format",pt_.get<std::string>("Layer.Format")); |
59 | pt_root_.add("Capabilities.Contents.Layer.TileMatrixSetLink.TileMatrixSet",pt_.get<std::string>("Layer.TileMatrixSetLink.TileMatrixSet")); | 66 | pt_root_.add("Capabilities.Contents.Layer.TileMatrixSetLink.TileMatrixSet",pt_.get<std::string>("Layer.TileMatrixSetLink.TileMatrixSet")); |
60 | - | 67 | + |
61 | boost::property_tree::ptree pt_TileMatrixSet_; | 68 | boost::property_tree::ptree pt_TileMatrixSet_; |
62 | pt_TileMatrixSet_.add("ows:Identifier",pt_.get<std::string>("TileMatrixSet.ows:Identifier")); | 69 | pt_TileMatrixSet_.add("ows:Identifier",pt_.get<std::string>("TileMatrixSet.ows:Identifier")); |
63 | pt_TileMatrixSet_.add("ows:SupportedCRS",pt_.get<std::string>("TileMatrixSet.ows:SupportedCRS")); | 70 | pt_TileMatrixSet_.add("ows:SupportedCRS",pt_.get<std::string>("TileMatrixSet.ows:SupportedCRS")); |
@@ -65,8 +72,10 @@ namespace DmpWmts | @@ -65,8 +72,10 @@ namespace DmpWmts | ||
65 | pt_TileMatrixSet_.add("TileHeight",pt_.get<std::string>("TileMatrixSet.TileHeight")); | 72 | pt_TileMatrixSet_.add("TileHeight",pt_.get<std::string>("TileMatrixSet.TileHeight")); |
66 | pt_TileMatrixSet_.add("TopLeftCorner",pt_.get<std::string>("TileMatrixSet.TopLeftCorner")); | 73 | pt_TileMatrixSet_.add("TopLeftCorner",pt_.get<std::string>("TileMatrixSet.TopLeftCorner")); |
67 | pt_TileMatrixSet_.add("Dpi",pt_.get<std::string>("TileMatrixSet.DPI")); | 74 | pt_TileMatrixSet_.add("Dpi",pt_.get<std::string>("TileMatrixSet.DPI")); |
68 | - | ||
69 | - pt_TileMatrix_=pt_.get_child("TileMatrixSet.TileMatrix"); | 75 | + |
76 | + //pt_TileMatrix_=pt_.get_child("TileMatrixSet.TileMatrix"); | ||
77 | + pt_TileMatrix_=pt_.get_child("TileMatrixSet.Levels"); | ||
78 | + int i=pt_TileMatrix_.size(); | ||
70 | boost::property_tree::ptree::iterator pos_ = pt_TileMatrix_.begin(); | 79 | boost::property_tree::ptree::iterator pos_ = pt_TileMatrix_.begin(); |
71 | for (; pos_ != pt_TileMatrix_.end(); ++pos_ ) | 80 | for (; pos_ != pt_TileMatrix_.end(); ++pos_ ) |
72 | { | 81 | { |
@@ -84,15 +93,19 @@ namespace DmpWmts | @@ -84,15 +93,19 @@ namespace DmpWmts | ||
84 | pt_root_.add_child("Capabilities.Contents.TileMatrixSet",pt_TileMatrixSet_); | 93 | pt_root_.add_child("Capabilities.Contents.TileMatrixSet",pt_TileMatrixSet_); |
85 | //pt_root_.add("Capabilities.Contents.TileMatrixSet.TileMatrix.ows:Identifier",pt_.get<std::string>("TileMatrixSet.TileMatrix.ows:Identifier")); | 94 | //pt_root_.add("Capabilities.Contents.TileMatrixSet.TileMatrix.ows:Identifier",pt_.get<std::string>("TileMatrixSet.TileMatrix.ows:Identifier")); |
86 | //pt_root_.add("Capabilities.Contents.TileMatrixSet.TileMatrix.TopLeftCorner",pt_.get<std::string>("TileMatrixSet.TileMatrix.TopLeftCorner")); | 95 | //pt_root_.add("Capabilities.Contents.TileMatrixSet.TileMatrix.TopLeftCorner",pt_.get<std::string>("TileMatrixSet.TileMatrix.TopLeftCorner")); |
87 | - std::string http_cap0_="http://"+host_+"/DMap/Services/"+servicename+"/MapServer/WMTSServer/1.0.0/WMTSCapabilities.xml"; | 96 | + std::string http_cap0_="http://"+host_+"/DMap/Services/"+servicename+"/TileServer/WMTSService/1.0.0/WMTSCapabilities.xml"; |
88 | pt_root_.add("Capabilities.ServiceMetadataURL.<xmlattr>.xlink:href",http_cap0_); | 97 | pt_root_.add("Capabilities.ServiceMetadataURL.<xmlattr>.xlink:href",http_cap0_); |
98 | + | ||
89 | //写入流 | 99 | //写入流 |
90 | - //std::stringstream ss; | ||
91 | - //boost::property_tree::write_xml(ss,pt_root_); | ||
92 | - //std::string strExtent_=ss.str(); | ||
93 | - //response.SetHeader("Content-Type", "application/xml;charset=utf-8"); | ||
94 | - //response.WriteContent(strExtent_.c_str(),102400); | ||
95 | - std::string fpath_="/usr/local/"+servicename+".xml"; | 100 | + std::stringstream ss; |
101 | + boost::property_tree::write_xml(ss,pt_root_); | ||
102 | + std::string strExtent_=ss.str(); | ||
103 | + response.setHeader("Content-Type", "application/xml;charset=utf-8"); | ||
104 | + response.write(strExtent_); | ||
105 | + return; | ||
106 | + /* | ||
107 | + //文件流代换写入 | ||
108 | + std::string fpath_="./"+servicename+".xml"; | ||
96 | boost::property_tree::write_xml(fpath_,pt_root_); | 109 | boost::property_tree::write_xml(fpath_,pt_root_); |
97 | std::ifstream fread(fpath_, std::ifstream::binary); | 110 | std::ifstream fread(fpath_, std::ifstream::binary); |
98 | if(!fread) | 111 | if(!fread) |
@@ -108,8 +121,8 @@ namespace DmpWmts | @@ -108,8 +121,8 @@ namespace DmpWmts | ||
108 | char* buff = new char[length]; | 121 | char* buff = new char[length]; |
109 | fread.read(buff,length); | 122 | fread.read(buff,length); |
110 | 123 | ||
111 | - response.SetHeader("Content-Type", "application/xml"); | ||
112 | - response.WriteContent(buff, length); | 124 | + response.setHeader("Content-Type", "application/xml"); |
125 | + response.writeContent(buff, length); | ||
113 | 126 | ||
114 | delete buff; | 127 | delete buff; |
115 | std::remove(fpath_.c_str()); | 128 | std::remove(fpath_.c_str()); |
@@ -119,7 +132,7 @@ namespace DmpWmts | @@ -119,7 +132,7 @@ namespace DmpWmts | ||
119 | response.sendError(500, "找不到文件:("); | 132 | response.sendError(500, "找不到文件:("); |
120 | return; | 133 | return; |
121 | } | 134 | } |
122 | - | 135 | + */ |
123 | } | 136 | } |
124 | 137 | ||
125 | void DmpCapabiliTilesOperation::GetCapabilitiesDocument(DmpServerResponse& response) | 138 | void DmpCapabiliTilesOperation::GetCapabilitiesDocument(DmpServerResponse& response) |
@@ -168,9 +181,9 @@ namespace DmpWmts | @@ -168,9 +181,9 @@ namespace DmpWmts | ||
168 | void DmpCapabiliTilesOperation:: GetServiceMetadataElement(const std::string& host_,const std::string& servicename,boost::property_tree::ptree& pt) | 181 | void DmpCapabiliTilesOperation:: GetServiceMetadataElement(const std::string& host_,const std::string& servicename,boost::property_tree::ptree& pt) |
169 | { | 182 | { |
170 | //localhost:8080/DMap/Services/GDWMTS/MapServer/WMTSServer?request=GetCapabilities | 183 | //localhost:8080/DMap/Services/GDWMTS/MapServer/WMTSServer?request=GetCapabilities |
171 | - std::string http_cap0_="http://"+host_+"/DMap/Services/"+servicename+"/MapServer/WMTSServer/1.0.0/WMTSCapabilities.xml"; | ||
172 | - std::string http_cap1_="http://"+host_+"/DMap/Services/"+servicename+"/MapServer/WMTSServer?"; | ||
173 | - std::string http_cap2_="http://"+host_+"/DMap/Services/"+servicename+"/MapServer/WMTSServer/1.0.0/"; | 184 | + std::string http_cap0_="http://"+host_+"/DMap/Services/"+servicename+"/TileServer/WMTSService/1.0.0/WMTSCapabilities.xml"; |
185 | + std::string http_cap1_="http://"+host_+"/DMap/Services/"+servicename+"/TileServer/WMTSService?"; | ||
186 | + std::string http_cap2_="http://"+host_+"/DMap/Services/"+servicename+"/TileServer/WMTSService/1.0.0/"; | ||
174 | boost::property_tree::ptree pt_child0_,pt_child1_; | 187 | boost::property_tree::ptree pt_child0_,pt_child1_; |
175 | 188 | ||
176 | pt_child0_.add("<xmlattr>.name","GetCapabilities"); | 189 | pt_child0_.add("<xmlattr>.name","GetCapabilities"); |
1 | +/************************************************************************** | ||
2 | +* file: dmpcapabilitiesoperation.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
1 | #ifndef __dmpcapabilitiesoperation_h__ | 9 | #ifndef __dmpcapabilitiesoperation_h__ |
2 | #define __dmpcapabilitiesoperation_h__ | 10 | #define __dmpcapabilitiesoperation_h__ |
3 | 11 | ||
@@ -8,12 +16,13 @@ | @@ -8,12 +16,13 @@ | ||
8 | #include "dmpcapabilitiesprovider.h" | 16 | #include "dmpcapabilitiesprovider.h" |
9 | 17 | ||
10 | 18 | ||
19 | + | ||
11 | using namespace std; | 20 | using namespace std; |
12 | 21 | ||
13 | namespace DmpWmts | 22 | namespace DmpWmts |
14 | { | 23 | { |
15 | 24 | ||
16 | - class DmpCapabiliTilesOperation : public DmpCapabiliTilesProvider | 25 | + class DmpCapabiliTilesOperation:public DmpCapabiliTilesProvider |
17 | { | 26 | { |
18 | private: | 27 | private: |
19 | std::string WMTS_NAMESPACE = "http://www.opengis.net/wmts/1.0"; | 28 | std::string WMTS_NAMESPACE = "http://www.opengis.net/wmts/1.0"; |
@@ -26,7 +35,7 @@ namespace DmpWmts | @@ -26,7 +35,7 @@ namespace DmpWmts | ||
26 | public: | 35 | public: |
27 | DmpCapabiliTilesOperation(); | 36 | DmpCapabiliTilesOperation(); |
28 | void WriteCapabilities(DmpServerResponse& response); | 37 | void WriteCapabilities(DmpServerResponse& response); |
29 | - void WriteCapabilities(boost::property_tree::ptree& pt_,const std::string& host_ ,const std::string& servicename,DmpServerResponse& response); | 38 | + void WriteCapabilities(boost::property_tree::ptree& pt,const std::string& host_ ,const std::string& servicename,DmpServerResponse& response); |
30 | void GetCapabilitiesDocument(DmpServerResponse& response); | 39 | void GetCapabilitiesDocument(DmpServerResponse& response); |
31 | void CreateGetCapabilitiesDocument(const std::string& host_ ,const std::string& servicename,boost::property_tree::ptree& pt); | 40 | void CreateGetCapabilitiesDocument(const std::string& host_ ,const std::string& servicename,boost::property_tree::ptree& pt); |
32 | void GetServiceIdentificationElement(const std::string& servicename,boost::property_tree::ptree& pt); | 41 | void GetServiceIdentificationElement(const std::string& servicename,boost::property_tree::ptree& pt); |
1 | +/************************************************************************** | ||
2 | +* file: dmpcapabilitiesprovider.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-09 17:41:00 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
1 | #ifndef __dmpcapabilitiesprovider_h__ | 9 | #ifndef __dmpcapabilitiesprovider_h__ |
2 | #define __dmpcapabilitiesprovider_h__ | 10 | #define __dmpcapabilitiesprovider_h__ |
3 | #include <string> | 11 | #include <string> |
@@ -8,8 +16,8 @@ namespace DmpWmts | @@ -8,8 +16,8 @@ namespace DmpWmts | ||
8 | class DmpCapabiliTilesProvider | 16 | class DmpCapabiliTilesProvider |
9 | { | 17 | { |
10 | public: | 18 | public: |
11 | - virtual void WriteCapabilities(DmpServerResponse& respons) = 0; | ||
12 | - virtual void WriteCapabilities(boost::property_tree::ptree& pt_,const std::string& host_ ,const std::string& servicename ,DmpServerResponse& respons) = 0; | 19 | + void WriteCapabilities(DmpServerResponse& respons); |
20 | + void WriteCapabilities(boost::property_tree::ptree& pt_,const std::string& host_ ,const std::string& servicename ,DmpServerResponse& respons); | ||
13 | 21 | ||
14 | protected: | 22 | protected: |
15 | std::string file_rootPath; | 23 | std::string file_rootPath; |
@@ -11,8 +11,8 @@ | @@ -11,8 +11,8 @@ | ||
11 | #include "dmpesritileprovider.h" | 11 | #include "dmpesritileprovider.h" |
12 | #include "dmpesribundlev1provider.h" | 12 | #include "dmpesribundlev1provider.h" |
13 | #include "dmpesribundlev2provider.h" | 13 | #include "dmpesribundlev2provider.h" |
14 | -//#include "dmpcapabilitiesprovider.h" | ||
15 | -//#include "dmpcapabilitiesoperation.h" | 14 | +#include "dmpcapabilitiesprovider.h" |
15 | +#include "dmpcapabilitiesoperation.h" | ||
16 | #include <boost/lexical_cast.hpp> | 16 | #include <boost/lexical_cast.hpp> |
17 | #include "dmplogger.h" | 17 | #include "dmplogger.h" |
18 | #include "dmpwmtsutils.h" | 18 | #include "dmpwmtsutils.h" |
@@ -29,10 +29,10 @@ namespace DmpWmts | @@ -29,10 +29,10 @@ namespace DmpWmts | ||
29 | std::shared_ptr<DmpTileProvider> provider; | 29 | std::shared_ptr<DmpTileProvider> provider; |
30 | try | 30 | try |
31 | { | 31 | { |
32 | - std::string path_= dmpTileLayer_->GetVector(); | ||
33 | - std::string data_=dmpTileLayer_->GetDataSource(); | ||
34 | - std::string tilePath_ = "/mnt/d/Code/tiles/gdmap/_alllayers"; | ||
35 | - std::string tileVersion_ = "ESRI_V1"; | 32 | + std::string tileVersion_= dmpTileLayer_->getVector(); |
33 | + std::string tilePath_=dmpTileLayer_->getDataSource(); | ||
34 | + //std::string tilePath_ = "/mnt/d/Code/tiles/gdmap/_alllayers"; | ||
35 | + //std::string tileVersion_ = "ESRI_V1"; | ||
36 | int iver_=StringToVector(tileVersion_); | 36 | int iver_=StringToVector(tileVersion_); |
37 | Vector version = (Vector)boost::lexical_cast<int>(iver_); | 37 | Vector version = (Vector)boost::lexical_cast<int>(iver_); |
38 | switch(version) | 38 | switch(version) |
@@ -18,8 +18,8 @@ | @@ -18,8 +18,8 @@ | ||
18 | #include <boost/property_tree/json_parser.hpp> | 18 | #include <boost/property_tree/json_parser.hpp> |
19 | #include <memory> | 19 | #include <memory> |
20 | #include "dmpwmtsparameters.h" | 20 | #include "dmpwmtsparameters.h" |
21 | +#include "dmpcapabilitiesoperation.h" | ||
21 | #include "dmplogger.h" | 22 | #include "dmplogger.h" |
22 | -//#include "dmpcapabilitiesoperation.h" | ||
23 | #include "dmptileproviderfactory.h" | 23 | #include "dmptileproviderfactory.h" |
24 | #include "dmpserverrequest.h" | 24 | #include "dmpserverrequest.h" |
25 | #include "dmpwmtsservice.h" | 25 | #include "dmpwmtsservice.h" |
@@ -30,7 +30,7 @@ using namespace std; | @@ -30,7 +30,7 @@ using namespace std; | ||
30 | 30 | ||
31 | namespace DmpWmts | 31 | namespace DmpWmts |
32 | { | 32 | { |
33 | - | 33 | + |
34 | DmpWMTSService::DmpWMTSService() | 34 | DmpWMTSService::DmpWMTSService() |
35 | { | 35 | { |
36 | LOGGER_DEBUG("Constructing WmtsService"); | 36 | LOGGER_DEBUG("Constructing WmtsService"); |
@@ -40,7 +40,34 @@ namespace DmpWmts | @@ -40,7 +40,34 @@ namespace DmpWmts | ||
40 | { | 40 | { |
41 | LOGGER_DEBUG("Destructing WmtsService"); | 41 | LOGGER_DEBUG("Destructing WmtsService"); |
42 | } | 42 | } |
43 | + bool allowMethod(DmpServerRequest::Method method) | ||
44 | + { | ||
45 | + return method == DmpServerRequest::GET_METHOD; | ||
46 | + } | ||
43 | 47 | ||
48 | + std::string getWMTSServiceName(const std::string& url) | ||
49 | + { | ||
50 | + std::string service_name; | ||
51 | + boost::cmatch what; | ||
52 | + std::string path_("^/DMap/Services/?(/[\\w./]*)/TileServer/WMTSService"); | ||
53 | + boost::regex reg(path_, boost::regex_constants::icase); | ||
54 | + if(boost::regex_search(url.c_str(), what, reg)) | ||
55 | + { | ||
56 | + if(what.size() >= 2) { | ||
57 | + std::string server_path = what[1].str(); | ||
58 | + std::string::size_type pos = server_path.find_first_of("/"); | ||
59 | + | ||
60 | + if(pos != std::string::npos) { | ||
61 | + service_name = server_path.substr(pos+1,server_path.length()-1); | ||
62 | + } | ||
63 | + else { | ||
64 | + service_name = server_path; | ||
65 | + } | ||
66 | + | ||
67 | + } | ||
68 | + } | ||
69 | + return service_name; | ||
70 | + } | ||
44 | void DmpWMTSService::executeRequest(const DmpServerContext &context) | 71 | void DmpWMTSService::executeRequest(const DmpServerContext &context) |
45 | { | 72 | { |
46 | DmpWmtsParameters *params = nullptr; | 73 | DmpWmtsParameters *params = nullptr; |
@@ -64,11 +91,8 @@ namespace DmpWmts | @@ -64,11 +91,8 @@ namespace DmpWmts | ||
64 | const DmpProject *project = context.project(); | 91 | const DmpProject *project = context.project(); |
65 | DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer(layerName)); | 92 | DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer(layerName)); |
66 | //context.response()->writeHtml("hello,wmts"); | 93 | //context.response()->writeHtml("hello,wmts"); |
67 | - | ||
68 | //const DmpWmtsParameters params(context.request()->serverParameters()); | 94 | //const DmpWmtsParameters params(context.request()->serverParameters()); |
69 | - | ||
70 | - | ||
71 | - | 95 | + |
72 | if (req.empty()) | 96 | if (req.empty()) |
73 | { | 97 | { |
74 | context.response()->writeHtml("wmts,Operation is null"); | 98 | context.response()->writeHtml("wmts,Operation is null"); |
@@ -81,14 +105,55 @@ namespace DmpWmts | @@ -81,14 +105,55 @@ namespace DmpWmts | ||
81 | } | 105 | } |
82 | else if (boost::iequals(req, "GetCapabilities")) | 106 | else if (boost::iequals(req, "GetCapabilities")) |
83 | { | 107 | { |
108 | + const std::string host_=context.request()->domain()+":"+context.request()->port();; | ||
109 | + const std::string servicename_=getWMTSServiceName(context.request()->path()); | ||
110 | + | ||
111 | + boost::property_tree::ptree pt; | ||
112 | + pt.add("Layer.ows:Title",tileLayer->title()); | ||
113 | + pt.add("Layer.ows:Abstract",tileLayer->abstract()); | ||
114 | + pt.add("Layer.ows:Identifier",""); | ||
115 | + pt.add("Layer.Style",tileLayer->getStyle()); | ||
116 | + pt.add("Layer.Format",tileLayer->getFormat()); | ||
117 | + | ||
118 | + std::vector<DmpTileMatrixSet*> tileMatrixSets; | ||
119 | + tileLayer->getTileMatrixSets(tileMatrixSets); | ||
120 | + | ||
121 | + | ||
122 | + for(auto iter=tileMatrixSets.cbegin();iter!=tileMatrixSets.cend();iter++) | ||
123 | + { | ||
124 | + pt.add("Layer.TileMatrixSetLink.TileMatrixSet",(*iter)->id()); | ||
125 | + | ||
126 | + boost::property_tree::ptree ptLevels_; | ||
127 | + std::vector<TileLevel*> tileLevels_=(*iter)->tileLevels(); | ||
128 | + for(auto leviter=tileLevels_.cbegin();leviter!=tileLevels_.cend();leviter++) | ||
129 | + { | ||
130 | + boost::property_tree::ptree pt_level_; | ||
131 | + | ||
132 | + pt_level_.add("level",(*leviter)->id); | ||
133 | + pt_level_.add("scale",(*leviter)->scaleDenominator); | ||
134 | + pt_level_.add("resolution",(*leviter)->resolution); | ||
135 | + ptLevels_.add_child("TileMatrix",pt_level_); | ||
136 | + } | ||
137 | + pt.add_child("TileMatrixSet.Levels",ptLevels_); | ||
138 | + pt.add("TileMatrixSet.ows:Identifier",(*iter)->id()); | ||
139 | + pt.add("TileMatrixSet.ows:SupportedCRS",(*iter)->crs()); | ||
140 | + pt.add("TileMatrixSet.TileWidth",(*iter)->tileCols()); | ||
141 | + pt.add("TileMatrixSet.TileHeight",(*iter)->tileRows()); | ||
142 | + pt.add("TileMatrixSet.TopLeftCorner",std::to_string((*iter)->tileOrigin()->x())+","+std::to_string((*iter)->tileOrigin()->y())); | ||
143 | + pt.add("TileMatrixSet.DPI",(*iter)->dpi()); | ||
144 | + } | ||
145 | + //boost::property_tree::write_json("/mnt/d/json.txt",pt); | ||
146 | + | ||
147 | + DmpCapabiliTilesOperation capOper; | ||
148 | + capOper.WriteCapabilities(pt,host_,servicename_,*context.response()); | ||
149 | + | ||
84 | } | 150 | } |
85 | 151 | ||
86 | //std::string Msg_,connMsg_; | 152 | //std::string Msg_,connMsg_; |
87 | //std::string strsql_="SELECT \"Id\", \"Name\" FROM public.\"TileMapItem\";"; | 153 | //std::string strsql_="SELECT \"Id\", \"Name\" FROM public.\"TileMapItem\";"; |
88 | //PgsqlUtils *pg_=new PgsqlUtils(connMsg_); | 154 | //PgsqlUtils *pg_=new PgsqlUtils(connMsg_); |
89 | //pg_->ExecuteQuery(strsql_,Msg_); | 155 | //pg_->ExecuteQuery(strsql_,Msg_); |
90 | - // | ||
91 | - | 156 | + |
92 | //获取服务的实例 | 157 | //获取服务的实例 |
93 | // std::string service_name = GetServiceName(context.request()->path()); | 158 | // std::string service_name = GetServiceName(context.request()->path()); |
94 | // DmpService* service_ = GetService(service_name); | 159 | // DmpService* service_ = GetService(service_name); |
请
注册
或
登录
后发表评论