35 return QStringLiteral(
"1.1.0" );
50 static QSet<QString> sFilter
52 QStringLiteral(
"REQUEST" ),
53 QStringLiteral(
"VERSION" ),
54 QStringLiteral(
"SERVICE" ),
60 for (
auto param : q.queryItems() )
62 if ( sFilter.contains( param.first.toUpper() ) )
63 q.removeAllQueryItems( param.first );
69 return href.toString();
74 QString name = layer->
name();
77 name = name.replace(
' ',
'_' );
84 for (
const QString &layerId : layerIds )
91 if ( layer->
type() != QgsMapLayer::LayerType::VectorLayer )
107 QStringList collectedServerFids;
115 QDomNodeList fidNodes = filterElem.elementsByTagName( QStringLiteral(
"FeatureId" ) );
116 QDomNodeList goidNodes = filterElem.elementsByTagName( QStringLiteral(
"GmlObjectId" ) );
117 if ( !fidNodes.isEmpty() )
120 QStringList collectedServerFids;
122 for (
int f = 0; f < fidNodes.size(); f++ )
124 fidElem = fidNodes.at( f ).toElement();
125 if ( !fidElem.hasAttribute( QStringLiteral(
"fid" ) ) )
130 QString serverFid = fidElem.attribute( QStringLiteral(
"fid" ) );
131 if ( serverFid.contains( QLatin1String(
"." ) ) )
133 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
135 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
137 collectedServerFids << serverFid;
140 if ( collectedServerFids.isEmpty() )
145 serverFids.append( collectedServerFids );
149 else if ( !goidNodes.isEmpty() )
152 QStringList collectedServerFids;
153 QDomElement goidElem;
154 for (
int f = 0; f < goidNodes.size(); f++ )
156 goidElem = goidNodes.at( f ).toElement();
157 if ( !goidElem.hasAttribute( QStringLiteral(
"id" ) ) && !goidElem.hasAttribute( QStringLiteral(
"gml:id" ) ) )
162 QString serverFid = goidElem.attribute( QStringLiteral(
"id" ) );
163 if ( serverFid.isEmpty() )
164 serverFid = goidElem.attribute( QStringLiteral(
"gml:id" ) );
165 if ( serverFid.contains( QLatin1String(
"." ) ) )
167 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
169 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
171 collectedServerFids << serverFid;
174 if ( collectedServerFids.isEmpty() )
179 serverFids.append( collectedServerFids );
183 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"BBOX" ) )
185 QDomElement bboxElem = filterElem.firstChildElement();
186 QDomElement childElem = bboxElem.firstChildElement();
188 while ( !childElem.isNull() )
190 if ( childElem.tagName() == QLatin1String(
"Box" ) )
194 else if ( childElem.tagName() != QLatin1String(
"PropertyName" ) )
199 childElem = childElem.nextSiblingElement();
206 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"And" ) &&
207 !filterElem.firstChildElement().firstChildElement( QLatin1String(
"BBOX" ) ).isNull() )
209 int nbChildElem = filterElem.firstChildElement().childNodes().size();
212 QDomElement childFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
213 if ( nbChildElem > 2 )
215 QDomElement childAndElement = filterElem.ownerDocument().createElement( QLatin1String(
"And" ) );
216 childFilterElement.appendChild( childAndElement );
220 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
222 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
223 while ( !childElem.isNull() )
226 if ( childElem.tagName() == QLatin1String(
"BBOX" ) )
229 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
234 if ( nbChildElem > 2 )
236 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
240 childFilterElement.appendChild( childElem.cloneNode(
true ) );
243 childElem = childElem.nextSiblingElement();
247 QStringList collectedServerFids;
264 if ( !collectedServerFids.isEmpty() )
266 serverFids.append( collectedServerFids );
278 if ( project !=
nullptr )
285 if ( filter->hasParserError() )
290 if ( filter->needsGeometry() )
Base class for all map layer types.
bool isEmpty() const
Returns true if the rectangle is empty.
QgsMapLayer::LayerType type() const
Returns the type of the layer.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
Use exact geometry intersection (slower) instead of bounding boxes.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
QgsVectorLayer * layerByTypeName(const QgsProject *project, const QString &typeName)
Retrieve a layer by typename.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
A geometry is the spatial representation of a feature.
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
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...
static QgsRectangle rectangleFromGMLBox(const QDomNode &boxNode)
Read rectangle from GML2 Box.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QString serviceUrl(const QgsServerRequest &request, const QgsProject *project)
Service URL string.
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.
Reads and writes project states.
QString implementationVersion()
Returns the highest version supported by this implementation.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
static QgsGeometry geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
QString expression() const
Returns the original, unmodified expression string.
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.
QgsExpression * filterExpression() const
Returns the filter expression if set.