34 return QStringLiteral(
"1.1.0" );
49 static QSet<QString> sFilter
51 QStringLiteral(
"REQUEST" ),
52 QStringLiteral(
"VERSION" ),
53 QStringLiteral(
"SERVICE" ),
59 const auto constQueryItems = q.queryItems();
60 for (
const auto ¶m : constQueryItems )
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(
' ',
'_' ).replace(
':',
'-' );
84 for (
const QString &layerId : qgis::as_const( layerIds ) )
98 return qobject_cast<QgsVectorLayer *>( layer );
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" ) )
200 childElem = childElem.nextSiblingElement();
207 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"And" ) &&
208 !filterElem.firstChildElement().firstChildElement( QLatin1String(
"BBOX" ) ).isNull() )
210 int nbChildElem = filterElem.firstChildElement().childNodes().size();
213 QDomElement childFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
214 if ( nbChildElem > 2 )
216 QDomElement childAndElement = filterElem.ownerDocument().createElement( QLatin1String(
"And" ) );
217 childFilterElement.appendChild( childAndElement );
221 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
223 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
224 while ( !childElem.isNull() )
227 if ( childElem.tagName() == QLatin1String(
"BBOX" ) )
230 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
235 if ( nbChildElem > 2 )
237 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
241 childFilterElement.appendChild( childElem.cloneNode(
true ) );
244 childElem = childElem.nextSiblingElement();
248 QStringList collectedServerFids;
265 if ( !collectedServerFids.isEmpty() )
267 serverFids.append( collectedServerFids );
279 if ( project !=
nullptr )
286 if ( filter->hasParserError() || !filter->parserErrorString().isEmpty() )
291 if ( filter->needsGeometry() )
Contains information about the context in which a coordinate transform is executed.
QString expression() const
Returns the original, unmodified expression string.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsExpression * filterExpression() const
Returns the filter expression if set.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
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.
Base class for all map layer types.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the 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,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsCoordinateTransformContext transformContext
bool isEmpty() const
Returns true if the rectangle is empty.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
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...
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.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
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)
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.