提交 65e902c02a0e0a04cd7ecf18a102bb2b33f95de1

作者 LJH 李佳桓
2 个父辈 d6049415 a9f08b3f
... ... @@ -50,6 +50,8 @@ public:
50 50 void setHeader(const std::string &name, const std::string &value);
51 51 Headers headers() const { return headers_; }
52 52 bool isRestful() const { return isRestful_; }
  53 + std::string serviceName() const { return serviceName_;}
  54 + void setServiceName(const std::string &serviceName) { serviceName_ = serviceName;}
53 55
54 56 DmpServerParameters serverParameters() const { return params_; }
55 57 void setParameter(const std::string &name, const std::string &value);
... ... @@ -68,6 +70,7 @@ protected:
68 70 std::string port_;
69 71 std::string path_;
70 72 std::string query_;
  73 + std::string serviceName_;
71 74 bool isRestful_;
72 75
73 76 private:
... ...
... ... @@ -23,6 +23,7 @@
23 23 #include "dmplogger.h"
24 24 #include "dmpapiutils.h"
25 25 #include "dmpservermanager.h"
  26 +#include "dmpserverutils.h"
26 27
27 28 DmpManagerApiHandler::DmpManagerApiHandler()
28 29 {
... ... @@ -126,8 +127,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const
126 127 }
127 128 if(context.manager()->publish(serverType, name, capabilities, project)) {
128 129 LOGGER_INFO("服务发布成功");
129   - //context.response()->write("{\"status\":\"true\",\"message\":\"服务发布成功\"}");
130 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);
131 136 }
132 137 else
133 138 {
... ...
... ... @@ -65,6 +65,7 @@ void DmpTileServer::executeRequest(DmpServerRequest &request, DmpServerResponse
65 65 if(what.size() == 4) {
66 66 std::string serviceName = what[1].str();
67 67 std::string serverType = what[2].str();
  68 + request.setServiceName(serviceName);
68 69 if(request.isRestful()) {
69 70 std::string queryString = what[3].str();
70 71 request.setQuery(queryString);
... ...
... ... @@ -45,29 +45,6 @@ namespace DmpWmts
45 45 return method == DmpServerRequest::GET_METHOD;
46 46 }
47 47
48   - std::string getWMTSServiceName(const std::string& url)
49   - {
50   - std::string service_name;
51   - boost::cmatch what;
52   - std::string path_("^/DMap/Services/?(/[\\w./]*)/TileServer/WMTSService");
53   - boost::regex reg(path_, boost::regex_constants::icase);
54   - if(boost::regex_search(url.c_str(), what, reg))
55   - {
56   - if(what.size() >= 2) {
57   - std::string server_path = what[1].str();
58   - std::string::size_type pos = server_path.find_first_of("/");
59   -
60   - if(pos != std::string::npos) {
61   - service_name = server_path.substr(pos+1,server_path.length()-1);
62   - }
63   - else {
64   - service_name = server_path;
65   - }
66   -
67   - }
68   - }
69   - return service_name;
70   - }
71 48 void DmpWMTSService::executeRequest(const DmpServerContext &context)
72 49 {
73 50 DmpWmtsParameters *params = nullptr;
... ... @@ -106,7 +83,7 @@ namespace DmpWmts
106 83 else if (boost::iequals(req, "GetCapabilities"))
107 84 {
108 85 const std::string host_=context.request()->domain()+":"+context.request()->port();;
109   - const std::string servicename_=getWMTSServiceName(context.request()->path());
  86 + const std::string servicename_=context.request()->serviceName();
110 87
111 88 boost::property_tree::ptree pt;
112 89 pt.add("Layer.ows:Title",tileLayer->title());
... ... @@ -148,93 +125,5 @@ namespace DmpWmts
148 125 capOper.WriteCapabilities(pt,host_,servicename_,*context.response());
149 126
150 127 }
151   -
152   - //std::string Msg_,connMsg_;
153   - //std::string strsql_="SELECT \"Id\", \"Name\" FROM public.\"TileMapItem\";";
154   - //PgsqlUtils *pg_=new PgsqlUtils(connMsg_);
155   - //pg_->ExecuteQuery(strsql_,Msg_);
156   -
157   - //获取服务的实例
158   - // std::string service_name = GetServiceName(context.request()->path());
159   - // DmpService* service_ = GetService(service_name);
160   - // if(!service_) {
161   - // context.response()->write("找不到服务:" + service_name + "请确保服务已发布!");
162   - // }
163   - //判断RESTful、Kvp请求方式
164   - /*
165   - std::string path_= context.request()->path();
166   - if(strstr(path_.c_str(), "?") == NULL)
167   - {
168   - int row_,col_,matrix_;
169   - std::string format_;
170   - vector<string> vec;
171   - boost::split(vec,path_,boost::is_any_of("/"),boost::token_compress_on);
172   - int isize=vec.size();
173   - if(isize<8)
174   - {
175   - context.response()->write("Tms,Operation is null");
176   - }
177   - if(vec[isize-1].compare(".png")||vec[isize-1].compare(".jpg"))
178   - {
179   - vector<string> vec0;
180   - boost::split(vec0,vec[isize-1],boost::is_any_of("."),boost::token_compress_on);
181   - format_=vec0[1];
182   - col_=atoi(vec0[0].c_str());
183   - row_=atoi(vec[isize-2].c_str());
184   - matrix_=atoi(vec[isize-3].c_str());
185   - std::shared_ptr<DmpTileProvider> provider = TileProviderFactory::GetProvider(service_);
186   - provider->WriteTile(row_, col_, matrix_, format_, *context.response());
187   - }
188   - else
189   - {
190   - context.response()->write("Tms,Operation is null");
191   - }
192   -
193   - }
194   - */
195   - // const DmpWmtsParameters params(context.request()->serverParameters());
196   - // int tile_col = params.TileCol();
197   - // int tile_row = params.TileRow();
198   - // int tile_matrix = params.TileMatrix();
199   - // string req = params.Request();
200   - // DmpWmtsParameters::Format format = params.ImageFormat();
201   - // if (req.empty())
202   - // {
203   - // context.response()->write("wmts,Operation is null");
204   - // }
205   - // if (boost::iequals(req, "GetTile"))
206   - // {
207   - // string f = (format == DmpWmtsParameters::Format::JPG) ? "jpg" : "png";
208   - // std::shared_ptr<DmpTileProvider> provider = TileProviderFactory::GetProvider(service_);
209   - // provider->WriteTile(tile_row, tile_col, tile_matrix, f, *context.response());
210   - // }
211   - // else if (boost::iequals(req, "GetCapabilities"))
212   - // {
213   - //std::shared_ptr<DmpCapabiliTilesProvider> provider = CapabiliTileProviderFactory::GetProvider();
214   - //provider->WriteCapabilities(*context.response());
215   -
216   - // std::string host_=context.request()->domain()+":"+context.request()->port();
217   -
218   - // std::shared_ptr<DmpCapabiliTilesProvider> provider = CapabiliTileProviderFactory::GetProvider();
219   - // boost::property_tree::ptree pt_;
220   - // if(context.manager()->GetTilePTree(service_name,pt_))
221   - // {
222   - // //provider->WriteCapabilities(pt_,host_,service_name,*context.response());
223   - // provider->WriteCapabilities(*context.response());
224   - // }
225   - // else
226   - // {
227   - // context.response()->write("GetTileInfo false");
228   - // }
229   -
230   - // }
231   - // else if (boost::iequals(req, "GetFeatureInfo"))
232   - // {
233   - // context.response()->write("wmts, GetFeatureInfo");
234   - // }
235   - // else
236   - // {
237   - // context.response()->write("wmts,Operation not supported");
238   - // }
239 128 }
240 129 } // namespace DmpWmts
\ No newline at end of file
... ...
注册登录 后发表评论