42 #ifdef HAVE_SERVER_PYTHON_PLUGINS
46 const QDomDocument *capabilitiesDocument =
nullptr;
48 #ifdef HAVE_SERVER_PYTHON_PLUGINS
50 if ( cacheManager && cacheManager->
getCachedDocument( &doc, project, request, accessControl ) )
52 capabilitiesDocument = &doc;
62 capabilitiesDocument = &doc;
66 capabilitiesDocument = &doc;
68 response.
setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/xml; charset=utf-8" ) );
69 response.
write( capabilitiesDocument->toByteArray() );
81 QDomElement wfsCapabilitiesElement = doc.createElement( QStringLiteral(
"WFS_Capabilities" ) );
82 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
83 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
84 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd" );
85 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
86 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:gml" ),
GML_NAMESPACE );
87 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
88 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
89 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
90 wfsCapabilitiesElement.setAttribute( QStringLiteral(
"updateSequence" ), QStringLiteral(
"0" ) );
91 doc.appendChild( wfsCapabilitiesElement );
106 QDomElement filterCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Filter_Capabilities" ) );
107 wfsCapabilitiesElement.appendChild( filterCapabilitiesElement );
108 QDomElement spatialCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Capabilities" ) );
109 filterCapabilitiesElement.appendChild( spatialCapabilitiesElement );
110 QDomElement spatialOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Spatial_Operators" ) );
111 spatialCapabilitiesElement.appendChild( spatialOperatorsElement );
112 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:BBOX" ) ) );
113 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Disjoint" ) ) );
114 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Intersect" ) ) );
115 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Touches" ) ) );
116 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Crosses" ) ) );
117 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Contains" ) ) );
118 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Overlaps" ) ) );
119 spatialOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Within" ) ) );
120 QDomElement scalarCapabilitiesElement = doc.createElement( QStringLiteral(
"ogc:Scalar_Capabilities" ) );
121 filterCapabilitiesElement.appendChild( scalarCapabilitiesElement );
122 QDomElement comparisonOperatorsElement = doc.createElement( QStringLiteral(
"ogc:Comparison_Operators" ) );
123 scalarCapabilitiesElement.appendChild( comparisonOperatorsElement );
124 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Simple_Comparisons" ) ) );
125 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Between" ) ) );
126 comparisonOperatorsElement.appendChild( doc.createElement( QStringLiteral(
"ogc:Like" ) ) );
135 QDomElement serviceElem = doc.createElement( QStringLiteral(
"Service" ) );
138 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
139 const QDomText nameText = doc.createTextNode(
"WFS" );
140 nameElem.appendChild( nameText );
141 serviceElem.appendChild( nameElem );
144 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
145 const QDomText titleText = doc.createTextNode( title );
146 titleElem.appendChild( titleText );
147 serviceElem.appendChild( titleElem );
150 if ( !
abstract.isEmpty() )
152 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
153 const QDomText abstractText = doc.createCDATASection(
abstract );
154 abstractElem.appendChild( abstractText );
155 serviceElem.appendChild( abstractElem );
159 if ( !keywords.isEmpty() && !keywords.join( QLatin1String(
", " ) ).isEmpty() )
161 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
162 const QDomText keywordsText = doc.createTextNode( keywords.join( QLatin1String(
", " ) ) );
163 keywordsElem.appendChild( keywordsText );
164 serviceElem.appendChild( keywordsElem );
167 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"OnlineResource" ) );
169 if ( !onlineResource.isEmpty() )
171 const QDomText onlineResourceText = doc.createTextNode( onlineResource );
172 onlineResourceElem.appendChild( onlineResourceText );
174 serviceElem.appendChild( onlineResourceElem );
177 if ( !fees.isEmpty() )
179 QDomElement feesElem = doc.createElement( QStringLiteral(
"Fees" ) );
180 const QDomText feesText = doc.createTextNode( fees );
181 feesElem.appendChild( feesText );
182 serviceElem.appendChild( feesElem );
186 if ( !accessConstraints.isEmpty() )
188 QDomElement accessConstraintsElem = doc.createElement( QStringLiteral(
"AccessConstraints" ) );
189 const QDomText accessConstraintsText = doc.createTextNode( accessConstraints );
190 accessConstraintsElem.appendChild( accessConstraintsText );
191 serviceElem.appendChild( accessConstraintsElem );
201 QDomElement capabilityElement = doc.createElement( QStringLiteral(
"Capability" ) );
204 QDomElement requestElement = doc.createElement( QStringLiteral(
"Request" ) );
205 capabilityElement.appendChild( requestElement );
207 QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral(
"GetCapabilities" ) );
208 requestElement.appendChild( getCapabilitiesElement );
210 QDomElement dcpTypeElement = doc.createElement( QStringLiteral(
"DCPType" ) );
211 getCapabilitiesElement.appendChild( dcpTypeElement );
212 QDomElement httpElement = doc.createElement( QStringLiteral(
"HTTP" ) );
213 dcpTypeElement.appendChild( httpElement );
216 const QString hrefString =
serviceUrl( request, project, *settings );
219 QDomElement getElement = doc.createElement( QStringLiteral(
"Get" ) );
220 httpElement.appendChild( getElement );
221 getElement.setAttribute( QStringLiteral(
"onlineResource" ), hrefString );
222 const QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
223 getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
224 getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );
227 QDomElement describeFeatureTypeElement = doc.createElement( QStringLiteral(
"DescribeFeatureType" ) );
228 requestElement.appendChild( describeFeatureTypeElement );
229 QDomElement schemaDescriptionLanguageElement = doc.createElement( QStringLiteral(
"SchemaDescriptionLanguage" ) );
230 describeFeatureTypeElement.appendChild( schemaDescriptionLanguageElement );
231 const QDomElement xmlSchemaElement = doc.createElement( QStringLiteral(
"XMLSCHEMA" ) );
232 schemaDescriptionLanguageElement.appendChild( xmlSchemaElement );
233 const QDomElement describeFeatureTypeDhcTypeElement = dcpTypeElement.cloneNode().toElement();
234 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypeElement );
235 const QDomElement describeFeatureTypeDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
236 describeFeatureTypeDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
237 describeFeatureTypeElement.appendChild( describeFeatureTypeDhcTypePostElement );
240 QDomElement getFeatureElement = doc.createElement( QStringLiteral(
"GetFeature" ) );
241 requestElement.appendChild( getFeatureElement );
242 QDomElement getFeatureFormatElement = doc.createElement( QStringLiteral(
"ResultFormat" ) );
243 getFeatureElement.appendChild( getFeatureFormatElement );
244 const QDomElement gmlFormatElement = doc.createElement( QStringLiteral(
"GML2" ) );
245 getFeatureFormatElement.appendChild( gmlFormatElement );
246 const QDomElement gml3FormatElement = doc.createElement( QStringLiteral(
"GML3" ) );
247 getFeatureFormatElement.appendChild( gml3FormatElement );
248 const QDomElement geojsonFormatElement = doc.createElement( QStringLiteral(
"GeoJSON" ) );
249 getFeatureFormatElement.appendChild( geojsonFormatElement );
250 const QDomElement getFeatureDhcTypeGetElement = dcpTypeElement.cloneNode().toElement();
251 getFeatureElement.appendChild( getFeatureDhcTypeGetElement );
252 const QDomElement getFeatureDhcTypePostElement = dcpTypeElement.cloneNode().toElement();
253 getFeatureDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
254 getFeatureElement.appendChild( getFeatureDhcTypePostElement );
257 QDomElement transactionElement = doc.createElement( QStringLiteral(
"Transaction" ) );
258 requestElement.appendChild( transactionElement );
259 const QDomElement transactionDhcTypeElement = dcpTypeElement.cloneNode().toElement();
260 transactionDhcTypeElement.firstChild().firstChild().toElement().setTagName( QStringLiteral(
"Post" ) );
261 transactionElement.appendChild( transactionDhcTypeElement );
263 return capabilityElement;
268 #ifdef HAVE_SERVER_PYTHON_PLUGINS
275 QDomElement featureTypeListElement = doc.createElement( QStringLiteral(
"FeatureTypeList" ) );
277 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
278 featureTypeListElement.appendChild( operationsElement );
280 const QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
281 operationsElement.appendChild( queryElement );
298 #ifdef HAVE_SERVER_PYTHON_PLUGINS
304 QDomElement layerElem = doc.createElement( QStringLiteral(
"FeatureType" ) );
307 QDomElement nameElem = doc.createElement( QStringLiteral(
"Name" ) );
312 const QDomText nameText = doc.createTextNode(
typeName );
313 nameElem.appendChild( nameText );
314 layerElem.appendChild( nameElem );
317 QDomElement titleElem = doc.createElement( QStringLiteral(
"Title" ) );
318 QString title = layer->
title();
319 if ( title.isEmpty() )
321 title = layer->
name();
323 const QDomText titleText = doc.createTextNode( title );
324 titleElem.appendChild( titleText );
325 layerElem.appendChild( titleElem );
328 const QString
abstract = layer->
abstract();
329 if ( !
abstract.isEmpty() )
331 QDomElement abstractElem = doc.createElement( QStringLiteral(
"Abstract" ) );
332 const QDomText abstractText = doc.createTextNode(
abstract );
333 abstractElem.appendChild( abstractText );
334 layerElem.appendChild( abstractElem );
339 if ( !keywords.isEmpty() )
341 QDomElement keywordsElem = doc.createElement( QStringLiteral(
"Keywords" ) );
342 const QDomText keywordsText = doc.createTextNode( keywords );
343 keywordsElem.appendChild( keywordsText );
344 layerElem.appendChild( keywordsElem );
348 QDomElement srsElem = doc.createElement( QStringLiteral(
"SRS" ) );
349 const QDomText srsText = doc.createTextNode( layer->
crs().
authid() );
350 srsElem.appendChild( srsText );
351 layerElem.appendChild( srsElem );
362 QDomElement bBoxElement = doc.createElement( QStringLiteral(
"LatLongBoundingBox" ) );
367 layerElem.appendChild( bBoxElement );
373 QDomElement metaUrlElem = doc.createElement( QStringLiteral(
"MetadataURL" ) );
374 const QString metadataUrlType = url.type;
375 metaUrlElem.setAttribute( QStringLiteral(
"type" ), metadataUrlType );
376 const QString metadataUrlFormat = url.format;
377 if ( metadataUrlFormat == QLatin1String(
"text/xml" ) )
379 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"XML" ) );
383 metaUrlElem.setAttribute( QStringLiteral(
"format" ), QStringLiteral(
"TXT" ) );
385 const QDomText metaUrlText = doc.createTextNode( url.url );
386 metaUrlElem.appendChild( metaUrlText );
387 layerElem.appendChild( metaUrlElem );
391 QDomElement operationsElement = doc.createElement( QStringLiteral(
"Operations" ) );
393 const QDomElement queryElement = doc.createElement( QStringLiteral(
"Query" ) );
394 operationsElement.appendChild( queryElement );
395 if ( wfstUpdateLayersId.contains( layer->
id() ) ||
396 wfstInsertLayersId.contains( layer->
id() ) ||
397 wfstDeleteLayersId.contains( layer->
id() ) )
404 const QDomElement insertElement = doc.createElement( QStringLiteral(
"Insert" ) );
405 operationsElement.appendChild( insertElement );
409 wfstUpdateLayersId.contains( layer->
id() ) )
412 const QDomElement updateElement = doc.createElement( QStringLiteral(
"Update" ) );
413 operationsElement.appendChild( updateElement );
418 const QDomElement deleteElement = doc.createElement( QStringLiteral(
"Delete" ) );
419 operationsElement.appendChild( deleteElement );
423 layerElem.appendChild( operationsElement );
425 featureTypeListElement.appendChild( layerElem );
428 return featureTypeListElement;