|
@@ -28,11 +28,11 @@ namespace DmpWms |
|
@@ -28,11 +28,11 @@ namespace DmpWms |
28
|
std::string title = context.serverProject()->title();
|
28
|
std::string title = context.serverProject()->title();
|
29
|
if(port == "80" || port =="")
|
29
|
if(port == "80" || port =="")
|
30
|
{
|
30
|
{
|
31
|
- sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->enpath().c_str());
|
31
|
+ sprintf(char_hrefUrl, "http://%s%s?mapservice=10w", domain.c_str(), context.request()->enpath().c_str());
|
32
|
}
|
32
|
}
|
33
|
else
|
33
|
else
|
34
|
{
|
34
|
{
|
35
|
- sprintf(char_hrefUrl, "http://%s:%s%s", domain.c_str(),port.c_str(), context.request()->enpath().c_str());
|
35
|
+ sprintf(char_hrefUrl, "http://%s:%s%s?mapservice=10w", domain.c_str(),port.c_str(), context.request()->enpath().c_str());
|
36
|
}
|
36
|
}
|
37
|
hrefUrl = char_hrefUrl;
|
37
|
hrefUrl = char_hrefUrl;
|
38
|
// hrefUrl = "http://172.26.40.51:8821/?mapService=test";
|
38
|
// hrefUrl = "http://172.26.40.51:8821/?mapService=test";
|
|
@@ -45,10 +45,131 @@ namespace DmpWms |
|
@@ -45,10 +45,131 @@ namespace DmpWms |
45
|
|
45
|
|
46
|
// DmpServerResponse* response = context.response();
|
46
|
// DmpServerResponse* response = context.response();
|
47
|
context.response()->removeHeader("Content-Type");
|
47
|
context.response()->removeHeader("Content-Type");
|
48
|
- context.response()->setHeader("Content-Type", "text/xml;charset=utf-8");
|
48
|
+ context.response()->setHeader("Content-Type", "text/xml");
|
49
|
context.response()->write(xml);
|
49
|
context.response()->write(xml);
|
50
|
}
|
50
|
}
|
51
|
|
51
|
|
|
|
52
|
+ void writeGetCapabilities_3_0(const DmpServerContext &context, const DmpWmsParameters& params,
|
|
|
53
|
+ const DmpProject* project, bool projectSettings)
|
|
|
54
|
+ {
|
|
|
55
|
+ char resultBuff[10000];
|
|
|
56
|
+ string reponseString;
|
|
|
57
|
+ std::string version = params.Version();
|
|
|
58
|
+ std::string hrefUrl;
|
|
|
59
|
+ char char_hrefUrl[1024] = {0};
|
|
|
60
|
+ std::string domain = context.request()->domain();
|
|
|
61
|
+ std::string port = context.request()->port();
|
|
|
62
|
+ std::string name = context.serverProject()->name();
|
|
|
63
|
+ std::string title = context.serverProject()->title();
|
|
|
64
|
+ if(port == "80" || port =="")
|
|
|
65
|
+ {
|
|
|
66
|
+ sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->enpath().c_str());
|
|
|
67
|
+ }
|
|
|
68
|
+ else
|
|
|
69
|
+ {
|
|
|
70
|
+ sprintf(char_hrefUrl, "http://%s:%s%s", domain.c_str(),port.c_str(), context.request()->enpath().c_str());
|
|
|
71
|
+ }
|
|
|
72
|
+ hrefUrl = char_hrefUrl;
|
|
|
73
|
+
|
|
|
74
|
+
|
|
|
75
|
+ sprintf(resultBuff, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<WMS_Capabilities version=\"1.3.0\"><Service><Name>WMS</Name><Title>Dmap %s</Title><Abstract>%s</Abstract><Keywords>GIMS</Keywords><OnlineResource /><Fees>none</Fees><AccessConstraints>none</AccessConstraints></Service>",
|
|
|
76
|
+ name.c_str(), name.c_str());
|
|
|
77
|
+
|
|
|
78
|
+ reponseString.append(resultBuff);
|
|
|
79
|
+ sprintf(resultBuff, "<Capability><Request>");
|
|
|
80
|
+ reponseString.append(resultBuff);
|
|
|
81
|
+
|
|
|
82
|
+
|
|
|
83
|
+
|
|
|
84
|
+ sprintf(resultBuff, "<GetCapabilities><Format>text/xml</Format><DCPType><HTTP><Get><OnlineResource xlink:type=\"simple\" xlink:href=\"%s\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/></Get></HTTP></DCPType></GetCapabilities>", hrefUrl.c_str());
|
|
|
85
|
+ reponseString.append(resultBuff);
|
|
|
86
|
+
|
|
|
87
|
+ sprintf(resultBuff, "<GetMap><Format>png</Format><Format>jpeg</Format><Format>gif</Format><Format>image/png</Format><Format>image/jpeg</Format><Format>image/gif</Format><DCPType><HTTP><Get><OnlineResource xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:type=\"simple\" xlink:href=\"%s\"/></Get></HTTP></DCPType></GetMap>", hrefUrl.c_str());
|
|
|
88
|
+ reponseString.append(resultBuff);
|
|
|
89
|
+
|
|
|
90
|
+ sprintf(resultBuff, "<Map><Format><PNG/><GIF/><JPG/></Format><DCPType><HTTP><Get onlineResource=\"%s\" /></HTTP></DCPType></Map>", hrefUrl.c_str());
|
|
|
91
|
+ reponseString.append(resultBuff); //stbstb <JPEG /><GIF />
|
|
|
92
|
+
|
|
|
93
|
+ sprintf(resultBuff, "<Capabilities><Format><WMS_XML/></Format><DCPType><HTTP><Get onlineResource=\"%s\" /></HTTP></DCPType></Capabilities><FeatureInfo><Format><XML /><MIME /></Format><DCPType><HTTP><Get onlineResource=\"%s\" /></HTTP></DCPType></FeatureInfo></Request><Exception><Format><WMS_XML /><INIMAGE /><BLANK /></Format></Exception><Layer><Name>%s</Name><Title>%s</Title>",
|
|
|
94
|
+ hrefUrl.c_str(),
|
|
|
95
|
+ hrefUrl.c_str(),
|
|
|
96
|
+ name.c_str(),
|
|
|
97
|
+ title.c_str());
|
|
|
98
|
+
|
|
|
99
|
+ reponseString.append(resultBuff);
|
|
|
100
|
+
|
|
|
101
|
+ string srid = "0";
|
|
|
102
|
+ if(project->vectorLayers().size()>0)
|
|
|
103
|
+ {
|
|
|
104
|
+ DmpVectorLayer* vectorLayer = (DmpVectorLayer*)project->vectorLayers().at(0);
|
|
|
105
|
+ srid = vectorLayer->srid();
|
|
|
106
|
+ // shared_ptr<MapLayer> mapLayer = service->layers.at(0);
|
|
|
107
|
+ // srid = mapLayer->m_srid;
|
|
|
108
|
+ }
|
|
|
109
|
+
|
|
|
110
|
+ std::shared_ptr<DmpRectangle> rect_service = ((DmpProject*)project)->GetExtent();
|
|
|
111
|
+ if (rect_service != nullptr)
|
|
|
112
|
+ {
|
|
|
113
|
+ sprintf(resultBuff, "<CRS>EPSG:%s</CRS>", srid.c_str());
|
|
|
114
|
+ reponseString.append(resultBuff);
|
|
|
115
|
+
|
|
|
116
|
+ sprintf(resultBuff, R"(<EX_GeographicBoundingBox>
|
|
|
117
|
+<westBoundLongitude>%f</westBoundLongitude>
|
|
|
118
|
+<eastBoundLongitude>%f</eastBoundLongitude>
|
|
|
119
|
+<southBoundLatitude>%f</southBoundLatitude>
|
|
|
120
|
+<northBoundLatitude>%f</northBoundLatitude>
|
|
|
121
|
+</EX_GeographicBoundingBox>)",
|
|
|
122
|
+ rect_service->xmin(), rect_service->xmax(),rect_service->ymin(),
|
|
|
123
|
+ rect_service->ymax());
|
|
|
124
|
+ reponseString.append(resultBuff);
|
|
|
125
|
+
|
|
|
126
|
+
|
|
|
127
|
+
|
|
|
128
|
+ sprintf(resultBuff, "<BoundingBox CRS=\"EPSG:%s\" minx=\"%f\" miny=\"%f\" maxx=\"%f\" maxy=\"%f\"/>",
|
|
|
129
|
+ srid.c_str(), rect_service->xmin(), rect_service->ymin(),
|
|
|
130
|
+ rect_service->xmax(), rect_service->ymax());
|
|
|
131
|
+ // rect_service->m_dBottom, rect_service->m_dRight,rect_service->m_dTop
|
|
|
132
|
+ reponseString.append(resultBuff);
|
|
|
133
|
+
|
|
|
134
|
+ for (int i = 0; i < project->vectorLayers().size(); i++)
|
|
|
135
|
+ {
|
|
|
136
|
+ DmpVectorLayer *mapLayer = (DmpVectorLayer *)project->vectorLayers().at(i);
|
|
|
137
|
+
|
|
|
138
|
+ DmpRectangle rect = mapLayer->extent();
|
|
|
139
|
+
|
|
|
140
|
+ sprintf(resultBuff, R"(<EX_GeographicBoundingBox>
|
|
|
141
|
+<westBoundLongitude>%f</westBoundLongitude>
|
|
|
142
|
+<eastBoundLongitude>%f</eastBoundLongitude>
|
|
|
143
|
+<southBoundLatitude>%f</southBoundLatitude>
|
|
|
144
|
+<northBoundLatitude>%f</northBoundLatitude>
|
|
|
145
|
+</EX_GeographicBoundingBox>)",
|
|
|
146
|
+ rect.xmin(), rect.xmax(),rect.ymin(),
|
|
|
147
|
+ rect.ymax());
|
|
|
148
|
+
|
|
|
149
|
+ reponseString.append(resultBuff);
|
|
|
150
|
+ // if(rect == nullptr)
|
|
|
151
|
+ // continue;
|
|
|
152
|
+ sprintf(resultBuff, "\r\n<Layer queryable=\"1\"><CRS>EPSG:%s</CRS><Name>%s</Name><Title>%s</Title><BoundingBox CRS=\"EPSG:%s\" minx=\"%lf\" miny=\"%lf\" maxx=\"%lf\" maxy=\"%lf\" /></Layer>",
|
|
|
153
|
+ mapLayer->srid().c_str(),
|
|
|
154
|
+
|
|
|
155
|
+ mapLayer->name().c_str(),
|
|
|
156
|
+ mapLayer->title().empty()? mapLayer->name().c_str(): mapLayer->title().c_str(),
|
|
|
157
|
+ mapLayer->srid().c_str(),
|
|
|
158
|
+ rect.xmin(),
|
|
|
159
|
+ rect.ymin(),
|
|
|
160
|
+ rect.xmax(),
|
|
|
161
|
+ rect.ymax()
|
|
|
162
|
+ );
|
|
|
163
|
+
|
|
|
164
|
+ reponseString.append(resultBuff);
|
|
|
165
|
+ }
|
|
|
166
|
+ reponseString.append("</Layer></Capability></WMS_Capabilities>");
|
|
|
167
|
+ }
|
|
|
168
|
+ context.response()->removeHeader("Content-Type");
|
|
|
169
|
+ context.response()->setHeader("Content-Type", "text/xml");
|
|
|
170
|
+ context.response()->write(reponseString);
|
|
|
171
|
+ }
|
|
|
172
|
+
|
52
|
std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
|
173
|
std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
|
53
|
const std::string &version, const std::string &hrefUrl, std::string& name, std::string& title,
|
174
|
const std::string &version, const std::string &hrefUrl, std::string& name, std::string& title,
|
54
|
bool projectSettings )
|
175
|
bool projectSettings )
|
|
@@ -77,7 +198,7 @@ namespace DmpWms |
|
@@ -77,7 +198,7 @@ namespace DmpWms |
77
|
ptService.add("Title", title);
|
198
|
ptService.add("Title", title);
|
78
|
ptService.add("Abstract", "dmap wms service");
|
199
|
ptService.add("Abstract", "dmap wms service");
|
79
|
ptService.add("Keywords", "WMS,DMAP");
|
200
|
ptService.add("Keywords", "WMS,DMAP");
|
80
|
- ptService.add("OnlineResource", hrefUrl);
|
201
|
+ ptService.add("OnlineResource", "");
|
81
|
ptService.add("Fees","none");
|
202
|
ptService.add("Fees","none");
|
82
|
ptService.add("AccessConstraints","none");
|
203
|
ptService.add("AccessConstraints","none");
|
83
|
xmlRoot.add_child("Service",ptService);
|
204
|
xmlRoot.add_child("Service",ptService);
|
|
@@ -85,9 +206,14 @@ namespace DmpWms |
|
@@ -85,9 +206,14 @@ namespace DmpWms |
85
|
boost::property_tree::ptree ptCapability;
|
206
|
boost::property_tree::ptree ptCapability;
|
86
|
|
207
|
|
87
|
addCapabilitiesRequest(ptCapability,hrefUrl);
|
208
|
addCapabilitiesRequest(ptCapability,hrefUrl);
|
|
|
209
|
+ boost::property_tree::ptree ptexception;
|
88
|
boost::property_tree::ptree format;
|
210
|
boost::property_tree::ptree format;
|
89
|
- format.add("Format", "XML");
|
|
|
90
|
- ptCapability.add_child("Exception",format);
|
211
|
+
|
|
|
212
|
+ format.add( "XML","");
|
|
|
213
|
+ format.add( "WMS_XML","");
|
|
|
214
|
+ format.add( "INIMAGE","");
|
|
|
215
|
+ ptexception.add_child("Exception",format);
|
|
|
216
|
+ ptCapability.add_child("Format",ptexception);
|
91
|
addCapabilitiesLayers(ptCapability,project,name,title);
|
217
|
addCapabilitiesLayers(ptCapability,project,name,title);
|
92
|
|
218
|
|
93
|
xmlRoot.add_child("Capability",ptCapability);
|
219
|
xmlRoot.add_child("Capability",ptCapability);
|
|
@@ -123,6 +249,36 @@ namespace DmpWms |
|
@@ -123,6 +249,36 @@ namespace DmpWms |
123
|
|
249
|
|
124
|
}
|
250
|
}
|
125
|
|
251
|
|
|
|
252
|
+ void addCapabilitiesRequestNode2(boost::property_tree::ptree &pt, const std::string &hrefUrl, const char* request,const std::vector<const char*>& formatList)
|
|
|
253
|
+ {
|
|
|
254
|
+ boost::property_tree::ptree pt_request;
|
|
|
255
|
+ boost::property_tree::ptree pt_dcpType;
|
|
|
256
|
+ boost::property_tree::ptree pt_http;
|
|
|
257
|
+ boost::property_tree::ptree pt_method;
|
|
|
258
|
+ // boost::property_tree::ptree pt_onlineRes;
|
|
|
259
|
+
|
|
|
260
|
+ boost::property_tree::ptree pt_format;
|
|
|
261
|
+
|
|
|
262
|
+ for(int i =0; i< formatList.size(); i++)
|
|
|
263
|
+ {
|
|
|
264
|
+ const char* format = formatList.at(i);
|
|
|
265
|
+ pt_format.add(format,"");
|
|
|
266
|
+ }
|
|
|
267
|
+ pt_request.add_child("Format",pt_format);
|
|
|
268
|
+
|
|
|
269
|
+ // pt_onlineRes.add("<xmlattr>.xmlns:xlink","http://www.w3.org/1999/xlink");
|
|
|
270
|
+ // pt_onlineRes.add("<xmlattr>.xmlns:type","simple");
|
|
|
271
|
+ // pt_onlineRes.add("<xmlattr>.xmlns:href",hrefUrl);
|
|
|
272
|
+
|
|
|
273
|
+ pt_method.add("<xmlattr>.onlineResource",hrefUrl);
|
|
|
274
|
+
|
|
|
275
|
+ pt_http.add_child("Get",pt_method);
|
|
|
276
|
+ pt_dcpType.add_child("HTTP",pt_http);
|
|
|
277
|
+ pt_request.add_child("DCPType",pt_dcpType);
|
|
|
278
|
+ pt.add_child(request,pt_request);
|
|
|
279
|
+
|
|
|
280
|
+ }
|
|
|
281
|
+
|
126
|
|
282
|
|
127
|
void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl)
|
283
|
void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl)
|
128
|
{
|
284
|
{
|
|
@@ -143,6 +299,22 @@ namespace DmpWms |
|
@@ -143,6 +299,22 @@ namespace DmpWms |
143
|
formatList.push_back("text/json");
|
299
|
formatList.push_back("text/json");
|
144
|
formatList.push_back("text/xml");
|
300
|
formatList.push_back("text/xml");
|
145
|
addCapabilitiesRequestNode(pt_request,hrefUrl,"GetFeatureInfo",formatList);
|
301
|
addCapabilitiesRequestNode(pt_request,hrefUrl,"GetFeatureInfo",formatList);
|
|
|
302
|
+
|
|
|
303
|
+ formatList.clear();
|
|
|
304
|
+
|
|
|
305
|
+ formatList.push_back("PNG");
|
|
|
306
|
+ formatList.push_back("GIF");
|
|
|
307
|
+ formatList.push_back("JPG");
|
|
|
308
|
+ addCapabilitiesRequestNode2(pt_request,hrefUrl,"Map",formatList);
|
|
|
309
|
+
|
|
|
310
|
+ formatList.clear();
|
|
|
311
|
+ formatList.push_back("WMS_XML");
|
|
|
312
|
+ addCapabilitiesRequestNode2(pt_request,hrefUrl,"Capabilities",formatList);
|
|
|
313
|
+
|
|
|
314
|
+ formatList.clear();
|
|
|
315
|
+ formatList.push_back("XML");
|
|
|
316
|
+ formatList.push_back("MIME");
|
|
|
317
|
+ addCapabilitiesRequestNode2(pt_request,hrefUrl,"FeatureInfo",formatList);
|
146
|
|
318
|
|
147
|
pt.add_child("Request", pt_request);
|
319
|
pt.add_child("Request", pt_request);
|
148
|
return;
|
320
|
return;
|
|
@@ -195,12 +367,12 @@ namespace DmpWms |
|
@@ -195,12 +367,12 @@ namespace DmpWms |
195
|
ptProject.add("Title", title);
|
367
|
ptProject.add("Title", title);
|
196
|
ptProject.add("CRS", srs);
|
368
|
ptProject.add("CRS", srs);
|
197
|
|
369
|
|
198
|
- //boost::property_tree::ptree ptGeographicBoundingbox;
|
|
|
199
|
- //ptGeographicBoundingbox.add("westBoundLongitude", minx);
|
|
|
200
|
- //ptGeographicBoundingbox.add("eastBoundLongitude", maxx);
|
|
|
201
|
- //ptGeographicBoundingbox.add("southBoundLatitude", miny);
|
|
|
202
|
- //ptGeographicBoundingbox.add("northBoundLatitude", maxy);
|
|
|
203
|
- //ptProject.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox);
|
370
|
+ boost::property_tree::ptree ptGeographicBoundingbox;
|
|
|
371
|
+ ptGeographicBoundingbox.add("westBoundLongitude", minx);
|
|
|
372
|
+ ptGeographicBoundingbox.add("eastBoundLongitude", maxx);
|
|
|
373
|
+ ptGeographicBoundingbox.add("southBoundLatitude", miny);
|
|
|
374
|
+ ptGeographicBoundingbox.add("northBoundLatitude", maxy);
|
|
|
375
|
+ // ptProject.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox);
|
204
|
|
376
|
|
205
|
boost::property_tree::ptree ptBoundingbox;
|
377
|
boost::property_tree::ptree ptBoundingbox;
|
206
|
ptBoundingbox.add("<xmlattr>.CRS", srs);
|
378
|
ptBoundingbox.add("<xmlattr>.CRS", srs);
|
|
@@ -236,11 +408,11 @@ namespace DmpWms |
|
@@ -236,11 +408,11 @@ namespace DmpWms |
236
|
ptLayer.add("Title", layer->title().empty()? layer->name():layer->title());
|
408
|
ptLayer.add("Title", layer->title().empty()? layer->name():layer->title());
|
237
|
ptLayer.add("CRS", srs);
|
409
|
ptLayer.add("CRS", srs);
|
238
|
|
410
|
|
239
|
- //boost::property_tree::ptree ptGeographicBoundingbox;
|
|
|
240
|
- //ptGeographicBoundingbox.add("westBoundLongitude", layer->extent().xmin());
|
|
|
241
|
- //ptGeographicBoundingbox.add("eastBoundLongitude", layer->extent().xmax());
|
|
|
242
|
- //ptGeographicBoundingbox.add("southBoundLatitude", layer->extent().ymin());
|
|
|
243
|
- //ptGeographicBoundingbox.add("northBoundLatitude", layer->extent().ymax());
|
411
|
+ boost::property_tree::ptree ptGeographicBoundingbox;
|
|
|
412
|
+ ptGeographicBoundingbox.add("westBoundLongitude", layer->extent().xmin());
|
|
|
413
|
+ ptGeographicBoundingbox.add("eastBoundLongitude", layer->extent().xmax());
|
|
|
414
|
+ ptGeographicBoundingbox.add("southBoundLatitude", layer->extent().ymin());
|
|
|
415
|
+ ptGeographicBoundingbox.add("northBoundLatitude", layer->extent().ymax());
|
244
|
//ptLayer.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox);
|
416
|
//ptLayer.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox);
|
245
|
|
417
|
|
246
|
boost::property_tree::ptree ptBoundingbox;
|
418
|
boost::property_tree::ptree ptBoundingbox;
|