...
|
...
|
@@ -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 |
...
|
...
|
|