34 return QStringLiteral(
"1.1.0" );
49 static QSet<QString> sFilter
51 QStringLiteral(
"REQUEST" ),
52 QStringLiteral(
"VERSION" ),
53 QStringLiteral(
"SERVICE" ),
59 for (
auto param : q.queryItems() )
61 if ( sFilter.contains( param.first.toUpper() ) )
62 q.removeAllQueryItems( param.first );
68 return href.toString();
73 QString name = layer->
name();
76 name = name.replace(
' ',
'_' );
83 for (
const QString &layerId : layerIds )
106 QStringList collectedServerFids;
114 QDomNodeList fidNodes = filterElem.elementsByTagName( QStringLiteral(
"FeatureId" ) );
115 QDomNodeList goidNodes = filterElem.elementsByTagName( QStringLiteral(
"GmlObjectId" ) );
116 if ( !fidNodes.isEmpty() )
119 QStringList collectedServerFids;
121 for (
int f = 0; f < fidNodes.size(); f++ )
123 fidElem = fidNodes.at( f ).toElement();
124 if ( !fidElem.hasAttribute( QStringLiteral(
"fid" ) ) )
129 QString serverFid = fidElem.attribute( QStringLiteral(
"fid" ) );
130 if ( serverFid.contains( QLatin1String(
"." ) ) )
132 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
134 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
136 collectedServerFids << serverFid;
139 if ( collectedServerFids.isEmpty() )
144 serverFids.append( collectedServerFids );
148 else if ( !goidNodes.isEmpty() )
151 QStringList collectedServerFids;
152 QDomElement goidElem;
153 for (
int f = 0; f < goidNodes.size(); f++ )
155 goidElem = goidNodes.at( f ).toElement();
156 if ( !goidElem.hasAttribute( QStringLiteral(
"id" ) ) && !goidElem.hasAttribute( QStringLiteral(
"gml:id" ) ) )
161 QString serverFid = goidElem.attribute( QStringLiteral(
"id" ) );
162 if ( serverFid.isEmpty() )
163 serverFid = goidElem.attribute( QStringLiteral(
"gml:id" ) );
164 if ( serverFid.contains( QLatin1String(
"." ) ) )
166 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
168 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
170 collectedServerFids << serverFid;
173 if ( collectedServerFids.isEmpty() )
178 serverFids.append( collectedServerFids );
182 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"BBOX" ) )
184 QDomElement bboxElem = filterElem.firstChildElement();
185 QDomElement childElem = bboxElem.firstChildElement();
187 while ( !childElem.isNull() )
189 if ( childElem.tagName() == QLatin1String(
"Box" ) )
193 else if ( childElem.tagName() != QLatin1String(
"PropertyName" ) )
198 childElem = childElem.nextSiblingElement();
205 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"And" ) &&
206 !filterElem.firstChildElement().firstChildElement( QLatin1String(
"BBOX" ) ).isNull() )
208 int nbChildElem = filterElem.firstChildElement().childNodes().size();
211 QDomElement childFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
212 if ( nbChildElem > 2 )
214 QDomElement childAndElement = filterElem.ownerDocument().createElement( QLatin1String(
"And" ) );
215 childFilterElement.appendChild( childAndElement );
219 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
221 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
222 while ( !childElem.isNull() )
225 if ( childElem.tagName() == QLatin1String(
"BBOX" ) )
228 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
233 if ( nbChildElem > 2 )
235 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
239 childFilterElement.appendChild( childElem.cloneNode(
true ) );
242 childElem = childElem.nextSiblingElement();
246 QStringList collectedServerFids;
263 if ( !collectedServerFids.isEmpty() )
265 serverFids.append( collectedServerFids );
277 if ( project !=
nullptr )
284 if ( filter->hasParserError() )
289 if ( filter->needsGeometry() )
Base class for all map layer types.
QgsMapLayerType type() const
Returns the type of the layer.
Use exact geometry intersection (slower) instead of bounding boxes.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QgsVectorLayer * layerByTypeName(const QgsProject *project, const QString &typeName)
Retrieve a layer by typename.
A geometry is the spatial representation of a feature.
QUrl originalUrl() const
Returns the request url as seen by the web server, by default this is equal to the url seen by QGIS s...
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
static QgsRectangle rectangleFromGMLBox(const QDomNode &boxNode)
Read rectangle from GML2 Box.
QgsExpression * filterExpression() const
Returns the filter expression if set.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Service URL string.
bool isEmpty() const
Returns true if the rectangle is empty.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsFeatureRequest parseFilterElement(const QString &typeName, QDomElement &filterElem, const QgsProject *project)
Transform a Filter element to a feature request.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
QString implementationVersion()
Returns the highest version supported by this implementation.
QString expression() const
Returns the original, unmodified expression string.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
static QgsGeometry geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
Represents a vector layer which manages a vector based data sets.
SERVER_EXPORT QString wfsServiceUrl(const QgsProject &project)
Returns the WFS service url defined in a QGIS project.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.