提交 5e556b6613c7140ae85c39b92a017b618c6777c7
Merge branch 'master' of http://gitlab.ctune.cn/DMapServer/DMapServer4.1
正在显示
17 个修改的文件
包含
1431 行增加
和
429 行删除
1 | -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -o -lfcgi++ -lfcgi") | ||
2 | - | ||
3 | -INCLUDE_DIRECTORIES( | ||
4 | - ${CMAKE_SOURCE_DIR}/src/server/spserver | ||
5 | -) | ||
6 | - | ||
7 | - | ||
8 | -ADD_SUBDIRECTORY(spserver) | ||
9 | -ADD_SUBDIRECTORY(services) | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | -######################################################## | ||
14 | -# Files | ||
15 | -SET (DMAP_SERVER_SRCS | ||
16 | - dmpfilterresponsedecorator.cpp | ||
17 | - dmpmainserver.cpp | ||
18 | - dmprequesthandler.cpp | ||
19 | - dmpserver.cpp | ||
20 | - dmpserverapi.cpp | ||
21 | - dmpserverconfig.cpp | ||
22 | - dmpservercontext.cpp | ||
23 | - dmpserverapicontext.cpp | ||
24 | - dmpserverapihandler.cpp | ||
25 | - dmpserverfilter.cpp | ||
26 | - dmpserverinterface.cpp | ||
27 | - dmpserverinterfaceimpl.cpp | ||
28 | - dmpservermanager.cpp | ||
29 | - dmpservermanagerapi.cpp | ||
30 | - dmpserverresponse.cpp | ||
31 | - dmpserverrequest.cpp | ||
32 | - dmpserverparameters.cpp | ||
33 | - dmpserverplugins.cpp | ||
34 | - dmpserverutils.cpp | ||
35 | - dmpserverloader.cpp | ||
36 | - dmpserverproject.cpp | ||
37 | - dmpserverregistry.cpp | ||
38 | - python/dmppythonutils.cpp | ||
39 | - python/dmpserverwrapper.cpp | ||
40 | - dmphttpbase.cpp | ||
41 | - dmphttputils.cpp | ||
42 | -) | ||
43 | - | ||
44 | -SET (DMAP_SERVER_HDRS | ||
45 | - dmpfilterresponsedecorator.h | ||
46 | - dmpmainserver.h | ||
47 | - dmprequesthandler.h | ||
48 | - dmpserver.h | ||
49 | - dmpserverapi.h | ||
50 | - dmpserverapihandler.h | ||
51 | - dmpserverapicontext.h | ||
52 | - dmpservercontext.h | ||
53 | - dmpserverconfig.h | ||
54 | - dmpserverentity.h | ||
55 | - dmpserverfilter.h | ||
56 | - dmpserverinterface.h | ||
57 | - dmpserverinterfaceimpl.h | ||
58 | - dmpservermanager.h | ||
59 | - dmpservermanagerapi.h | ||
60 | - dmpserverrequest.h | ||
61 | - dmpserverresponse.h | ||
62 | - dmpserverparameters.h | ||
63 | - dmpserverplugins.h | ||
64 | - dmpserverutils.h | ||
65 | - dmpservice.h | ||
66 | - dmpservermodule.h | ||
67 | - dmpserverloader.h | ||
68 | - dmpserverproject.h | ||
69 | - dmpserverregistry.h | ||
70 | - python/dmppythonutils.h | ||
71 | - dmphttpbase.h | ||
72 | - dmphttputils.h | ||
73 | -) | ||
74 | - | ||
75 | -############################################################# | ||
76 | -# dmap_server library | ||
77 | - | ||
78 | - | ||
79 | - | ||
80 | -INCLUDE_DIRECTORIES( | ||
81 | - ${CMAKE_SOURCE_DIR}/src/core | ||
82 | - ${CMAKE_SOURCE_DIR}/src/core/geometry | ||
83 | - ${CMAKE_SOURCE_DIR}/src/core/symbology | ||
84 | -) | ||
85 | - | ||
86 | -INCLUDE_DIRECTORIES(SYSTEM | ||
87 | - ${PYTHON_INCLUDE_PATH} | ||
88 | -) | ||
89 | -ADD_LIBRARY(dmap_server SHARED ${DMAP_SERVER_SRCS} ${DMAP_SERVER_HDRS}) | ||
90 | - | ||
91 | -target_link_libraries(dmap_server | ||
92 | - dmap_core | ||
93 | - ${Boost_LIBRARIES} | ||
94 | - Boost::regex | ||
95 | - ${PYTHON_LIBRARIES} | ||
96 | - dl) | ||
97 | - | ||
98 | -IF (WITH_BINDINGS) | ||
99 | - TARGET_LINK_LIBRARIES(dmap_server | ||
100 | - Boost::${DMAP_BOOST_PYTHON_FOUND} | ||
101 | - ) | ||
102 | -ENDIF(WITH_BINDINGS) | ||
103 | - | ||
104 | -set_target_properties(dmap_server | ||
105 | - PROPERTIES | ||
106 | - POSITION_INDEPENDENT_CODE 1 | ||
107 | - CXX_VISIBILITY_PRESET hidden | ||
108 | - VISIBILITY_INLINES_HIDDEN 1 | ||
109 | - #VERSION ${COMPLETE_VERSION} | ||
110 | - #SOVERSION ${COMPLETE_VERSION} | ||
111 | - ) | ||
112 | - | ||
113 | -generate_export_header( | ||
114 | - dmap_server | ||
115 | - BASE_NAME SERVER | ||
116 | - EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/dmap_server.h" | ||
117 | -) | ||
118 | - | ||
119 | - | ||
120 | -target_include_directories(dmap_server | ||
121 | - PUBLIC | ||
122 | - ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR} | ||
123 | - ) | ||
124 | - MESSAGE(STATUS "dmap_server path: ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}") | ||
125 | - | ||
126 | - | ||
127 | -add_executable(dmap_spserv | ||
128 | - dmap_spserv.cpp | ||
129 | - dmpspserverrequest.h | ||
130 | - dmpspserverresponse.h | ||
131 | - dmpspserverrequest.cpp | ||
132 | - dmpspserverresponse.cpp | ||
133 | -) | ||
134 | - | ||
135 | -add_executable(dmap_serv | ||
136 | - dmap_serv.cpp | ||
137 | - dmpapacheserverrequest.h | ||
138 | - dmpapacheserverresponse.h | ||
139 | - dmpapacheserverrequest.cpp | ||
140 | - dmpapacheserverresponse.cpp | ||
141 | -) | ||
142 | - | ||
143 | -target_link_libraries(dmap_spserv | ||
144 | - spserver | ||
145 | - dmap_server | ||
146 | - ) | ||
147 | - | ||
148 | -target_link_libraries(dmap_serv | ||
149 | - dmap_server | ||
150 | -) | ||
151 | - | ||
152 | -INCLUDE_DIRECTORIES( | ||
153 | - ${CMAKE_SOURCE_DIR}/pgsql/include | ||
154 | -) | ||
155 | -LINK_DIRECTORIES(dmap_server ${CMAKE_SOURCE_DIR}/pgsql/lib) | ||
156 | -TARGET_LINK_LIBRARIES(dmap_server ${CMAKE_SOURCE_DIR}/pgsql/lib/libpq.so) | ||
157 | - | ||
158 | -find_package(Fcgi REQUIRED) | ||
159 | -if (NOT FCGI_FOUND) | ||
160 | - message (SEND_ERROR "Fast CGI dependency was not found!") | ||
161 | -endif() | ||
162 | - | ||
163 | -target_include_directories(dmap_serv SYSTEM PRIVATE | ||
164 | - ${FCGI_INCLUDE_DIR} | ||
165 | -) | ||
166 | -target_link_libraries(dmap_serv | ||
167 | - ${FCGI_LIBRARY} | ||
168 | -) | ||
169 | -######################################################## | ||
170 | -# Install | ||
171 | -INSTALL(FILES | ||
172 | - dmpserver.ini | ||
173 | - DESTINATION ${DMAP_LIBEXEC_SUBDIR} | ||
174 | -) | ||
175 | - | ||
176 | -INSTALL(TARGETS dmap_server | ||
177 | - RUNTIME DESTINATION ${DMAP_BIN_DIR} | ||
178 | - LIBRARY DESTINATION ${DMAP_LIB_DIR} | ||
179 | - ARCHIVE DESTINATION ${DMAP_LIB_DIR} | ||
180 | - PUBLIC_HEADER DESTINATION ${DMAP_INCLUDE_DIR} | ||
181 | -) | ||
182 | - | ||
183 | -INSTALL(TARGETS dmap_serv | ||
184 | - DESTINATION ${DMAP_BIN_DIR} | ||
185 | -) | ||
186 | - | ||
187 | -INSTALL(TARGETS dmap_spserv | ||
188 | - DESTINATION ${DMAP_BIN_DIR} | 1 | + |
2 | +INCLUDE_DIRECTORIES( | ||
3 | + ${CMAKE_SOURCE_DIR}/src/server/spserver | ||
4 | +) | ||
5 | + | ||
6 | +ADD_SUBDIRECTORY(spserver) | ||
7 | +ADD_SUBDIRECTORY(services) | ||
8 | + | ||
9 | +######################################################## | ||
10 | +# Files | ||
11 | +SET (DMAP_SERVER_SRCS | ||
12 | + dmpfilterresponsedecorator.cpp | ||
13 | + dmpmainserver.cpp | ||
14 | + dmprequesthandler.cpp | ||
15 | + dmpserver.cpp | ||
16 | + dmpservice.cpp | ||
17 | + dmpservercontext.cpp | ||
18 | + dmpserverapihandler.cpp | ||
19 | + dmpserverfilter.cpp | ||
20 | + dmpserverinterface.cpp | ||
21 | + dmpserverinterfaceimpl.cpp | ||
22 | + dmpservermanager.cpp | ||
23 | + dmpservermanagerapi.cpp | ||
24 | + dmpserverresponse.cpp | ||
25 | + dmpserverrequest.cpp | ||
26 | + dmpserverparameters.cpp | ||
27 | + dmpserverplugins.cpp | ||
28 | + dmpserverutils.cpp | ||
29 | + dmpservernativeloader.cpp | ||
30 | + python/dmppythonutils.cpp | ||
31 | + python/dmpserverwrapper.cpp | ||
32 | +) | ||
33 | + | ||
34 | +SET (DMAP_SERVER_HDRS | ||
35 | + dmpfilterresponsedecorator.h | ||
36 | + dmpmainserver.h | ||
37 | + dmprequesthandler.h | ||
38 | + dmpserver.h | ||
39 | + dmpserverapihandler.h | ||
40 | + dmpservercontext.h | ||
41 | + dmpserverfilter.h | ||
42 | + dmpserverinterface.h | ||
43 | + dmpserverinterfaceimpl.h | ||
44 | + dmpservermanager.h | ||
45 | + dmpservermanagerapi.h | ||
46 | + dmpserverrequest.h | ||
47 | + dmpserverresponse.h | ||
48 | + dmpserverparameters.h | ||
49 | + dmpserverplugins.h | ||
50 | + dmpserverutils.h | ||
51 | + dmpservice.h | ||
52 | + dmpservermodule.h | ||
53 | + dmpservernativeloader.h | ||
54 | + python/dmppythonutils.h | ||
55 | +) | ||
56 | + | ||
57 | +############################################################# | ||
58 | +# dmap_server library | ||
59 | + | ||
60 | +INCLUDE_DIRECTORIES( | ||
61 | + ${CMAKE_SOURCE_DIR}/src/core | ||
62 | +) | ||
63 | + | ||
64 | +INCLUDE_DIRECTORIES(SYSTEM | ||
65 | + ${PYTHON_INCLUDE_PATH} | ||
66 | +) | ||
67 | +ADD_LIBRARY(dmap_server SHARED ${DMAP_SERVER_SRCS} ${DMAP_SERVER_HDRS}) | ||
68 | + | ||
69 | +target_link_libraries(dmap_server | ||
70 | + dmap_core | ||
71 | + ${Boost_LIBRARIES} | ||
72 | + Boost::regex | ||
73 | + ${PYTHON_LIBRARIES} | ||
74 | + dl) | ||
75 | + | ||
76 | +IF (WITH_BINDINGS) | ||
77 | + TARGET_LINK_LIBRARIES(dmap_server | ||
78 | + Boost::${DMAP_BOOST_PYTHON_FOUND} | ||
79 | + ) | ||
80 | +ENDIF(WITH_BINDINGS) | ||
81 | + | ||
82 | +set_target_properties(dmap_server | ||
83 | + PROPERTIES | ||
84 | + POSITION_INDEPENDENT_CODE 1 | ||
85 | + CXX_VISIBILITY_PRESET hidden | ||
86 | + VISIBILITY_INLINES_HIDDEN 1 | ||
87 | + #VERSION ${COMPLETE_VERSION} | ||
88 | + #SOVERSION ${COMPLETE_VERSION} | ||
89 | + ) | ||
90 | + | ||
91 | +generate_export_header( | ||
92 | + dmap_server | ||
93 | + BASE_NAME SERVER | ||
94 | + EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/dmap_server.h" | ||
95 | +) | ||
96 | + | ||
97 | + | ||
98 | +target_include_directories(dmap_server | ||
99 | + PUBLIC | ||
100 | + ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR} | ||
101 | + ) | ||
102 | + MESSAGE(STATUS "dmap_server path: ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}") | ||
103 | + | ||
104 | +add_executable(dmap_spserv | ||
105 | + dmap_spserv.cpp | ||
106 | + dmpspserverrequest.h | ||
107 | + dmpspserverresponse.h | ||
108 | + dmpspserverrequest.cpp | ||
109 | + dmpspserverresponse.cpp | ||
110 | +) | ||
111 | + | ||
112 | +target_link_libraries(dmap_spserv | ||
113 | + spserver | ||
114 | + dmap_server | ||
115 | + ) | ||
116 | + | ||
117 | +######################################################## | ||
118 | +# Install | ||
119 | + | ||
120 | +INSTALL(TARGETS dmap_server | ||
121 | + RUNTIME DESTINATION ${DMAP_BIN_DIR} | ||
122 | + LIBRARY DESTINATION ${DMAP_LIB_DIR} | ||
123 | + ARCHIVE DESTINATION ${DMAP_LIB_DIR} | ||
124 | + PUBLIC_HEADER DESTINATION ${DMAP_INCLUDE_DIR} | ||
125 | +) | ||
126 | + | ||
127 | +INSTALL(TARGETS dmap_spserv | ||
128 | + DESTINATION ${DMAP_BIN_DIR} | ||
189 | ) | 129 | ) |
@@ -54,25 +54,25 @@ if (temp_data.find(http_) == 0) { | @@ -54,25 +54,25 @@ if (temp_data.find(http_) == 0) { | ||
54 | int DmpHttp::DmpHttpBase::buildPostRequest(const std::string& server, const std::string& path, | 54 | int DmpHttp::DmpHttpBase::buildPostRequest(const std::string& server, const std::string& path, |
55 | std::ostream& out_request) { | 55 | std::ostream& out_request) { |
56 | // 分割path中的json数据 | 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(); | 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; | 76 | return HTTP_SUCCESS; |
77 | } | 77 | } |
78 | 78 |
@@ -15,15 +15,15 @@ DmpHttp::DmpHttpUtils::~DmpHttpUtils() {} | @@ -15,15 +15,15 @@ DmpHttp::DmpHttpUtils::~DmpHttpUtils() {} | ||
15 | 15 | ||
16 | int DmpHttp::DmpHttpUtils::post(const std::string& url) | 16 | int DmpHttp::DmpHttpUtils::post(const std::string& url) |
17 | { | 17 | { |
18 | - handle_request_resolve(url, DmpHttpBase::buildPostRequest); | 18 | + handleRequestResolve(url, DmpHttpBase::buildPostRequest); |
19 | return HTTP_SUCCESS; | 19 | return HTTP_SUCCESS; |
20 | } | 20 | } |
21 | int DmpHttp::DmpHttpUtils::get(const std::string& url) | 21 | int DmpHttp::DmpHttpUtils::get(const std::string& url) |
22 | { | 22 | { |
23 | - handle_request_resolve(url, DmpHttpBase::buildGetRequest); | 23 | + handleRequestResolve(url, DmpHttpBase::buildGetRequest); |
24 | return HTTP_SUCCESS; | 24 | return HTTP_SUCCESS; |
25 | } | 25 | } |
26 | -void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuildRequest func) { | 26 | +void DmpHttp::DmpHttpUtils::handleRequestResolve(const std::string& url, pBuildRequest func) { |
27 | try { | 27 | try { |
28 | responseData_.clear(); | 28 | responseData_.clear(); |
29 | // 解析URL | 29 | // 解析URL |
@@ -37,7 +37,7 @@ void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuil | @@ -37,7 +37,7 @@ void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuil | ||
37 | // 解析服务地址\端口 | 37 | // 解析服务地址\端口 |
38 | boost::asio::ip::tcp::resolver::query query(server, port); | 38 | boost::asio::ip::tcp::resolver::query query(server, port); |
39 | resolver_.async_resolve(query, | 39 | resolver_.async_resolve(query, |
40 | - boost::bind(&DmpHttpUtils::handle_resolve, this, | 40 | + boost::bind(&DmpHttpUtils::handleResolve, this, |
41 | boost::asio::placeholders::error, | 41 | boost::asio::placeholders::error, |
42 | boost::asio::placeholders::iterator)); | 42 | boost::asio::placeholders::iterator)); |
43 | } | 43 | } |
@@ -47,7 +47,7 @@ void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuil | @@ -47,7 +47,7 @@ void DmpHttp::DmpHttpUtils::handle_request_resolve(const std::string& url, pBuil | ||
47 | } | 47 | } |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | -void DmpHttp::DmpHttpUtils::handle_resolve(const boost::system::error_code& err, | 50 | +void DmpHttp::DmpHttpUtils::handleResolve(const boost::system::error_code& err, |
51 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { | 51 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { |
52 | if (err) { | 52 | if (err) { |
53 | std::cout << "Error: " << err << "\n"; | 53 | std::cout << "Error: " << err << "\n"; |
@@ -55,30 +55,30 @@ void DmpHttp::DmpHttpUtils::handle_resolve(const boost::system::error_code& err, | @@ -55,30 +55,30 @@ void DmpHttp::DmpHttpUtils::handle_resolve(const boost::system::error_code& err, | ||
55 | } | 55 | } |
56 | // 尝试连接 | 56 | // 尝试连接 |
57 | boost::asio::async_connect(socket_, endpoint_iterator, | 57 | boost::asio::async_connect(socket_, endpoint_iterator, |
58 | - boost::bind(&DmpHttpUtils::handle_connect, this, | 58 | + boost::bind(&DmpHttpUtils::handleConnect, this, |
59 | boost::asio::placeholders::error)); | 59 | boost::asio::placeholders::error)); |
60 | } | 60 | } |
61 | -void DmpHttp::DmpHttpUtils::handle_connect(const boost::system::error_code& err) { | 61 | +void DmpHttp::DmpHttpUtils::handleConnect(const boost::system::error_code& err) { |
62 | if (err) { | 62 | if (err) { |
63 | std::cout << "Error: " << err << "\n"; | 63 | std::cout << "Error: " << err << "\n"; |
64 | return; | 64 | return; |
65 | } | 65 | } |
66 | // 发送request请求 | 66 | // 发送request请求 |
67 | boost::asio::async_write(socket_, request_, | 67 | boost::asio::async_write(socket_, request_, |
68 | - boost::bind(&DmpHttpUtils::handle_write_request, this, | 68 | + boost::bind(&DmpHttpUtils::handleWriteRequest, this, |
69 | boost::asio::placeholders::error)); | 69 | boost::asio::placeholders::error)); |
70 | } | 70 | } |
71 | -void DmpHttp::DmpHttpUtils::handle_write_request(const boost::system::error_code& err) { | 71 | +void DmpHttp::DmpHttpUtils::handleWriteRequest(const boost::system::error_code& err) { |
72 | if (err) { | 72 | if (err) { |
73 | std::cout << "Error: " << err << "\n"; | 73 | std::cout << "Error: " << err << "\n"; |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | // 异步持续读数据到response_,直到接收协议符号 \r\n 为止 | 76 | // 异步持续读数据到response_,直到接收协议符号 \r\n 为止 |
77 | boost::asio::async_read_until(socket_, response_, "\r\n", | 77 | boost::asio::async_read_until(socket_, response_, "\r\n", |
78 | - boost::bind(&DmpHttpUtils::handle_read_status_line, this, | 78 | + boost::bind(&DmpHttpUtils::handleReadStatusLine, this, |
79 | boost::asio::placeholders::error)); | 79 | boost::asio::placeholders::error)); |
80 | } | 80 | } |
81 | -void DmpHttp::DmpHttpUtils::handle_read_status_line(const boost::system::error_code& err) { | 81 | +void DmpHttp::DmpHttpUtils::handleReadStatusLine(const boost::system::error_code& err) { |
82 | if (err) { | 82 | if (err) { |
83 | std::cout << "Error: " << err << "\n"; | 83 | std::cout << "Error: " << err << "\n"; |
84 | return; | 84 | return; |
@@ -102,11 +102,11 @@ void DmpHttp::DmpHttpUtils::handle_read_status_line(const boost::system::error_c | @@ -102,11 +102,11 @@ void DmpHttp::DmpHttpUtils::handle_read_status_line(const boost::system::error_c | ||
102 | } | 102 | } |
103 | // 读取响应头,直到接收协议符号 \r\n\r\n 为止 | 103 | // 读取响应头,直到接收协议符号 \r\n\r\n 为止 |
104 | boost::asio::async_read_until(socket_, response_, "\r\n\r\n", | 104 | boost::asio::async_read_until(socket_, response_, "\r\n\r\n", |
105 | - boost::bind(&DmpHttpUtils::handle_read_headers, this, | 105 | + boost::bind(&DmpHttpUtils::handleReadHeaders, this, |
106 | boost::asio::placeholders::error)); | 106 | boost::asio::placeholders::error)); |
107 | } | 107 | } |
108 | 108 | ||
109 | -void DmpHttp::DmpHttpUtils::handle_read_headers(const boost::system::error_code& err) { | 109 | +void DmpHttp::DmpHttpUtils::handleReadHeaders(const boost::system::error_code& err) { |
110 | if (err) { | 110 | if (err) { |
111 | std::cout << "Error: " << err << "\n"; | 111 | std::cout << "Error: " << err << "\n"; |
112 | return; | 112 | return; |
@@ -135,10 +135,10 @@ void DmpHttp::DmpHttpUtils::handle_read_headers(const boost::system::error_code& | @@ -135,10 +135,10 @@ void DmpHttp::DmpHttpUtils::handle_read_headers(const boost::system::error_code& | ||
135 | // 开始读取剩余所有内容 | 135 | // 开始读取剩余所有内容 |
136 | boost::asio::async_read(socket_, response_, | 136 | boost::asio::async_read(socket_, response_, |
137 | boost::asio::transfer_at_least(1), | 137 | boost::asio::transfer_at_least(1), |
138 | - boost::bind(&DmpHttpUtils::handle_read_content, this, | 138 | + boost::bind(&DmpHttpUtils::handleReadContent, this, |
139 | boost::asio::placeholders::error)); | 139 | boost::asio::placeholders::error)); |
140 | } | 140 | } |
141 | -void DmpHttp::DmpHttpUtils::handle_read_content(const boost::system::error_code& err) { | 141 | +void DmpHttp::DmpHttpUtils::handleReadContent(const boost::system::error_code& err) { |
142 | if (!err) { | 142 | if (!err) { |
143 | 143 | ||
144 | // 输出读到的数据 | 144 | // 输出读到的数据 |
@@ -152,7 +152,7 @@ void DmpHttp::DmpHttpUtils::handle_read_content(const boost::system::error_code& | @@ -152,7 +152,7 @@ void DmpHttp::DmpHttpUtils::handle_read_content(const boost::system::error_code& | ||
152 | // 继续读取剩余内容,直到读到EOF | 152 | // 继续读取剩余内容,直到读到EOF |
153 | boost::asio::async_read(socket_, response_, | 153 | boost::asio::async_read(socket_, response_, |
154 | boost::asio::transfer_at_least(1), | 154 | boost::asio::transfer_at_least(1), |
155 | - boost::bind(&DmpHttpUtils::handle_read_content, this, | 155 | + boost::bind(&DmpHttpUtils::handleReadContent, this, |
156 | boost::asio::placeholders::error)); | 156 | boost::asio::placeholders::error)); |
157 | 157 | ||
158 | } | 158 | } |
@@ -25,20 +25,20 @@ namespace DmpHttp | @@ -25,20 +25,20 @@ namespace DmpHttp | ||
25 | virtual std::string getResponse(void) {return responseData_;} | 25 | virtual std::string getResponse(void) {return responseData_;} |
26 | private: | 26 | private: |
27 | // 建立请求 | 27 | // 建立请求 |
28 | - void handle_request_resolve(const std::string& url, pBuildRequest func); | 28 | + void handleRequestResolve(const std::string& url, pBuildRequest func); |
29 | // 解析后 | 29 | // 解析后 |
30 | - void handle_resolve(const boost::system::error_code& err, | 30 | + void handleResolve(const boost::system::error_code& err, |
31 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator); | 31 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator); |
32 | // 连接后 | 32 | // 连接后 |
33 | - void handle_connect(const boost::system::error_code& err); | 33 | + void handleConnect(const boost::system::error_code& err); |
34 | // 发送请求后 | 34 | // 发送请求后 |
35 | - void handle_write_request(const boost::system::error_code& err); | 35 | + void handleWriteRequest(const boost::system::error_code& err); |
36 | // 读取响应后 | 36 | // 读取响应后 |
37 | - void handle_read_status_line(const boost::system::error_code& err); | 37 | + void handleReadStatusLine(const boost::system::error_code& err); |
38 | // 读取响应头后 | 38 | // 读取响应头后 |
39 | - void handle_read_headers(const boost::system::error_code& err); | 39 | + void handleReadHeaders(const boost::system::error_code& err); |
40 | // 读取正文数据后 | 40 | // 读取正文数据后 |
41 | - void handle_read_content(const boost::system::error_code& err); | 41 | + void handleReadContent(const boost::system::error_code& err); |
42 | private: | 42 | private: |
43 | // 解析器 | 43 | // 解析器 |
44 | boost::asio::ip::tcp::resolver resolver_; | 44 | boost::asio::ip::tcp::resolver resolver_; |
1 | -/************************************************************************** | ||
2 | -* file: dmpservermanager.cpp | ||
3 | - | ||
4 | -* Author: wanzhongping | ||
5 | -* Date: 2021-07-27 21:59:46 | ||
6 | -* Email: zhongpingw@chinadci.com | ||
7 | -* copyright: 广州城市信息研究所有限公司 | ||
8 | -***************************************************************************/ | ||
9 | -#include "dmpservermanager.h" | ||
10 | -#include "dmpserver.h" | ||
11 | -#include "dmphttputils.h" | ||
12 | -#include "dmpserverConfig.h" | ||
13 | -#include <memory> | ||
14 | -#include <boost/property_tree/ptree.hpp> | ||
15 | -#include <boost/property_tree/json_parser.hpp> | ||
16 | -#include <boost/property_tree/xml_parser.hpp> | ||
17 | -#include <sstream> | ||
18 | -#include <fstream> | ||
19 | -#include <iostream> | ||
20 | -#include "dmplogger.h" | ||
21 | - | ||
22 | - | ||
23 | -DmpServerManager::DmpServerManager() | ||
24 | -{ | ||
25 | - serverRegistry_ = new DmpServerRegistry(); | ||
26 | -} | ||
27 | - | ||
28 | -DmpServerManager::~DmpServerManager() | ||
29 | -{ | ||
30 | - if (serverRegistry_) | ||
31 | - { | ||
32 | - delete serverRegistry_; | ||
33 | - serverRegistry_ = NULL; | ||
34 | - } | ||
35 | - | ||
36 | - ProjectMap::iterator iter = projects_.begin(); | ||
37 | - for (; iter != projects_.end(); ++iter) | ||
38 | - { | ||
39 | - DmpProject *mapProject = iter->second; | ||
40 | - if (mapProject) | ||
41 | - { | ||
42 | - delete mapProject; | ||
43 | - mapProject = nullptr; | ||
44 | - } | ||
45 | - } | ||
46 | - projects_.clear(); | ||
47 | -} | ||
48 | - | ||
49 | -void DmpServerManager::init(const boost::filesystem::path &modulePath) | ||
50 | -{ | ||
51 | - serverRegistry_->init(modulePath); | ||
52 | - | ||
53 | - if(!LoadServices()) | ||
54 | - { | ||
55 | - std::cout << "加载服务失败!" << std::endl; | ||
56 | - LOGGER_ERROR("加载服务失败!"); | ||
57 | - } | ||
58 | -} | ||
59 | - | ||
60 | -std::string DmpServerManager::getCapabilities() | ||
61 | -{ | ||
62 | - return serverRegistry_->getCapabilities(); | ||
63 | -} | ||
64 | - | ||
65 | -std::shared_ptr<DmpServer> DmpServerManager::serverForRequest(const DmpServerRequest &request) | ||
66 | -{ | ||
67 | - return serverRegistry_->getServerForRequest(request); | ||
68 | -} | ||
69 | - | ||
70 | -std::shared_ptr<DmpServerApi> DmpServerManager::apiForRequest(const DmpServerRequest &request) | ||
71 | -{ | ||
72 | - return serverRegistry_->getApiForRequest(request); | ||
73 | -} | ||
74 | - | ||
75 | -DmpProject *DmpServerManager::getProject(const std::string &serviceName) | ||
76 | -{ | ||
77 | - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | ||
78 | - if (iter != projects_.end()) | ||
79 | - { | ||
80 | - return iter->second; | ||
81 | - } | ||
82 | - else | ||
83 | - { | ||
84 | - return nullptr; | ||
85 | - } | ||
86 | -} | ||
87 | - | ||
88 | -bool DmpServerManager::removeProject(const std::string &serviceName) | ||
89 | -{ | ||
90 | - try | ||
91 | - { | ||
92 | - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | ||
93 | - if (iter != projects_.end()) | ||
94 | - { | ||
95 | - delete iter->second; | ||
96 | - projects_.erase(iter); | ||
97 | - } | ||
98 | - } | ||
99 | - catch (const std::exception &e) | ||
100 | - { | ||
101 | - std::cerr << e.what() << '\n'; | ||
102 | - return false; | ||
103 | - } | ||
104 | - return true; | ||
105 | -} | ||
106 | - | ||
107 | -bool DmpServerManager::publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData) | ||
108 | -{ | ||
109 | - //project | ||
110 | - std::string projData; | ||
111 | - if (!DmpServerUtils::Base64Decode(projectData, &projData)) | ||
112 | - { | ||
113 | - return false; | ||
114 | - } | ||
115 | - DmpProject *project = new DmpProject(); | ||
116 | - if (!project->Read(projData)) | ||
117 | - { | ||
118 | - delete project; | ||
119 | - return false; | ||
120 | - } | ||
121 | - | ||
122 | - if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project)) | ||
123 | - { | ||
124 | - delete project; | ||
125 | - return false; | ||
126 | - } | ||
127 | - projects_[serviceName] = project; | ||
128 | - return true; | ||
129 | -} | ||
130 | - | ||
131 | -bool DmpServerManager::deleteService(const std::string &serverName, const std::string &serviceName) | ||
132 | -{ | ||
133 | - if (serverRegistry_->getServer(serverName)->remove(serviceName) && removeProject(serviceName)) | ||
134 | - { | ||
135 | - return true; | ||
136 | - } | ||
137 | - else | ||
138 | - { | ||
139 | - return false; | ||
140 | - } | ||
141 | -} | ||
142 | - | ||
143 | -bool DmpServerManager::startService(const std::string &serverName, const std::string &serviceName) | ||
144 | -{ | ||
145 | - return serverRegistry_->getServer(serverName)->start(serviceName); | ||
146 | -} | ||
147 | - | ||
148 | -bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName) | ||
149 | -{ | ||
150 | - return serverRegistry_->getServer(serverName)->stop(serviceName); | ||
151 | -} | ||
152 | -bool DmpServerManager::LoadServices() | ||
153 | -{ | ||
154 | - boost::property_tree::ptree pt,ptList; | ||
155 | - std::string conn = DmpServerConfig::Instance()->getMetaUrl(); | ||
156 | - const std::string url= conn + URI_RELOAD; | ||
157 | - std::string strContent=DmpHttp::get(url); | ||
158 | - if(strContent.length()==0) | ||
159 | - { | ||
160 | - return false; | ||
161 | - } | ||
162 | - | ||
163 | - ////测试响应内容写入文本 | ||
164 | - // std::ofstream examplefile ("/mnt/d/example.txt"); | ||
165 | - // if (examplefile.is_open()) { | ||
166 | - // examplefile << DmpHttp::get(url_); | ||
167 | - // examplefile.close(); | ||
168 | - // } | ||
169 | - //boost::property_tree::read_json("./example.txt", pt_); | ||
170 | - | ||
171 | - std::stringstream ssData; | ||
172 | - ssData<<strContent.c_str(); | ||
173 | - boost::property_tree::read_json(ssData, pt); | ||
174 | - int iCount = std::atoi(pt.get<std::string>("data.count").c_str()); | ||
175 | - if(iCount>0) | ||
176 | - { | ||
177 | - ptList=pt.get_child("data.list"); | ||
178 | - for (auto& e : ptList) | ||
179 | - { | ||
180 | - std::string name = e.second.get<std::string>("name"); | ||
181 | - std::string title = e.second.get<std::string>("title"); | ||
182 | - std::string type = e.second.get<std::string>("type"); | ||
183 | - int capabilities =e.second.get<int>("capabilities"); | ||
184 | - std::string project = e.second.get<std::string>("project"); | ||
185 | - this->publish(type,name,title,capabilities,project); | ||
186 | - } | ||
187 | - } | ||
188 | - return true; | 1 | +/************************************************************************** |
2 | +* file: dmpservermanager.cpp | ||
3 | + | ||
4 | +* Author: wanzhongping | ||
5 | +* Date: 2021-07-27 21:59:46 | ||
6 | +* Email: zhongpingw@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpservermanager.h" | ||
10 | +#include "dmpserver.h" | ||
11 | +#include "dmphttputils.h" | ||
12 | +#include "dmpserverConfig.h" | ||
13 | +#include <memory> | ||
14 | +#include <boost/property_tree/ptree.hpp> | ||
15 | +#include <boost/property_tree/json_parser.hpp> | ||
16 | +#include <boost/property_tree/xml_parser.hpp> | ||
17 | +#include <sstream> | ||
18 | +#include <fstream> | ||
19 | +#include <math.h> | ||
20 | +#include "dmptilelayer.h" | ||
21 | +#include <iostream> | ||
22 | +#include "dmplogger.h" | ||
23 | +#include "dmptilelayer.h" | ||
24 | + | ||
25 | +DmpServerManager::DmpServerManager() | ||
26 | +{ | ||
27 | + serverRegistry_ = new DmpServerRegistry(); | ||
28 | +} | ||
29 | + | ||
30 | +DmpServerManager::~DmpServerManager() | ||
31 | +{ | ||
32 | + if (serverRegistry_) | ||
33 | + { | ||
34 | + delete serverRegistry_; | ||
35 | + serverRegistry_ = NULL; | ||
36 | + } | ||
37 | + | ||
38 | + ProjectMap::iterator iter = projects_.begin(); | ||
39 | + for (; iter != projects_.end(); ++iter) | ||
40 | + { | ||
41 | + DmpProject *mapProject = iter->second; | ||
42 | + if (mapProject) | ||
43 | + { | ||
44 | + delete mapProject; | ||
45 | + mapProject = nullptr; | ||
46 | + } | ||
47 | + } | ||
48 | + projects_.clear(); | ||
49 | +} | ||
50 | + | ||
51 | +void DmpServerManager::init(const boost::filesystem::path &modulePath) | ||
52 | +{ | ||
53 | + serverRegistry_->init(modulePath); | ||
54 | + if(!loadServices()) | ||
55 | + { | ||
56 | + std::cout << "加载服务失败!" << std::endl; | ||
57 | + LOGGER_ERROR("加载服务失败!"); | ||
58 | + } | ||
59 | + //LoadDmpServices(); | ||
60 | +} | ||
61 | + | ||
62 | +std::string DmpServerManager::getCapabilities() | ||
63 | +{ | ||
64 | + return serverRegistry_->getCapabilities(); | ||
65 | +} | ||
66 | + | ||
67 | +std::shared_ptr<DmpServer> DmpServerManager::serverForRequest(const DmpServerRequest &request) | ||
68 | +{ | ||
69 | + return serverRegistry_->getServerForRequest(request); | ||
70 | +} | ||
71 | + | ||
72 | +std::shared_ptr<DmpServerApi> DmpServerManager::apiForRequest(const DmpServerRequest &request) | ||
73 | +{ | ||
74 | + return serverRegistry_->getApiForRequest(request); | ||
75 | +} | ||
76 | + | ||
77 | +DmpProject *DmpServerManager::getProject(const std::string &serviceName) | ||
78 | +{ | ||
79 | + std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | ||
80 | + if (iter != projects_.end()) | ||
81 | + { | ||
82 | + return iter->second; | ||
83 | + } | ||
84 | + else | ||
85 | + { | ||
86 | + return nullptr; | ||
87 | + } | ||
88 | +} | ||
89 | + | ||
90 | +bool DmpServerManager::removeProject(const std::string &serviceName) | ||
91 | +{ | ||
92 | + try | ||
93 | + { | ||
94 | + std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | ||
95 | + if (iter != projects_.end()) | ||
96 | + { | ||
97 | + delete iter->second; | ||
98 | + projects_.erase(iter); | ||
99 | + } | ||
100 | + } | ||
101 | + catch (const std::exception &e) | ||
102 | + { | ||
103 | + std::cerr << e.what() << '\n'; | ||
104 | + return false; | ||
105 | + } | ||
106 | + return true; | ||
107 | +} | ||
108 | + | ||
109 | +bool DmpServerManager::publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData) | ||
110 | +{ | ||
111 | + //project | ||
112 | + std::string projData; | ||
113 | + if (!DmpServerUtils::Base64Decode(projectData, &projData)) | ||
114 | + { | ||
115 | + return false; | ||
116 | + } | ||
117 | + DmpProject *project = new DmpProject(); | ||
118 | + if (!project->Read(projData)) | ||
119 | + { | ||
120 | + delete project; | ||
121 | + return false; | ||
122 | + } | ||
123 | + | ||
124 | + if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project)) | ||
125 | + { | ||
126 | + delete project; | ||
127 | + return false; | ||
128 | + } | ||
129 | + projects_[serviceName] = project; | ||
130 | + | ||
131 | + return true; | ||
132 | +} | ||
133 | + | ||
134 | +bool DmpServerManager::deleteService(const std::string &serverName, const std::string &serviceName) | ||
135 | +{ | ||
136 | + if (serverRegistry_->getServer(serverName)->remove(serviceName) && removeProject(serviceName)) | ||
137 | + { | ||
138 | + return true; | ||
139 | + } | ||
140 | + else | ||
141 | + { | ||
142 | + return false; | ||
143 | + } | ||
144 | +} | ||
145 | + | ||
146 | +bool DmpServerManager::startService(const std::string &serverName, const std::string &serviceName) | ||
147 | +{ | ||
148 | + return serverRegistry_->getServer(serverName)->start(serviceName); | ||
149 | +} | ||
150 | + | ||
151 | +bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName) | ||
152 | +{ | ||
153 | + return serverRegistry_->getServer(serverName)->stop(serviceName); | ||
154 | +} | ||
155 | +bool DmpServerManager::loadServices() | ||
156 | +{ | ||
157 | + boost::property_tree::ptree pt,ptList; | ||
158 | + std::string conn = DmpServerConfig::Instance()->getMetaUrl(); | ||
159 | + const std::string url= conn + URI_RELOAD; | ||
160 | + std::string strContent=DmpHttp::get(url); | ||
161 | + if(strContent.length()==0) | ||
162 | + { | ||
163 | + return false; | ||
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->initServices(type,name,title,capabilities,project); | ||
180 | + } | ||
181 | + } | ||
182 | + return true; | ||
183 | +} | ||
184 | +bool DmpServerManager::initServices(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData) | ||
185 | +{ | ||
186 | + //project | ||
187 | + std::string projData; | ||
188 | + if (!DmpServerUtils::Base64Decode(projectData, &projData)) | ||
189 | + { | ||
190 | + return false; | ||
191 | + } | ||
192 | + DmpProject *project = new DmpProject(); | ||
193 | + if (!project->Read(projData)) | ||
194 | + { | ||
195 | + delete project; | ||
196 | + return false; | ||
197 | + } | ||
198 | + | ||
199 | + if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project)) | ||
200 | + { | ||
201 | + delete project; | ||
202 | + return false; | ||
203 | + } | ||
204 | + projects_[serviceName] = project; | ||
205 | + return true; | ||
189 | } | 206 | } |
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | #include "dmpserverrequest.h" | 19 | #include "dmpserverrequest.h" |
20 | #include "dmpserverregistry.h" | 20 | #include "dmpserverregistry.h" |
21 | 21 | ||
22 | + | ||
22 | #define URI_RELOAD ("/API/Service/TileService/Reload") //加载已注册服务接口 | 23 | #define URI_RELOAD ("/API/Service/TileService/Reload") //加载已注册服务接口 |
23 | class SERVER_EXPORT DmpServerManager | 24 | class SERVER_EXPORT DmpServerManager |
24 | { | 25 | { |
@@ -37,7 +38,12 @@ public: | @@ -37,7 +38,12 @@ public: | ||
37 | DmpProject* getProject(const std::string& serviceName); | 38 | DmpProject* getProject(const std::string& serviceName); |
38 | bool removeProject(const std::string& serviceName); | 39 | bool removeProject(const std::string& serviceName); |
39 | std::string getCapabilities(); | 40 | std::string getCapabilities(); |
40 | - bool LoadServices(); | 41 | + bool loadServices(); |
42 | + //初始化加载服务 | ||
43 | + bool initServices(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData); | ||
44 | + // bool ctreatTmsThumbnail() ; | ||
45 | + // bool ctreatWmtsThumbnail() ; | ||
46 | + // bool BufferCopy(cairo_surface_t *pClsCSFrom, cairo_surface_t *pClsCSTo,cairo_t *cr,int x,int y); | ||
41 | 47 | ||
42 | private: | 48 | private: |
43 | typedef std::map<std::string, DmpProject*, ci_less> ProjectMap; | 49 | typedef std::map<std::string, DmpProject*, ci_less> ProjectMap; |
@@ -54,4 +60,5 @@ struct ServicesData | @@ -54,4 +60,5 @@ struct ServicesData | ||
54 | std::string project; | 60 | std::string project; |
55 | }; | 61 | }; |
56 | 62 | ||
63 | + | ||
57 | #endif // __dmpservermanager_h__ | 64 | #endif // __dmpservermanager_h__ |
src/server/dmptilethumbnail.cpp
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmptilethumbnail.cpp | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-23 15:33:50 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmptilethumbnail.h" | ||
10 | +#include <iostream> | ||
11 | +#include <string> | ||
12 | +#include <map> | ||
13 | +#include <memory> | ||
14 | +#include <math.h> | ||
15 | + | ||
16 | + | ||
17 | +bool DmpTileThumbnail::ctreatWmtsThumbnail(DmpTileLayer *tileLayer) | ||
18 | +{ | ||
19 | + | ||
20 | + std::string path = tileLayer->getDataSource(); | ||
21 | + path="/mnt/d/Code/tiles/qgis"; | ||
22 | + std::string vendor=tileLayer->getVendor(); | ||
23 | + std::string format=tileLayer->getFormat(); | ||
24 | + | ||
25 | + DmpRectangle rectangle=tileLayer->extent(); | ||
26 | + std::string lowerPoint=std::to_string(rectangle.xmin())+" "+std::to_string(rectangle.ymin()); | ||
27 | + std::string upperPoint=std::to_string(rectangle.xmax())+" "+std::to_string(rectangle.ymax()); | ||
28 | + Point minPoin{.x=107.78981494180618,.y=18.870480519260582}; | ||
29 | + Point maxPoin{.x=120.43553603935675,.y=25.999868757737033}; | ||
30 | + | ||
31 | + int tileMatrix=6; | ||
32 | + Point origin{.x=-400,.y=400}; | ||
33 | + double resolution=0.02197265625009295*256; | ||
34 | + int minCol=floor(abs(origin.x-minPoin.x)/resolution); | ||
35 | + int minRow=floor(abs(origin.y-minPoin.y)/resolution); | ||
36 | + int maxCol=floor(abs(origin.x-maxPoin.x)/resolution); | ||
37 | + int maxRow=floor(abs(origin.y-maxPoin.y)/resolution); | ||
38 | + int width=maxCol-minCol; | ||
39 | + int heigth=minRow-maxRow; | ||
40 | + cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256*(width+1), 256*(heigth+1)); | ||
41 | + cairo_t *cr =cairo_create (surface); | ||
42 | + | ||
43 | + for( int i = 0 ; i <= width ; i++ ) | ||
44 | + { | ||
45 | + for(int j=0;j<=heigth;j++) | ||
46 | + { | ||
47 | + char* buff; | ||
48 | + int length; | ||
49 | + getTile(maxRow+j,minCol+i,tileMatrix,format,buff,length); | ||
50 | + // std::string filepath=path+"/"+std::to_string(tileMatrix)+"/"+std::to_string(minCol+i)+"/"+std::to_string(maxRow+j)+".png"; | ||
51 | + // cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str()); | ||
52 | + | ||
53 | + st_png_data* pPngData; | ||
54 | + pPngData->pdata=(unsigned char*)buff; | ||
55 | + pPngData->length=length; | ||
56 | + cairo_surface_t* image1 = cairo_image_surface_create_from_png_stream(cairo_read_func_mine,&pPngData); | ||
57 | + | ||
58 | + BufferCopy(image1,surface,cr,0,0); | ||
59 | + cairo_surface_write_to_png (surface, "./wmts1.png"); | ||
60 | + BufferCopy(image1,surface,cr,i*256,j*256); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + cairo_destroy (cr); | ||
65 | + cairo_surface_write_to_png (surface, "./wmts.png"); | ||
66 | + cairo_surface_destroy (surface); | ||
67 | + return true; | ||
68 | +} | ||
69 | +bool DmpTileThumbnail::ctreatTmsThumbnail() | ||
70 | +{ | ||
71 | + std::string path="/mnt/d/Code/tiles/qgis"; | ||
72 | + std::string vendor="QGIS"; | ||
73 | + Point origin{.x=-400,.y=400}; | ||
74 | + Point minPoin{.x=107.78981494180618,.y=18.870480519260582}; | ||
75 | + Point maxPoin{.x=120.43553603935675,.y=25.999868757737033}; | ||
76 | + double resolution=0.02197265625009295*256; | ||
77 | + // int minCol=floor(abs(origin.x-minPoin.x)/resolution); | ||
78 | + // int minRow=floor(abs(origin.y-minPoin.y)/resolution); | ||
79 | + // int maxCol=floor(abs(origin.x-maxPoin.x)/resolution); | ||
80 | + // int maxRow=floor(abs(origin.y-maxPoin.y)/resolution); | ||
81 | + int minCol=51; | ||
82 | + int minRow=28; | ||
83 | + int maxCol=53; | ||
84 | + int maxRow=27; | ||
85 | + int width=maxCol-minCol; | ||
86 | + int heigth=minRow-maxRow; | ||
87 | + cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256*(width+1), 256*(heigth+1)); | ||
88 | + cairo_t *cr =cairo_create (surface); | ||
89 | + for( int i = 0 ; i <= width ; i++ ) | ||
90 | + { | ||
91 | + for(int j=0;j<=heigth;j++) | ||
92 | + { | ||
93 | + std::string filepath=path+"/6/"+std::to_string(minCol+i)+"/"+std::to_string(maxRow+j)+".png"; | ||
94 | + cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str()); | ||
95 | + | ||
96 | + BufferCopy(image,surface,cr,i*256,j*256); | ||
97 | + } | ||
98 | + } | ||
99 | + cairo_destroy (cr); | ||
100 | + cairo_surface_write_to_png (surface, "./tms.png"); | ||
101 | + cairo_surface_destroy (surface); | ||
102 | + return true; | ||
103 | +} | ||
104 | +bool DmpTileThumbnail::BufferCopy(cairo_surface_t *pClsCSFrom, cairo_surface_t *pClsCSTo, cairo_t *cr,int x,int y) | ||
105 | +{ | ||
106 | + if (pClsCSFrom == NULL||pClsCSTo == NULL) | ||
107 | + { | ||
108 | + return false; | ||
109 | + } | ||
110 | + if(cr==NULL) | ||
111 | + { | ||
112 | + cr = cairo_create (pClsCSTo); | ||
113 | + } | ||
114 | + cairo_set_source_surface(cr, pClsCSFrom, x, y); | ||
115 | + cairo_paint(cr); | ||
116 | + | ||
117 | + return true; | ||
118 | +} | ||
119 | +void DmpTileThumbnail::getTile(int row, int col, int level, std::string& format,char* refbuff,int length) | ||
120 | +{ | ||
121 | + int packSize = 128; | ||
122 | + int rGroup = (int)row/packSize; | ||
123 | + rGroup = rGroup * packSize; | ||
124 | + int cGroup = (int)col/packSize; | ||
125 | + cGroup = cGroup*packSize; | ||
126 | + std::string path="/mnt/d/Code/tiles/gdmap/_alllayers"; | ||
127 | + std::string bundleBase =GetBundlePath(level,rGroup,cGroup); | ||
128 | + std::string bundleFilePath = path+bundleBase + ".bundle"; | ||
129 | + std::string bundlxFilePath = path+bundleBase + ".bundlx"; | ||
130 | + | ||
131 | + int index = packSize * (col - cGroup) + (row - rGroup); | ||
132 | + | ||
133 | + //读取bundlx文件存储该切片的位置,计算偏移量 | ||
134 | + std::ifstream freadx(bundlxFilePath, std::ifstream::binary); | ||
135 | + if(!freadx) | ||
136 | + { | ||
137 | + | ||
138 | + return; | ||
139 | + } | ||
140 | + freadx.seekg(16+5*index, freadx.beg); | ||
141 | + char* buffer = new char[5]; | ||
142 | + freadx.read(buffer,5); | ||
143 | + freadx.close(); | ||
144 | + | ||
145 | + long offset = (long)(buffer[0]&0xff) | ||
146 | + + (long)(buffer[1]&0xff) * 256 | ||
147 | + + (long)(buffer[2]&0xff) * 65536 | ||
148 | + + (long)(buffer[3]&0xff) * 16777216 | ||
149 | + + (long)(buffer[4]&0xff) * 4294967296L; | ||
150 | + delete [] buffer; | ||
151 | + //读取bundle文件获取切片 | ||
152 | + std::ifstream fread(bundleFilePath, std::ifstream::binary); | ||
153 | + if(!fread) | ||
154 | + { | ||
155 | + | ||
156 | + return; | ||
157 | + } | ||
158 | + fread.seekg(offset, fread.beg); | ||
159 | + char* buff = new char[4]; | ||
160 | + fread.read(buff, 4); | ||
161 | + length = (long)(buff[0]&0xff) | ||
162 | + + (long)(buff[1]&0xff) * 256 | ||
163 | + + (long)(buff[2]&0xff) * 65536 | ||
164 | + + (long)(buff[3]&0xff) * 16777216; | ||
165 | + delete[] buff; | ||
166 | + char* imgBuffer = new char[length]; | ||
167 | + fread.read(imgBuffer, length); | ||
168 | + fread.close(); | ||
169 | + refbuff=imgBuffer; | ||
170 | + delete[] imgBuffer; | ||
171 | +} | ||
172 | +std::string DmpTileThumbnail::GetBundlePath(int level, int rGroup, int cGroup) | ||
173 | +{ | ||
174 | + std::string l = std::to_string(level); | ||
175 | + int len = l.length(); | ||
176 | + if (len < 2) | ||
177 | + { | ||
178 | + for (int i = 0; i < 2 - len; i++) | ||
179 | + { | ||
180 | + l = "0" + l; | ||
181 | + } | ||
182 | + } | ||
183 | + l = "L" + l; | ||
184 | + std::string r =IntToHexStr(rGroup); | ||
185 | + | ||
186 | + int rLength = r.length(); | ||
187 | + if (rLength < 4) | ||
188 | + { | ||
189 | + for (int i = 0; i < 4 - rLength; i++) | ||
190 | + { | ||
191 | + r = "0" + r; | ||
192 | + } | ||
193 | + } | ||
194 | + r = "R" + r; | ||
195 | + | ||
196 | + std::string c = IntToHexStr(cGroup); | ||
197 | + int cLength = c.length(); | ||
198 | + if (cLength < 4) | ||
199 | + { | ||
200 | + for (int i = 0; i < 4 - cLength; i++) | ||
201 | + { | ||
202 | + c = "0" + c; | ||
203 | + } | ||
204 | + } | ||
205 | + c = "C" + c; | ||
206 | + std::string rootPath; | ||
207 | + std::string bundlePath = rootPath + "/"+l+"/"+r+c; | ||
208 | + return bundlePath; | ||
209 | +} | ||
210 | +std::string DmpTileThumbnail::IntToFormatStr(const int num) | ||
211 | + { | ||
212 | + std::string str = std::to_string(num); | ||
213 | + if(num>=0 && num<10) | ||
214 | + { | ||
215 | + str = "0"+str; | ||
216 | + } | ||
217 | + return str; | ||
218 | + } | ||
219 | + | ||
220 | +std::string DmpTileThumbnail::IntToHexStr(const int num) | ||
221 | + { | ||
222 | + char* buffer = new char[8]; | ||
223 | + sprintf(buffer,"%x",num); | ||
224 | + std::string str = std::string(buffer); | ||
225 | + delete[] buffer; | ||
226 | + return str; | ||
227 | + } | ||
228 | + | ||
229 | + | ||
230 | +cairo_status_t DmpTileThumbnail::cairo_read_func_mine (void *closure, unsigned char *data, unsigned int length) | ||
231 | +{ | ||
232 | + st_png_data* pPngData = (st_png_data*)closure; | ||
233 | + memcpy(data, pPngData->pdata + pPngData->length, length); | ||
234 | + pPngData->length += length; | ||
235 | + return CAIRO_STATUS_SUCCESS; | ||
236 | +} |
src/server/dmptilethumbnail.h
0 → 100644
1 | +/************************************************************************** | ||
2 | +* file: dmptilethumbnail.h | ||
3 | + | ||
4 | +* Author: lijiahuan | ||
5 | +* Date: 2021-12-23 15:34:29 | ||
6 | +* Email: jiahuanl@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmptilethumbnail_h__ | ||
11 | +#define __dmptilethumbnail_h__ | ||
12 | +#include <cairo/cairo.h> | ||
13 | +#include "dmptilelayer.h" | ||
14 | +// namespace tileserver | ||
15 | +// { | ||
16 | + class DmpTileThumbnail | ||
17 | + { | ||
18 | + public: | ||
19 | + | ||
20 | + static bool ctreatTmsThumbnail() ; | ||
21 | + static bool ctreatWmtsThumbnail(DmpTileLayer *tileLayer); | ||
22 | + static bool BufferCopy(cairo_surface_t *pClsCSFrom, cairo_surface_t *pClsCSTo,cairo_t *cr,int x,int y); | ||
23 | + static void getTile(int row, int col, int level, std::string& format,char* refbuff,int length); | ||
24 | + static std::string GetBundlePath(int level, int rGroup, int cGroup); | ||
25 | + static std::string IntToFormatStr(const int num); | ||
26 | + static std::string IntToHexStr(const int num); | ||
27 | + static cairo_status_t cairo_read_func_mine (void *closure, unsigned char *data, unsigned int length); | ||
28 | + const int _packetSize = 128; | ||
29 | + | ||
30 | + }; | ||
31 | + struct Point | ||
32 | + { | ||
33 | + double x; | ||
34 | + double y; | ||
35 | + }; | ||
36 | + | ||
37 | + struct st_png_data | ||
38 | + { | ||
39 | + unsigned char* pdata; | ||
40 | + unsigned int length; | ||
41 | + }; | ||
42 | +// } | ||
43 | + | ||
44 | +#endif // __dmptilethumbnail_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpmanagerapihandler.cpp | ||
3 | + | ||
4 | +* Author: wanzhongping | ||
5 | +* Date: 2021-07-15 14:46:40 | ||
6 | +* Email: zhongpingw@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include <iostream> | ||
10 | +#include <boost/json.hpp> | ||
11 | +#include <boost/property_tree/ptree.hpp> | ||
12 | +#include <boost/property_tree/json_parser.hpp> | ||
13 | +#include <boost/property_tree/xml_parser.hpp> | ||
14 | +#include <boost/foreach.hpp> | ||
15 | +#include <boost/lexical_cast.hpp> | ||
16 | +#include <boost/algorithm/string.hpp> | ||
17 | +#include <boost/date_time.hpp> | ||
18 | + | ||
19 | +#include "dmpmanagerapihandler.h" | ||
20 | +#include "dmpserverrequest.h" | ||
21 | +#include "dmpserverresponse.h" | ||
22 | +#include "dmpapiparameters.h" | ||
23 | +#include "dmplogger.h" | ||
24 | +#include "dmpapiutils.h" | ||
25 | +#include "dmpservermanager.h" | ||
26 | +#include "dmpserverutils.h" | ||
27 | + | ||
28 | +DmpManagerApiHandler::DmpManagerApiHandler() | ||
29 | +{ | ||
30 | + | ||
31 | +} | ||
32 | + | ||
33 | +void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) const | ||
34 | +{ | ||
35 | + if (OperationId().compare("regservice") == 0) { | ||
36 | + regService(context); | ||
37 | + } | ||
38 | + else if (OperationId().compare("startservice") == 0) { | ||
39 | + startService(context); | ||
40 | + } | ||
41 | + else if (OperationId().compare("stopservice") == 0) { | ||
42 | + stopService(context); | ||
43 | + } | ||
44 | + else if(OperationId().compare("regtileservice") == 0) { | ||
45 | + RegTileService(context); | ||
46 | + } | ||
47 | + else if(OperationId().compare("getservicelist") == 0) { | ||
48 | + GetServiceList(context); | ||
49 | + } | ||
50 | + else if(OperationId().compare("getservicedetail") == 0) { | ||
51 | + GetServiceDetail(context); | ||
52 | + } | ||
53 | + else if(OperationId().compare("getcapabilities") == 0) { | ||
54 | + getCapabilities(context); | ||
55 | + } | ||
56 | + else if(OperationId().compare("updateservice") == 0) { | ||
57 | + UpdateService(context); | ||
58 | + } | ||
59 | + else if(OperationId().compare("deleteservice") == 0) { | ||
60 | + deleteService(context); | ||
61 | + } | ||
62 | + else if(OperationId().compare("gettileserviceinfo") == 0) { | ||
63 | + GetTileServiceInfo(context); | ||
64 | + } | ||
65 | + else if(OperationId().compare("addcatalog") == 0) { | ||
66 | + AddCatalog(context); | ||
67 | + } | ||
68 | + else if(OperationId().compare("deletecatalog") == 0) { | ||
69 | + DeleteCatalog(context); | ||
70 | + } | ||
71 | + else if(OperationId().compare("getservicesmatrixsets") == 0) { | ||
72 | + GetServicesMatrixSets(context); | ||
73 | + } | ||
74 | + else if(OperationId().compare("deletecache") == 0) { | ||
75 | + DeleteCache(context); | ||
76 | + } | ||
77 | + else if(OperationId().compare("updatecache") == 0) { | ||
78 | + UpdateCache(context); | ||
79 | + } | ||
80 | + else if(OperationId().compare("reloadservices") == 0) { | ||
81 | + reloadServices(context); | ||
82 | + } | ||
83 | + else { | ||
84 | + context.response()->write("not find oparation: " + OperationId()); | ||
85 | + } | ||
86 | +} | ||
87 | +void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
88 | +{ | ||
89 | + switch (context.request()->method()) | ||
90 | + { | ||
91 | + case DmpServerRequest::Method::GET_METHOD: | ||
92 | + { | ||
93 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); | ||
94 | + break; | ||
95 | + } | ||
96 | + case DmpServerRequest::Method::POST_METHOD: | ||
97 | + { | ||
98 | + std::string name; | ||
99 | + std::string title; | ||
100 | + int capabilities; | ||
101 | + std::string serverType; | ||
102 | + std::string project; | ||
103 | + const char* data = (char*)(context.request()->GetData()); | ||
104 | + if(data && *data != '\0') | ||
105 | + { | ||
106 | + try | ||
107 | + { | ||
108 | + std::stringstream stream(data); | ||
109 | + boost::property_tree::ptree pt; | ||
110 | + boost::property_tree::read_json(stream, pt); | ||
111 | + | ||
112 | + name = pt.get<std::string>("name"); | ||
113 | + title = pt.get<std::string>("title"); | ||
114 | + capabilities = pt.get<int>("capabilities"); | ||
115 | + serverType = pt.get<std::string>("type"); | ||
116 | + project = pt.get<std::string>("project"); | ||
117 | + } | ||
118 | + catch (boost::property_tree::ptree_bad_path& e) { | ||
119 | + LOGGER_ERROR(e.what()); | ||
120 | + context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | ||
121 | + return; | ||
122 | + } | ||
123 | + catch (boost::property_tree::ptree_bad_data& e) { | ||
124 | + LOGGER_ERROR(e.what()); | ||
125 | + context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | ||
126 | + return; | ||
127 | + } | ||
128 | + if(context.manager()->publish(serverType, name, title, capabilities, project)) { | ||
129 | + LOGGER_INFO("服务发布成功"); | ||
130 | + context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}"); | ||
131 | + // std::string projData; | ||
132 | + // DmpServerUtils::Base64Decode(project, &projData); | ||
133 | + // context.response()->removeHeader("Content-Type"); | ||
134 | + // context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); | ||
135 | + // context.response()->write(projData); | ||
136 | + } | ||
137 | + else | ||
138 | + { | ||
139 | + LOGGER_ERROR("服务发布失败"); | ||
140 | + context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | ||
141 | + } | ||
142 | + } | ||
143 | + else | ||
144 | + { | ||
145 | + LOGGER_ERROR("POST数据为空"); | ||
146 | + context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | ||
147 | + return; | ||
148 | + } | ||
149 | + break; | ||
150 | + | ||
151 | + } | ||
152 | + default: | ||
153 | + { | ||
154 | + | ||
155 | + } | ||
156 | + } | ||
157 | +} | ||
158 | + | ||
159 | +void DmpManagerApiHandler::startService(const DmpServerApiContext &context) const | ||
160 | +{ | ||
161 | + switch (context.request()->method()) | ||
162 | + { | ||
163 | + case DmpServerRequest::Method::GET_METHOD: | ||
164 | + { | ||
165 | + DmpServerParameters params = context.request()->serverParameters(); | ||
166 | + std::string serverName; | ||
167 | + params.getValue("servername", serverName); | ||
168 | + std::string serviceName; | ||
169 | + params.getValue("servicename",serviceName); | ||
170 | + context.manager()->startService(serverName, serviceName); | ||
171 | + break; | ||
172 | + } | ||
173 | + case DmpServerRequest::Method::POST_METHOD: | ||
174 | + { | ||
175 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | ||
176 | + break; | ||
177 | + } | ||
178 | + default: | ||
179 | + { | ||
180 | + | ||
181 | + } | ||
182 | + } | ||
183 | +} | ||
184 | +void DmpManagerApiHandler::stopService(const DmpServerApiContext &context) const | ||
185 | +{ | ||
186 | + switch (context.request()->method()) | ||
187 | + { | ||
188 | + case DmpServerRequest::Method::GET_METHOD: | ||
189 | + { | ||
190 | + DmpServerParameters params = context.request()->serverParameters(); | ||
191 | + std::string serverName; | ||
192 | + params.getValue("servername", serverName); | ||
193 | + std::string serviceName; | ||
194 | + params.getValue("servicename",serviceName); | ||
195 | + context.manager()->stopService(serverName, serviceName); | ||
196 | + break; | ||
197 | + } | ||
198 | + case DmpServerRequest::Method::POST_METHOD: | ||
199 | + { | ||
200 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | ||
201 | + break; | ||
202 | + } | ||
203 | + default: | ||
204 | + { | ||
205 | + | ||
206 | + } | ||
207 | + } | ||
208 | +} | ||
209 | +void DmpManagerApiHandler::RegTileService(const DmpServerApiContext &context) const | ||
210 | +{ | ||
211 | + switch (context.request()->method()) | ||
212 | + { | ||
213 | + case DmpServerRequest::Method::GET_METHOD: | ||
214 | + { | ||
215 | + context.response()->write("{\"status\":\"true\",\"message\":\"切片服务发布测试——————GET\"}"); | ||
216 | + break; | ||
217 | + } | ||
218 | + case DmpServerRequest::Method::POST_METHOD: | ||
219 | + { | ||
220 | + context.response()->write("{\"status\":\"true\",\"message\":\"切片服务发布测试——————POST\"}"); | ||
221 | + break; | ||
222 | + } | ||
223 | + default: | ||
224 | + { | ||
225 | + | ||
226 | + } | ||
227 | + } | ||
228 | +} | ||
229 | +void DmpManagerApiHandler::GetServiceList(const DmpServerApiContext &context) const | ||
230 | +{ | ||
231 | +} | ||
232 | + | ||
233 | +void DmpManagerApiHandler::GetServiceDetail(const DmpServerApiContext &context) const | ||
234 | +{ | ||
235 | +} | ||
236 | + | ||
237 | +void DmpManagerApiHandler::UpdateService(const DmpServerApiContext &context) const | ||
238 | +{ | ||
239 | + switch (context.request()->method()) | ||
240 | + { | ||
241 | + case DmpServerRequest::Method::GET_METHOD: | ||
242 | + { | ||
243 | + context.response()->write("{\"status\":\"true\",\"message\":\"更新服务信息——————GET\"}"); | ||
244 | + break; | ||
245 | + } | ||
246 | + case DmpServerRequest::Method::POST_METHOD: | ||
247 | + { | ||
248 | + context.response()->write("{\"status\":\"true\",\"message\":\"更新服务信息——————POST\"}"); | ||
249 | + break; | ||
250 | + } | ||
251 | + default: | ||
252 | + { | ||
253 | + | ||
254 | + } | ||
255 | + } | ||
256 | +} | ||
257 | + | ||
258 | +void DmpManagerApiHandler::deleteService(const DmpServerApiContext &context) const | ||
259 | +{ | ||
260 | + switch (context.request()->method()) | ||
261 | + { | ||
262 | + case DmpServerRequest::Method::GET_METHOD: | ||
263 | + { | ||
264 | + DmpServerParameters params = context.request()->serverParameters(); | ||
265 | + std::string serverName; | ||
266 | + params.getValue("servername", serverName); | ||
267 | + std::string serviceName; | ||
268 | + params.getValue("servicename",serviceName); | ||
269 | + if(context.manager()->deleteService(serverName, serviceName)) { | ||
270 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除服务成功\"}"); | ||
271 | + }else{ | ||
272 | + context.response()->write("{\"status\":\"false\",\"message\":\"删除服务失败\"}"); | ||
273 | + } | ||
274 | + break; | ||
275 | + } | ||
276 | + case DmpServerRequest::Method::POST_METHOD: | ||
277 | + { | ||
278 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务删除——————POST\"}"); | ||
279 | + break; | ||
280 | + } | ||
281 | + default: | ||
282 | + { | ||
283 | + | ||
284 | + } | ||
285 | + } | ||
286 | +} | ||
287 | + | ||
288 | +//获取配置文件切片信息 | ||
289 | +void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context) const | ||
290 | +{ | ||
291 | + switch (context.request()->method()) | ||
292 | + { | ||
293 | + case DmpServerRequest::Method::GET_METHOD: | ||
294 | + { | ||
295 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取切片配置信息——————GET\"}"); | ||
296 | + break; | ||
297 | + } | ||
298 | + case DmpServerRequest::Method::POST_METHOD: | ||
299 | + { | ||
300 | + std::string path; | ||
301 | + std::string strExtent; | ||
302 | + const char* data = (char*)(context.request()->GetData()); | ||
303 | + if(data && *data != '\0') | ||
304 | + { | ||
305 | + try | ||
306 | + { | ||
307 | + std::stringstream stream(data); | ||
308 | + boost::property_tree::ptree pt; | ||
309 | + boost::property_tree::ptree pt_json; | ||
310 | + std::string confcdipath; | ||
311 | + std::string confxmlpath; | ||
312 | + | ||
313 | + boost::property_tree::read_json(stream, pt); | ||
314 | + path= pt.get<std::string>("projectlayers.maplayer.datasource"); | ||
315 | + confcdipath=path+"/conf.cdi"; | ||
316 | + confxmlpath=path+"/conf.xml"; | ||
317 | + //读取切片配置文件conf.cdi | ||
318 | + boost::property_tree::ptree pt_confcdi; | ||
319 | + boost::property_tree::read_xml(confcdipath,pt_confcdi); | ||
320 | + //boost::property_tree::ptree pt_base=pt.get_child("base"); | ||
321 | + std::string xmin=pt_confcdi.get<std::string>("EnvelopeN.XMin"); | ||
322 | + std::string ymin=pt_confcdi.get<std::string>("EnvelopeN.YMin"); | ||
323 | + std::string xmax=pt_confcdi.get<std::string>("EnvelopeN.XMax"); | ||
324 | + std::string ymax=pt_confcdi.get<std::string>("EnvelopeN.YMax"); | ||
325 | + pt.put("projectlayers.maplayer.extent.xmin",xmin); | ||
326 | + pt.put("projectlayers.maplayer.extent.ymin",ymin); | ||
327 | + pt.put("projectlayers.maplayer.extent.xmax",xmax); | ||
328 | + pt.put("projectlayers.maplayer.extent.ymax",ymax); | ||
329 | + //读取配置文件conf.xml | ||
330 | + boost::property_tree::ptree pt_confxml; | ||
331 | + boost::property_tree::read_xml(confxmlpath,pt_confxml); | ||
332 | + std::string strWKT=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKT"); | ||
333 | + std::string wkid=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKID"); | ||
334 | + std::string top=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.X"); | ||
335 | + std::string left=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.Y"); | ||
336 | + std::string tileCols=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileCols"); | ||
337 | + std::string tileRows=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileRows"); | ||
338 | + std::string dpi=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.DPI"); | ||
339 | + pt.put("projectCrs.spatialrefsys.wkt",strWKT); | ||
340 | + pt.put("projectCrs.spatialrefsys.srid",wkid); | ||
341 | + | ||
342 | + boost::property_tree::ptree pt_tileMatrixSets=pt.get_child("tileMatrixSets"); | ||
343 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v1,pt_tileMatrixSets) | ||
344 | + { | ||
345 | + //conf.xml中读取tileinfo | ||
346 | + boost::property_tree::ptree pt_levels,pt_tileMatrixSet; | ||
347 | + boost::property_tree::ptree pt_tileArry=pt_confxml.get_child("CacheInfo.TileCacheInfo.LODInfos"); | ||
348 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v2,pt_tileArry) | ||
349 | + { | ||
350 | + boost::property_tree::ptree pt_level; | ||
351 | + if(v2.first=="LODInfo") | ||
352 | + { | ||
353 | + std::string level=v2.second.get<std::string>("LevelID"); | ||
354 | + std::string scale=v2.second.get<std::string>("Scale"); | ||
355 | + std::string resolution=v2.second.get<std::string>("Resolution"); | ||
356 | + pt_level.add("level.id",level); | ||
357 | + pt_level.add("level.scaleDenominator",scale); | ||
358 | + pt_level.add("level.resolution",resolution); | ||
359 | + pt_levels.push_back(std::make_pair("", pt_level)); | ||
360 | + } | ||
361 | + } | ||
362 | + std::string id_=v1.second.get<std::string>("tileMatrixSet.id"); | ||
363 | + pt_tileMatrixSet.add("id",id_); | ||
364 | + pt_tileMatrixSet.add("crs","EPSG::"+wkid); | ||
365 | + pt_tileMatrixSet.add("tileCols",tileCols); | ||
366 | + pt_tileMatrixSet.add("tileRows",tileRows); | ||
367 | + pt_tileMatrixSet.add("dpi",dpi); | ||
368 | + pt_tileMatrixSet.add("tileOrigin.X",top); | ||
369 | + pt_tileMatrixSet.add("tileOrigin.Y",left); | ||
370 | + pt_tileMatrixSet.add_child("levels",pt_levels); | ||
371 | + //pt_tilelist.add_child("tileMatrixList",pt_tiles); | ||
372 | + v1.second.put_child("tileMatrixSet",pt_tileMatrixSet); | ||
373 | + //v1.second.put("id","EPSG::"+wkid); | ||
374 | + } | ||
375 | + | ||
376 | + pt.put_child("tileMatrixSets",pt_tileMatrixSets); | ||
377 | + std::stringstream ss; | ||
378 | + boost::property_tree::write_json(ss,pt); | ||
379 | + strExtent=ss.str(); | ||
380 | + } | ||
381 | + catch (boost::property_tree::ptree_bad_path& e) { | ||
382 | + LOGGER_ERROR(e.what()); | ||
383 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
384 | + return; | ||
385 | + } | ||
386 | + catch (boost::property_tree::ptree_bad_data& e) { | ||
387 | + LOGGER_ERROR(e.what()); | ||
388 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
389 | + return; | ||
390 | + } | ||
391 | + context.response()->write(strExtent); | ||
392 | + } | ||
393 | + break; | ||
394 | + } | ||
395 | + default: | ||
396 | + { | ||
397 | + | ||
398 | + } | ||
399 | + } | ||
400 | +} | ||
401 | + | ||
402 | +//判断服务是否存在 | ||
403 | +void DmpManagerApiHandler::IsExistServiceName(const DmpServerApiContext &context) const | ||
404 | +{ | ||
405 | + switch (context.request()->method()) | ||
406 | + { | ||
407 | + case DmpServerRequest::Method::GET_METHOD: | ||
408 | + { | ||
409 | + context.response()->write("{\"status\":\"true\",\"message\":\"——————GET\"}"); | ||
410 | + break; | ||
411 | + } | ||
412 | + case DmpServerRequest::Method::POST_METHOD: | ||
413 | + { | ||
414 | + context.response()->write("{\"status\":\"true\",\"message\":\"——————POST\"}"); | ||
415 | + break; | ||
416 | + } | ||
417 | + default: | ||
418 | + { | ||
419 | + | ||
420 | + } | ||
421 | + } | ||
422 | +} | ||
423 | + | ||
424 | +//新增目录 | ||
425 | +void DmpManagerApiHandler::AddCatalog(const DmpServerApiContext &context) const | ||
426 | +{ | ||
427 | + switch (context.request()->method()) | ||
428 | + { | ||
429 | + case DmpServerRequest::Method::GET_METHOD: | ||
430 | + { | ||
431 | + context.response()->write("{\"status\":\"true\",\"message\":\"新增目录——————GET\"}"); | ||
432 | + break; | ||
433 | + } | ||
434 | + case DmpServerRequest::Method::POST_METHOD: | ||
435 | + { | ||
436 | + context.response()->write("{\"status\":\"true\",\"message\":\"新增目录——————POST\"}"); | ||
437 | + break; | ||
438 | + } | ||
439 | + default: | ||
440 | + { | ||
441 | + | ||
442 | + } | ||
443 | + } | ||
444 | +} | ||
445 | + | ||
446 | +//删除目录 | ||
447 | +void DmpManagerApiHandler::DeleteCatalog(const DmpServerApiContext &context) const | ||
448 | +{ | ||
449 | + switch (context.request()->method()) | ||
450 | + { | ||
451 | + case DmpServerRequest::Method::GET_METHOD: | ||
452 | + { | ||
453 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————GET\"}"); | ||
454 | + break; | ||
455 | + } | ||
456 | + case DmpServerRequest::Method::POST_METHOD: | ||
457 | + { | ||
458 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————POST\"}"); | ||
459 | + break; | ||
460 | + } | ||
461 | + default: | ||
462 | + { | ||
463 | + | ||
464 | + } | ||
465 | + } | ||
466 | +} | ||
467 | + | ||
468 | +void DmpManagerApiHandler::GetServicesMatrixSets(const DmpServerApiContext &context) const | ||
469 | +{ | ||
470 | + switch (context.request()->method()) | ||
471 | + { | ||
472 | + case DmpServerRequest::Method::GET_METHOD: | ||
473 | + { | ||
474 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————GET\"}"); | ||
475 | + break; | ||
476 | + } | ||
477 | + case DmpServerRequest::Method::POST_METHOD: | ||
478 | + { | ||
479 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除目录——————POST\"}"); | ||
480 | + break; | ||
481 | + } | ||
482 | + default: | ||
483 | + { | ||
484 | + | ||
485 | + } | ||
486 | + } | ||
487 | +} | ||
488 | +void DmpManagerApiHandler::GetCatalogList(const DmpServerApiContext &context) const | ||
489 | +{ | ||
490 | + switch (context.request()->method()) | ||
491 | + { | ||
492 | + case DmpServerRequest::Method::GET_METHOD: | ||
493 | + { | ||
494 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取目录列表——————GET\"}"); | ||
495 | + break; | ||
496 | + } | ||
497 | + case DmpServerRequest::Method::POST_METHOD: | ||
498 | + { | ||
499 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取目录列表——————POST\"}"); | ||
500 | + break; | ||
501 | + } | ||
502 | + default: | ||
503 | + { | ||
504 | + | ||
505 | + } | ||
506 | + } | ||
507 | +} | ||
508 | +void DmpManagerApiHandler::UpdateCache(const DmpServerApiContext &context)const | ||
509 | +{ | ||
510 | + switch (context.request()->method()) | ||
511 | + { | ||
512 | + case DmpServerRequest::Method::GET_METHOD: | ||
513 | + { | ||
514 | + std::string serviceName_; | ||
515 | + const DmpServerParameters params_ (context.request()->serverParameters()); | ||
516 | + CIMap paramsMap=params_.parameters(); | ||
517 | + std::map<std::string, std::string>::const_iterator iter; | ||
518 | + iter =paramsMap.find("SERVICENAME"); | ||
519 | + if (iter != paramsMap.end()) | ||
520 | + { | ||
521 | + try | ||
522 | + { | ||
523 | + serviceName_ = boost::lexical_cast<std::string>(iter->second); | ||
524 | + } | ||
525 | + catch (boost::bad_lexical_cast &e) | ||
526 | + { | ||
527 | + LOGGER_ERROR(e.what()); | ||
528 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取参数信息错误——————GET\"}"); | ||
529 | + return; | ||
530 | + } | ||
531 | + } | ||
532 | + | ||
533 | + break; | ||
534 | + } | ||
535 | + case DmpServerRequest::Method::POST_METHOD: | ||
536 | + { | ||
537 | + context.response()->write("{\"status\":\"true\",\"message\":\"更新缓存——————POST\"}"); | ||
538 | + break; | ||
539 | + } | ||
540 | + default: | ||
541 | + { | ||
542 | + | ||
543 | + } | ||
544 | + } | ||
545 | +} | ||
546 | +void DmpManagerApiHandler::DeleteCache(const DmpServerApiContext &context)const | ||
547 | +{ | ||
548 | + switch (context.request()->method()) | ||
549 | + { | ||
550 | + case DmpServerRequest::Method::GET_METHOD: | ||
551 | + { | ||
552 | + std::string serviceName_; | ||
553 | + const DmpServerParameters params_ (context.request()->serverParameters()); | ||
554 | + CIMap paramsMap=params_.parameters(); | ||
555 | + std::map<std::string, std::string>::const_iterator iter; | ||
556 | + iter =paramsMap.find("SERVICENAME"); | ||
557 | + if (iter != paramsMap.end()) | ||
558 | + { | ||
559 | + try | ||
560 | + { | ||
561 | + serviceName_ = boost::lexical_cast<std::string>(iter->second); | ||
562 | + } | ||
563 | + catch (boost::bad_lexical_cast &e) | ||
564 | + { | ||
565 | + LOGGER_ERROR(e.what()); | ||
566 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取参数信息错误——————GET\"}"); | ||
567 | + return; | ||
568 | + } | ||
569 | + } | ||
570 | + | ||
571 | + break; | ||
572 | + } | ||
573 | + case DmpServerRequest::Method::POST_METHOD: | ||
574 | + { | ||
575 | + context.response()->write("{\"status\":\"true\",\"message\":\"删除缓存——————POST\"}"); | ||
576 | + break; | ||
577 | + } | ||
578 | + default: | ||
579 | + { | ||
580 | + | ||
581 | + } | ||
582 | + } | ||
583 | +} | ||
584 | + | ||
585 | +void DmpManagerApiHandler::getCapabilities(const DmpServerApiContext &context) const | ||
586 | +{ | ||
587 | + std::string strJson = context.manager()->getCapabilities(); | ||
588 | + context.response()->write(strJson); | ||
589 | +} | ||
590 | +void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) const | ||
591 | +{ | ||
592 | + switch (context.request()->method()) | ||
593 | + { | ||
594 | + case DmpServerRequest::Method::GET_METHOD: | ||
595 | + { | ||
596 | + if(context.manager()->loadServices()) { | ||
597 | + context.response()->write("{\"status\":\"true\",\"message\":\"重载服务成功\"}"); | ||
598 | + }else{ | ||
599 | + context.response()->write("{\"status\":\"false\",\"message\":\"重载服务失败\"}"); | ||
600 | + } | ||
601 | + break; | ||
602 | + | ||
603 | + } | ||
604 | + case DmpServerRequest::Method::POST_METHOD: | ||
605 | + { | ||
606 | + context.response()->write("{\"status\":\"true\",\"message\":\"服务重载——————POST\"}"); | ||
607 | + break; | ||
608 | + } | ||
609 | + default: | ||
610 | + { | ||
611 | + | ||
612 | + } | ||
613 | + } | ||
614 | +} |
@@ -45,9 +45,12 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | @@ -45,9 +45,12 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | ||
45 | else if(OperationId().compare("deleteservice") == 0) { | 45 | else if(OperationId().compare("deleteservice") == 0) { |
46 | deleteService(context); | 46 | deleteService(context); |
47 | } | 47 | } |
48 | - else if(OperationId().compare("reloadservices") == 0) { | 48 | + else if(OperationId().compare("reloadservices") == 0) { |
49 | reloadServices(context); | 49 | reloadServices(context); |
50 | } | 50 | } |
51 | + else if(OperationId().compare("gettileserviceinfo") == 0) { | ||
52 | + GetTileServiceInfo(context); | ||
53 | + } | ||
51 | else { | 54 | else { |
52 | context.response()->write("not find oparation: " + OperationId()); | 55 | context.response()->write("not find oparation: " + OperationId()); |
53 | } | 56 | } |
@@ -56,6 +59,7 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -56,6 +59,7 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
56 | { | 59 | { |
57 | switch (context.request()->method()) | 60 | switch (context.request()->method()) |
58 | { | 61 | { |
62 | + | ||
59 | case DmpServerRequest::Method::GET_METHOD: | 63 | case DmpServerRequest::Method::GET_METHOD: |
60 | { | 64 | { |
61 | context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); | 65 | context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); |
@@ -93,9 +97,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -93,9 +97,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
93 | context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | 97 | context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); |
94 | return; | 98 | return; |
95 | } | 99 | } |
96 | - if(context.manager()->publish(serverType, name, title, capabilities, project)) { | 100 | + int flag=context.manager()->publish(serverType, name, title, capabilities, project); |
101 | + if(flag==1) { | ||
97 | LOGGER_INFO("服务发布成功"); | 102 | LOGGER_INFO("服务发布成功"); |
98 | - context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}"); | 103 | + std::string http="http://"+context.request()->domain()+":"+context.request()->port(); |
104 | + std::string url=http+"/DMap/Services/"+name+"/TileServer/tmsService?REQUEST=GetThumbnail"; | ||
105 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}"); | ||
99 | // std::string projData; | 106 | // std::string projData; |
100 | // DmpServerUtils::Base64Decode(project, &projData); | 107 | // DmpServerUtils::Base64Decode(project, &projData); |
101 | // context.response()->removeHeader("Content-Type"); | 108 | // context.response()->removeHeader("Content-Type"); |
@@ -105,7 +112,14 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -105,7 +112,14 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
105 | else | 112 | else |
106 | { | 113 | { |
107 | LOGGER_ERROR("服务发布失败"); | 114 | LOGGER_ERROR("服务发布失败"); |
108 | - context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | 115 | + if(flag==0) |
116 | + { | ||
117 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"message\":\"Pulish service thumbnail fail!\"}"); | ||
118 | + } | ||
119 | + else | ||
120 | + { | ||
121 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"message\":\"Pulish service fail!\"}"); | ||
122 | + } | ||
109 | } | 123 | } |
110 | } | 124 | } |
111 | else | 125 | else |
@@ -236,4 +250,117 @@ void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) co | @@ -236,4 +250,117 @@ void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) co | ||
236 | 250 | ||
237 | } | 251 | } |
238 | } | 252 | } |
253 | +} | ||
254 | +//获取配置文件切片信息 | ||
255 | +void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context) const | ||
256 | +{ | ||
257 | + switch (context.request()->method()) | ||
258 | + { | ||
259 | + case DmpServerRequest::Method::GET_METHOD: | ||
260 | + { | ||
261 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取切片配置信息——————GET\"}"); | ||
262 | + break; | ||
263 | + } | ||
264 | + case DmpServerRequest::Method::POST_METHOD: | ||
265 | + { | ||
266 | + std::string path; | ||
267 | + std::string strExtent; | ||
268 | + const char* data = (char*)(context.request()->GetData()); | ||
269 | + if(data && *data != '\0') | ||
270 | + { | ||
271 | + try | ||
272 | + { | ||
273 | + std::stringstream stream(data); | ||
274 | + boost::property_tree::ptree pt; | ||
275 | + boost::property_tree::ptree pt_json; | ||
276 | + std::string confcdipath; | ||
277 | + std::string confxmlpath; | ||
278 | + | ||
279 | + boost::property_tree::read_json(stream, pt); | ||
280 | + path= pt.get<std::string>("projectlayers.maplayer.datasource"); | ||
281 | + confcdipath=path+"/conf.cdi"; | ||
282 | + confxmlpath=path+"/conf.xml"; | ||
283 | + //读取切片配置文件conf.cdi | ||
284 | + boost::property_tree::ptree pt_confcdi; | ||
285 | + boost::property_tree::read_xml(confcdipath,pt_confcdi); | ||
286 | + //boost::property_tree::ptree pt_base=pt.get_child("base"); | ||
287 | + std::string xmin=pt_confcdi.get<std::string>("EnvelopeN.XMin"); | ||
288 | + std::string ymin=pt_confcdi.get<std::string>("EnvelopeN.YMin"); | ||
289 | + std::string xmax=pt_confcdi.get<std::string>("EnvelopeN.XMax"); | ||
290 | + std::string ymax=pt_confcdi.get<std::string>("EnvelopeN.YMax"); | ||
291 | + pt.put("projectlayers.maplayer.extent.xmin",xmin); | ||
292 | + pt.put("projectlayers.maplayer.extent.ymin",ymin); | ||
293 | + pt.put("projectlayers.maplayer.extent.xmax",xmax); | ||
294 | + pt.put("projectlayers.maplayer.extent.ymax",ymax); | ||
295 | + //读取配置文件conf.xml | ||
296 | + boost::property_tree::ptree pt_confxml; | ||
297 | + boost::property_tree::read_xml(confxmlpath,pt_confxml); | ||
298 | + std::string strWKT=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKT"); | ||
299 | + std::string wkid=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKID"); | ||
300 | + std::string top=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.X"); | ||
301 | + std::string left=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.Y"); | ||
302 | + std::string tileCols=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileCols"); | ||
303 | + std::string tileRows=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileRows"); | ||
304 | + std::string dpi=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.DPI"); | ||
305 | + pt.put("projectCrs.spatialrefsys.wkt",strWKT); | ||
306 | + pt.put("projectCrs.spatialrefsys.srid",wkid); | ||
307 | + | ||
308 | + boost::property_tree::ptree pt_tileMatrixSets=pt.get_child("tileMatrixSets"); | ||
309 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v1,pt_tileMatrixSets) | ||
310 | + { | ||
311 | + //conf.xml中读取tileinfo | ||
312 | + boost::property_tree::ptree pt_levels,pt_tileMatrixSet; | ||
313 | + boost::property_tree::ptree pt_tileArry=pt_confxml.get_child("CacheInfo.TileCacheInfo.LODInfos"); | ||
314 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v2,pt_tileArry) | ||
315 | + { | ||
316 | + boost::property_tree::ptree pt_level; | ||
317 | + if(v2.first=="LODInfo") | ||
318 | + { | ||
319 | + std::string level=v2.second.get<std::string>("LevelID"); | ||
320 | + std::string scale=v2.second.get<std::string>("Scale"); | ||
321 | + std::string resolution=v2.second.get<std::string>("Resolution"); | ||
322 | + pt_level.add("level.id",level); | ||
323 | + pt_level.add("level.scaleDenominator",scale); | ||
324 | + pt_level.add("level.resolution",resolution); | ||
325 | + pt_levels.push_back(std::make_pair("", pt_level)); | ||
326 | + } | ||
327 | + } | ||
328 | + std::string id_=v1.second.get<std::string>("tileMatrixSet.id"); | ||
329 | + pt_tileMatrixSet.add("id",id_); | ||
330 | + pt_tileMatrixSet.add("crs","EPSG::"+wkid); | ||
331 | + pt_tileMatrixSet.add("tileCols",tileCols); | ||
332 | + pt_tileMatrixSet.add("tileRows",tileRows); | ||
333 | + pt_tileMatrixSet.add("dpi",dpi); | ||
334 | + pt_tileMatrixSet.add("tileOrigin.X",top); | ||
335 | + pt_tileMatrixSet.add("tileOrigin.Y",left); | ||
336 | + pt_tileMatrixSet.add_child("levels",pt_levels); | ||
337 | + //pt_tilelist.add_child("tileMatrixList",pt_tiles); | ||
338 | + v1.second.put_child("tileMatrixSet",pt_tileMatrixSet); | ||
339 | + //v1.second.put("id","EPSG::"+wkid); | ||
340 | + } | ||
341 | + | ||
342 | + pt.put_child("tileMatrixSets",pt_tileMatrixSets); | ||
343 | + std::stringstream ss; | ||
344 | + boost::property_tree::write_json(ss,pt); | ||
345 | + strExtent=ss.str(); | ||
346 | + } | ||
347 | + catch (boost::property_tree::ptree_bad_path& e) { | ||
348 | + LOGGER_ERROR(e.what()); | ||
349 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
350 | + return; | ||
351 | + } | ||
352 | + catch (boost::property_tree::ptree_bad_data& e) { | ||
353 | + LOGGER_ERROR(e.what()); | ||
354 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
355 | + return; | ||
356 | + } | ||
357 | + context.response()->write(strExtent); | ||
358 | + } | ||
359 | + break; | ||
360 | + } | ||
361 | + default: | ||
362 | + { | ||
363 | + | ||
364 | + } | ||
365 | + } | ||
239 | } | 366 | } |
@@ -27,6 +27,7 @@ public: | @@ -27,6 +27,7 @@ public: | ||
27 | void deleteService(const DmpServerApiContext &context) const; | 27 | void deleteService(const DmpServerApiContext &context) const; |
28 | void getCapabilities(const DmpServerApiContext &context)const; | 28 | void getCapabilities(const DmpServerApiContext &context)const; |
29 | void reloadServices(const DmpServerApiContext &context)const; | 29 | void reloadServices(const DmpServerApiContext &context)const; |
30 | + void GetTileServiceInfo(const DmpServerApiContext &context) const; | ||
30 | 31 | ||
31 | }; | 32 | }; |
32 | 33 |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | 3 | ||
4 | SET (TILESERVER_SRCS | 4 | SET (TILESERVER_SRCS |
5 | dmptileserver.cpp | 5 | dmptileserver.cpp |
6 | + #dmptilethumbnail.cpp | ||
6 | wmts/dmpwmts.cpp | 7 | wmts/dmpwmts.cpp |
7 | wmts/dmpwmtsparameters.cpp | 8 | wmts/dmpwmtsparameters.cpp |
8 | wmts/dmptileproviderfactory.cpp | 9 | wmts/dmptileproviderfactory.cpp |
@@ -18,6 +19,7 @@ SET (TILESERVER_SRCS | @@ -18,6 +19,7 @@ SET (TILESERVER_SRCS | ||
18 | 19 | ||
19 | SET (TILESERVER_HDRS | 20 | SET (TILESERVER_HDRS |
20 | dmptileserver.h | 21 | dmptileserver.h |
22 | + #dmptilethumbnail.h | ||
21 | wmts/dmpwmtsparameters.h | 23 | wmts/dmpwmtsparameters.h |
22 | wmts/dmptileprovider.h | 24 | wmts/dmptileprovider.h |
23 | wmts/dmptileproviderfactory.h | 25 | wmts/dmptileproviderfactory.h |
@@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
12 | #include "wmts/dmpwmts.h" | 12 | #include "wmts/dmpwmts.h" |
13 | #include "tms/dmptms.h" | 13 | #include "tms/dmptms.h" |
14 | #include "dmpserverresponse.h" | 14 | #include "dmpserverresponse.h" |
15 | +#include "dmptilethumbnail.h" | ||
15 | 16 | ||
16 | namespace tileserver | 17 | namespace tileserver |
17 | { | 18 | { |
@@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
23 | #include "dmpservice.h" | 23 | #include "dmpservice.h" |
24 | #include "dmpserverutils.h" | 24 | #include "dmpserverutils.h" |
25 | #include "dmpserverproject.h" | 25 | #include "dmpserverproject.h" |
26 | +#include<cairo/cairo.h> | ||
26 | 27 | ||
27 | namespace tileserver | 28 | namespace tileserver |
28 | { | 29 | { |
@@ -52,15 +52,21 @@ namespace DmpWmts | @@ -52,15 +52,21 @@ namespace DmpWmts | ||
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | } | 54 | } |
55 | - 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,const std::string& title,DmpServerResponse& response) |
56 | { | 56 | { |
57 | //构建能力文档 | 57 | //构建能力文档 |
58 | boost::property_tree::ptree pt_root,pt_TileMatrix; | 58 | boost::property_tree::ptree pt_root,pt_TileMatrix; |
59 | - CreateGetCapabilitiesDocument(host,servicename,pt_root); | 59 | + //CreateGetCapabilitiesDocument(host,servicename,pt_root); |
60 | + CreateGetCapabilitiesDocument(host,title,pt_root); | ||
60 | pt_root.add("Capabilities.Contents.Layer.ows:Title",pt.get<std::string>("Layer.ows:Title")); | 61 | pt_root.add("Capabilities.Contents.Layer.ows:Title",pt.get<std::string>("Layer.ows:Title")); |
61 | pt_root.add("Capabilities.Contents.Layer.ows:Abstract",pt.get<std::string>("Layer.ows:Abstract")); | 62 | pt_root.add("Capabilities.Contents.Layer.ows:Abstract",pt.get<std::string>("Layer.ows:Abstract")); |
62 | pt_root.add("Capabilities.Contents.Layer.ows:Identifier",pt.get<std::string>("Layer.ows:Identifier")); | 63 | pt_root.add("Capabilities.Contents.Layer.ows:Identifier",pt.get<std::string>("Layer.ows:Identifier")); |
63 | //pt_root_.add("Capabilities.Contents.Layer.Style.<xmlattr>.isDefault",pt_.get<std::string>("Layer.Style.<xmlattr>.isDefault")); | 64 | //pt_root_.add("Capabilities.Contents.Layer.Style.<xmlattr>.isDefault",pt_.get<std::string>("Layer.Style.<xmlattr>.isDefault")); |
65 | + | ||
66 | + | ||
67 | + pt_root.add("Capabilities.Contents.Layer.ows:BoundingBox.ows:LowerCorner",pt.get<std::string>("Layer.ows:BoundingBox.ows:LowerCorner")); | ||
68 | + pt_root.add("Capabilities.Contents.Layer.ows:BoundingBox.ows:UpperCorner",pt.get<std::string>("Layer.ows:BoundingBox.ows:UpperCorner")); | ||
69 | + | ||
64 | pt_root.add("Capabilities.Contents.Layer.Style",pt.get<std::string>("Layer.Style")); | 70 | pt_root.add("Capabilities.Contents.Layer.Style",pt.get<std::string>("Layer.Style")); |
65 | pt_root.add("Capabilities.Contents.Layer.Format",pt.get<std::string>("Layer.Format")); | 71 | pt_root.add("Capabilities.Contents.Layer.Format",pt.get<std::string>("Layer.Format")); |
66 | pt_root.add("Capabilities.Contents.Layer.TileMatrixSetLink.TileMatrixSet",pt.get<std::string>("Layer.TileMatrixSetLink.TileMatrixSet")); | 72 | pt_root.add("Capabilities.Contents.Layer.TileMatrixSetLink.TileMatrixSet",pt.get<std::string>("Layer.TileMatrixSetLink.TileMatrixSet")); |
@@ -35,7 +35,7 @@ namespace DmpWmts | @@ -35,7 +35,7 @@ namespace DmpWmts | ||
35 | public: | 35 | public: |
36 | DmpCapabiliTilesOperation(); | 36 | DmpCapabiliTilesOperation(); |
37 | void WriteCapabilities(DmpServerResponse& response); | 37 | void WriteCapabilities(DmpServerResponse& response); |
38 | - 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,const std::string& title,DmpServerResponse& response); |
39 | void GetCapabilitiesDocument(DmpServerResponse& response); | 39 | void GetCapabilitiesDocument(DmpServerResponse& response); |
40 | 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); |
41 | void GetServiceIdentificationElement(const std::string& servicename,boost::property_tree::ptree& pt); | 41 | void GetServiceIdentificationElement(const std::string& servicename,boost::property_tree::ptree& pt); |
@@ -66,7 +66,7 @@ namespace DmpWmts | @@ -66,7 +66,7 @@ namespace DmpWmts | ||
66 | const DmpServerProject *serverProject = context.serverProject(); | 66 | const DmpServerProject *serverProject = context.serverProject(); |
67 | const DmpProject *project = serverProject->project(); | 67 | const DmpProject *project = serverProject->project(); |
68 | DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer(layerName)); | 68 | DmpTileLayer *tileLayer = static_cast<DmpTileLayer *>(project->getLayer(layerName)); |
69 | - | 69 | + |
70 | if (req.empty()) | 70 | if (req.empty()) |
71 | { | 71 | { |
72 | context.response()->writeHtml("wmts,Operation is null"); | 72 | context.response()->writeHtml("wmts,Operation is null"); |
@@ -79,11 +79,11 @@ namespace DmpWmts | @@ -79,11 +79,11 @@ namespace DmpWmts | ||
79 | } | 79 | } |
80 | else if(boost::iequals(req, "GetThumbnail")) | 80 | else if(boost::iequals(req, "GetThumbnail")) |
81 | { | 81 | { |
82 | - | ||
83 | } | 82 | } |
84 | else if (boost::iequals(req, "GetCapabilities")) | 83 | else if (boost::iequals(req, "GetCapabilities")) |
85 | { | 84 | { |
86 | const std::string host=context.request()->domain()+":"+context.request()->port();; | 85 | const std::string host=context.request()->domain()+":"+context.request()->port();; |
86 | + const std::string title=serverProject->title(); | ||
87 | const std::string servicename=serverProject->name(); | 87 | const std::string servicename=serverProject->name(); |
88 | 88 | ||
89 | boost::property_tree::ptree pt; | 89 | boost::property_tree::ptree pt; |
@@ -92,6 +92,11 @@ namespace DmpWmts | @@ -92,6 +92,11 @@ namespace DmpWmts | ||
92 | pt.add("Layer.ows:Identifier",""); | 92 | pt.add("Layer.ows:Identifier",""); |
93 | pt.add("Layer.Style",tileLayer->getStyle()); | 93 | pt.add("Layer.Style",tileLayer->getStyle()); |
94 | pt.add("Layer.Format",tileLayer->getFormat()); | 94 | pt.add("Layer.Format",tileLayer->getFormat()); |
95 | + DmpRectangle rectangle=tileLayer->extent(); | ||
96 | + std::string lowerPoint=std::to_string(rectangle.xmin())+" "+std::to_string(rectangle.ymin()); | ||
97 | + std::string upperPoint=std::to_string(rectangle.xmax())+" "+std::to_string(rectangle.ymax()); | ||
98 | + pt.add("Layer.ows:BoundingBox.ows:LowerCorner",lowerPoint); | ||
99 | + pt.add("Layer.ows:BoundingBox.ows:UpperCorner",upperPoint); | ||
95 | 100 | ||
96 | std::vector<DmpTileMatrixSet*> tileMatrixSets; | 101 | std::vector<DmpTileMatrixSet*> tileMatrixSets; |
97 | tileLayer->getTileMatrixSets(tileMatrixSets); | 102 | tileLayer->getTileMatrixSets(tileMatrixSets); |
@@ -119,11 +124,12 @@ namespace DmpWmts | @@ -119,11 +124,12 @@ namespace DmpWmts | ||
119 | pt.add("TileMatrixSet.TileHeight",(*iter)->tileRows()); | 124 | pt.add("TileMatrixSet.TileHeight",(*iter)->tileRows()); |
120 | pt.add("TileMatrixSet.TopLeftCorner",std::to_string((*iter)->tileOrigin()->x())+","+std::to_string((*iter)->tileOrigin()->y())); | 125 | pt.add("TileMatrixSet.TopLeftCorner",std::to_string((*iter)->tileOrigin()->x())+","+std::to_string((*iter)->tileOrigin()->y())); |
121 | pt.add("TileMatrixSet.DPI",(*iter)->dpi()); | 126 | pt.add("TileMatrixSet.DPI",(*iter)->dpi()); |
127 | + | ||
122 | } | 128 | } |
123 | //boost::property_tree::write_json("/mnt/d/json.txt",pt); | 129 | //boost::property_tree::write_json("/mnt/d/json.txt",pt); |
124 | 130 | ||
125 | DmpCapabiliTilesOperation capOper; | 131 | DmpCapabiliTilesOperation capOper; |
126 | - capOper.WriteCapabilities(pt,host,servicename,*context.response()); | 132 | + capOper.WriteCapabilities(pt,host,servicename,title,*context.response()); |
127 | 133 | ||
128 | } | 134 | } |
129 | } | 135 | } |
请
注册
或
登录
后发表评论