@@ -69,6 +69,16 @@ QgsWMSServer::QgsWMSServer()
69
69
{
70
70
}
71
71
72
+ void QgsWMSServer::appendFormats ( QDomDocument &doc, QDomElement &elem, const QStringList &formats )
73
+ {
74
+ foreach ( QString format, formats )
75
+ {
76
+ QDomElement formatElem = doc.createElement ( " Format" /* wms:Format*/ );
77
+ formatElem.appendChild ( doc.createTextNode ( format ) );
78
+ elem.appendChild ( formatElem );
79
+ }
80
+ }
81
+
72
82
QDomDocument QgsWMSServer::getCapabilities ( QString version )
73
83
{
74
84
QgsDebugMsg ( " Entering." );
@@ -101,25 +111,25 @@ QDomDocument QgsWMSServer::getCapabilities( QString version )
101
111
// wms:Request element
102
112
QDomElement requestElement = doc.createElement ( " Request" /* wms:Request*/ );
103
113
capabilityElement.appendChild ( requestElement );
104
- // wms:GetCapabilities
105
- QDomElement getCapabilitiesElement = doc.createElement ( " GetCapabilities" /* wms:GetCapabilities*/ );
106
- requestElement.appendChild ( getCapabilitiesElement );
107
- QDomElement capabilitiesFormatElement = doc.createElement ( " Format" );/* wms:Format*/
108
- getCapabilitiesElement.appendChild ( capabilitiesFormatElement );
109
- QDomText capabilitiesFormatText = doc.createTextNode ( version == " 1.1.1" ? " application/vnd.ogc.se_xml" : " text/xml" );
110
- capabilitiesFormatElement.appendChild ( capabilitiesFormatText );
111
114
112
115
QDomElement dcpTypeElement = doc.createElement ( " DCPType" /* wms:DCPType*/ );
113
- getCapabilitiesElement.appendChild ( dcpTypeElement );
114
116
QDomElement httpElement = doc.createElement ( " HTTP" /* wms:HTTP*/ );
115
117
dcpTypeElement.appendChild ( httpElement );
116
118
119
+ QDomElement elem;
120
+
121
+ // wms:GetCapabilities
122
+ elem = doc.createElement ( " GetCapabilities" /* wms:GetCapabilities*/ );
123
+ appendFormats ( doc, elem, QStringList () << ( version == " 1.1.1" ? " application/vnd.ogc.wms_xml" : " text/xml" ) );
124
+ elem.appendChild ( dcpTypeElement );
125
+ requestElement.appendChild ( elem );
126
+
117
127
// Prepare url
118
128
// Some client requests already have http://<SERVER_NAME> in the REQUEST_URI variable
119
129
QString hrefString;
120
130
QString requestUrl = getenv ( " REQUEST_URI" );
121
131
QUrl mapUrl ( requestUrl );
122
- mapUrl.setHost ( QString ( getenv ( " SERVER_NAME" ) ) );
132
+ mapUrl.setHost ( getenv ( " SERVER_NAME" ) );
123
133
124
134
// Add non-default ports to url
125
135
QString portString = getenv ( " SERVER_PORT" );
@@ -193,60 +203,52 @@ QDomDocument QgsWMSServer::getCapabilities( QString version )
193
203
olResourceElement.setAttribute ( " xlink:href" , hrefString );
194
204
getElement.appendChild ( olResourceElement );
195
205
206
+ #if 0
196
207
// POST already used by SOAP
197
- // QDomElement postElement = doc.createElement("post"/*wms:SOAP*/);
198
- // httpElement.appendChild(postElement);
199
- // QDomElement postResourceElement = doc.createElement("OnlineResource"/*wms:OnlineResource*/);
200
- // postResourceElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");
201
- // postResourceElement.setAttribute("xlink:type","simple");
202
- // postResourceElement.setAttribute("xlink:href", "http://" + QString(getenv("SERVER_NAME")) + QString(getenv("REQUEST_URI")));
203
- // postElement.appendChild(postResourceElement);
204
- // dcpTypeElement.appendChild(postElement);
208
+ QDomElement postElement = doc.createElement( "post"/*wms:SOAP*/ );
209
+ httpElement.appendChild( postElement );
210
+ QDomElement postResourceElement = doc.createElement( "OnlineResource"/*wms:OnlineResource*/ );
211
+ postResourceElement.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
212
+ postResourceElement.setAttribute( "xlink:type", "simple" );
213
+ postResourceElement.setAttribute( "xlink:href", "http://" + QString( getenv( "SERVER_NAME" ) ) + QString( getenv( "REQUEST_URI" ) ) );
214
+ postElement.appendChild( postResourceElement );
215
+ dcpTypeElement.appendChild( postElement );
216
+ #endif
205
217
206
218
// wms:GetMap
207
- QDomElement getMapElement = doc.createElement ( " GetMap" /* wms:GetMap*/ );
208
- requestElement.appendChild ( getMapElement );
209
- QDomElement jpgFormatElement = doc.createElement ( " Format" /* wms:Format*/ );
210
- QDomText jpgFormatText = doc.createTextNode ( " image/jpeg" );
211
- jpgFormatElement.appendChild ( jpgFormatText );
212
- getMapElement.appendChild ( jpgFormatElement );
213
- QDomElement pngFormatElement = doc.createElement ( " Format" /* wms:Format*/ );
214
- QDomText pngFormatText = doc.createTextNode ( " image/png" );
215
- pngFormatElement.appendChild ( pngFormatText );
216
- getMapElement.appendChild ( pngFormatElement );
217
- QDomElement getMapDhcTypeElement = dcpTypeElement.cloneNode ().toElement ();// this is the same as for 'GetCapabilities'
218
- getMapElement.appendChild ( getMapDhcTypeElement );
219
+ elem = doc.createElement ( " GetMap" /* wms:GetMap*/ );
220
+ appendFormats ( doc, elem, QStringList () << " image/jpeg" << " image/png" );
221
+ elem.appendChild ( dcpTypeElement.cloneNode ().toElement () ); // this is the same as for 'GetCapabilities'
222
+ requestElement.appendChild ( elem );
219
223
220
224
// wms:GetFeatureInfo
221
- QDomElement getFeatureInfoElem = doc.createElement ( " GetFeatureInfo" );
222
- // text/plain
223
- QDomElement textFormatElem = doc.createElement ( " Format" );
224
- QDomText textFormatText = doc.createTextNode ( " text/plain" );
225
- textFormatElem.appendChild ( textFormatText );
226
- getFeatureInfoElem.appendChild ( textFormatElem );
227
- // text/html
228
- QDomElement htmlFormatElem = doc.createElement ( " Format" );
229
- QDomText htmlFormatText = doc.createTextNode ( " text/html" );
230
- htmlFormatElem.appendChild ( htmlFormatText );
231
- getFeatureInfoElem.appendChild ( htmlFormatElem );
232
- // text/xml
233
- QDomElement xmlFormatElem = doc.createElement ( " Format" );
234
- QDomText xmlFormatText = doc.createTextNode ( version == " 1.1.1" ? " application/vnd.ogc.se_xml" : " text/xml" );
235
- xmlFormatElem.appendChild ( xmlFormatText );
236
- getFeatureInfoElem.appendChild ( xmlFormatElem );
237
-
238
- // dcpType
239
- QDomElement getFeatureInfoDhcTypeElement = dcpTypeElement.cloneNode ().toElement ();// this is the same as for 'GetCapabilities'
240
- getFeatureInfoElem.appendChild ( getFeatureInfoDhcTypeElement );
241
- requestElement.appendChild ( getFeatureInfoElem );
225
+ elem = doc.createElement ( " GetFeatureInfo" );
226
+ appendFormats ( doc, elem, QStringList () << " text/plain" << " text/html" << " text/xml" );
227
+ elem.appendChild ( dcpTypeElement.cloneNode ().toElement () ); // this is the same as for 'GetCapabilities'
228
+ requestElement.appendChild ( elem );
229
+
230
+ // wms:GetLegendGraphic
231
+ elem = doc.createElement ( " GetLegendGraphic" /* wms:GetLegendGraphic*/ );
232
+ appendFormats ( doc, elem, QStringList () << " jpeg" << " image/jpeg" << " image/png" );
233
+ elem.appendChild ( dcpTypeElement.cloneNode ().toElement () ); // this is the same as for 'GetCapabilities'
234
+ requestElement.appendChild ( elem );
235
+
236
+ // wms:GetStyles
237
+ elem = doc.createElement ( " GetStyles" /* wms:GetStyles*/ );
238
+ appendFormats ( doc, elem, QStringList () << " text/xml" );
239
+ elem.appendChild ( dcpTypeElement.cloneNode ().toElement () ); // this is the same as for 'GetCapabilities'
240
+ requestElement.appendChild ( elem );
241
+
242
+ // wms:GetPrint
243
+ elem = doc.createElement ( " GetPrint" /* wms:GetPrint*/ );
244
+ appendFormats ( doc, elem, QStringList () << " svg" << " png" << " pdf" );
245
+ elem.appendChild ( dcpTypeElement.cloneNode ().toElement () ); // this is the same as for 'GetCapabilities'
246
+ requestElement.appendChild ( elem );
242
247
243
248
// Exception element is mandatory
244
- QDomElement exceptionElement = doc.createElement ( " Exception" );
245
- QDomElement exFormatElement = doc.createElement ( " Format" );
246
- QDomText formatText = doc.createTextNode ( version == " 1.1.1" ? " application/vnd.ogc.se_xml" : " text/xml" );
247
- exFormatElement.appendChild ( formatText );
248
- exceptionElement.appendChild ( exFormatElement );
249
- capabilityElement.appendChild ( exceptionElement );
249
+ elem = doc.createElement ( " Exception" );
250
+ appendFormats ( doc, elem, QStringList () << ( version == " 1.1.1" ? " application/vnd.ogc.se_xml" : " text/xml" ) );
251
+ capabilityElement.appendChild ( elem );
250
252
251
253
// Insert <ComposerTemplate> elements derived from wms:_ExtendedCapabilities
252
254
if ( mConfigParser )
@@ -271,6 +273,7 @@ QDomDocument QgsWMSServer::getCapabilities( QString version )
271
273
doc.save( capabilitiesStream, 4 );
272
274
}
273
275
#endif
276
+
274
277
return doc;
275
278
}
276
279
@@ -832,7 +835,7 @@ QImage* QgsWMSServer::initializeRendering( QStringList& layersList, QStringList&
832
835
}
833
836
// pass external GML to the SLD parser.
834
837
QString gml = mParameterMap .value ( " GML" );
835
- if ( !gml.isEmpty () )
838
+ if ( !gml.isEmpty () )
836
839
{
837
840
QDomDocument* gmlDoc = new QDomDocument ();
838
841
if ( gmlDoc->setContent ( gml, true ) )
0 commit comments