32using namespace Qt::StringLiterals;
49 static QSet<QString> sFilter {
58 const auto constQueryItems = q.queryItems();
59 for (
const auto ¶m : constQueryItems )
61 if ( sFilter.contains( param.first.toUpper() ) )
62 q.removeAllQueryItems( param.first );
68 return href.toString();
74 for (
const QString &layerId : std::as_const( layerIds ) )
88 return qobject_cast<QgsVectorLayer *>( layer );
97 QStringList collectedServerFids;
105 QDomNodeList fidNodes = filterElem.elementsByTagName( u
"FeatureId"_s );
106 QDomNodeList goidNodes = filterElem.elementsByTagName( u
"GmlObjectId"_s );
107 if ( !fidNodes.isEmpty() )
110 QStringList collectedServerFids;
112 for (
int f = 0; f < fidNodes.size(); f++ )
114 fidElem = fidNodes.at( f ).toElement();
115 if ( !fidElem.hasAttribute( u
"fid"_s ) )
120 QString serverFid = fidElem.attribute( u
"fid"_s );
121 if ( serverFid.contains(
"."_L1 ) )
123 if ( serverFid.section( u
"."_s, 0, 0 ) != typeName )
125 serverFid = serverFid.section( u
"."_s, 1, 1 );
127 collectedServerFids << serverFid;
130 if ( collectedServerFids.isEmpty() )
135 serverFids.append( collectedServerFids );
139 else if ( !goidNodes.isEmpty() )
142 QStringList collectedServerFids;
143 QDomElement goidElem;
144 for (
int f = 0; f < goidNodes.size(); f++ )
146 goidElem = goidNodes.at( f ).toElement();
147 if ( !goidElem.hasAttribute( u
"id"_s ) && !goidElem.hasAttribute( u
"gml:id"_s ) )
152 QString serverFid = goidElem.attribute( u
"id"_s );
153 if ( serverFid.isEmpty() )
154 serverFid = goidElem.attribute( u
"gml:id"_s );
155 if ( serverFid.contains(
"."_L1 ) )
157 if ( serverFid.section( u
"."_s, 0, 0 ) != typeName )
159 serverFid = serverFid.section( u
"."_s, 1, 1 );
161 collectedServerFids << serverFid;
164 if ( collectedServerFids.isEmpty() )
169 serverFids.append( collectedServerFids );
173 else if ( filterElem.firstChildElement().tagName() ==
"BBOX"_L1 )
175 QDomElement bboxElem = filterElem.firstChildElement();
176 QDomElement childElem = bboxElem.firstChildElement();
178 while ( !childElem.isNull() )
180 if ( childElem.tagName() ==
"Box"_L1 )
184 else if ( childElem.tagName() !=
"PropertyName"_L1 )
190 childElem = childElem.nextSiblingElement();
197 else if ( filterElem.firstChildElement().tagName() ==
"And"_L1 && !filterElem.firstChildElement().firstChildElement(
"BBOX"_L1 ).isNull() )
199 int nbChildElem = filterElem.firstChildElement().childNodes().size();
202 QDomElement childFilterElement = filterElem.ownerDocument().createElement(
"Filter"_L1 );
203 if ( nbChildElem > 2 )
205 QDomElement childAndElement = filterElem.ownerDocument().createElement(
"And"_L1 );
206 childFilterElement.appendChild( childAndElement );
210 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement(
"Filter"_L1 );
212 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
213 while ( !childElem.isNull() )
216 if ( childElem.tagName() ==
"BBOX"_L1 )
219 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
224 if ( nbChildElem > 2 )
226 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
230 childFilterElement.appendChild( childElem.cloneNode(
true ) );
233 childElem = childElem.nextSiblingElement();
237 QStringList collectedServerFids;
254 if ( !collectedServerFids.isEmpty() )
256 serverFids.append( collectedServerFids );
275 if ( filter->hasParserError() || !filter->parserErrorString().isEmpty() )
280 if ( filter->needsGeometry() )
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
@ NoFlags
No flags are set.
Contains information about the context in which a coordinate transform is executed.
QString expression() const
Returns the original, unmodified expression string.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
QgsExpression * filterExpression() const
Returns the filter expression (if set).
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
A geometry is the spatial representation of a feature.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QString wfsTypeName() const
Returns WFS typename for the layer.
Base class for all map layer types.
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
static QgsRectangle rectangleFromGMLBox(const QDomNode &boxNode)
Read rectangle from GML2 Box.
static QgsGeometry geometryFromGML(const QString &xmlString, const QgsOgcUtils::Context &context=QgsOgcUtils::Context())
Static method that creates geometry from GML.
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsCoordinateTransformContext transformContext
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
static QString wfsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WFS service url.
Defines requests passed to QgsService classes.
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...
Provides a way to retrieve settings by prioritizing according to environment variables,...
Represents a vector layer which manages a vector based dataset.
QString implementationVersion()
Returns the highest version supported by this implementation.
QgsVectorLayer * layerByTypeName(const QgsProject *project, const QString &typeName)
Retrieve a layer by typename.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Service URL string.
QgsFeatureRequest parseFilterElement(const QString &typeName, QDomElement &filterElem, QgsProject *project)
Transform a Filter element to a feature request.
The Context struct stores the current layer and coordinate transform context.