34 return QStringLiteral(
"1.1.0" );
46 static QSet<QString> sFilter
48 QStringLiteral(
"REQUEST" ),
49 QStringLiteral(
"VERSION" ),
50 QStringLiteral(
"SERVICE" ),
56 const auto constQueryItems = q.queryItems();
57 for (
const auto ¶m : constQueryItems )
59 if ( sFilter.contains( param.first.toUpper() ) )
60 q.removeAllQueryItems( param.first );
66 return href.toString();
71 QString name = layer->
name();
74 name = name.replace(
' ',
'_' ).replace(
':',
'-' );
81 for (
const QString &layerId : std::as_const( layerIds ) )
95 return qobject_cast<QgsVectorLayer *>( layer );
104 QStringList collectedServerFids;
112 QDomNodeList fidNodes = filterElem.elementsByTagName( QStringLiteral(
"FeatureId" ) );
113 QDomNodeList goidNodes = filterElem.elementsByTagName( QStringLiteral(
"GmlObjectId" ) );
114 if ( !fidNodes.isEmpty() )
117 QStringList collectedServerFids;
119 for (
int f = 0; f < fidNodes.size(); f++ )
121 fidElem = fidNodes.at( f ).toElement();
122 if ( !fidElem.hasAttribute( QStringLiteral(
"fid" ) ) )
127 QString serverFid = fidElem.attribute( QStringLiteral(
"fid" ) );
128 if ( serverFid.contains( QLatin1String(
"." ) ) )
130 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
132 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
134 collectedServerFids << serverFid;
137 if ( collectedServerFids.isEmpty() )
142 serverFids.append( collectedServerFids );
146 else if ( !goidNodes.isEmpty() )
149 QStringList collectedServerFids;
150 QDomElement goidElem;
151 for (
int f = 0; f < goidNodes.size(); f++ )
153 goidElem = goidNodes.at( f ).toElement();
154 if ( !goidElem.hasAttribute( QStringLiteral(
"id" ) ) && !goidElem.hasAttribute( QStringLiteral(
"gml:id" ) ) )
159 QString serverFid = goidElem.attribute( QStringLiteral(
"id" ) );
160 if ( serverFid.isEmpty() )
161 serverFid = goidElem.attribute( QStringLiteral(
"gml:id" ) );
162 if ( serverFid.contains( QLatin1String(
"." ) ) )
164 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
166 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
168 collectedServerFids << serverFid;
171 if ( collectedServerFids.isEmpty() )
176 serverFids.append( collectedServerFids );
180 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"BBOX" ) )
182 QDomElement bboxElem = filterElem.firstChildElement();
183 QDomElement childElem = bboxElem.firstChildElement();
185 while ( !childElem.isNull() )
187 if ( childElem.tagName() == QLatin1String(
"Box" ) )
191 else if ( childElem.tagName() != QLatin1String(
"PropertyName" ) )
197 childElem = childElem.nextSiblingElement();
204 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"And" ) &&
205 !filterElem.firstChildElement().firstChildElement( QLatin1String(
"BBOX" ) ).isNull() )
207 int nbChildElem = filterElem.firstChildElement().childNodes().size();
210 QDomElement childFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
211 if ( nbChildElem > 2 )
213 QDomElement childAndElement = filterElem.ownerDocument().createElement( QLatin1String(
"And" ) );
214 childFilterElement.appendChild( childAndElement );
218 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
220 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
221 while ( !childElem.isNull() )
224 if ( childElem.tagName() == QLatin1String(
"BBOX" ) )
227 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
232 if ( nbChildElem > 2 )
234 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
238 childFilterElement.appendChild( childElem.cloneNode(
true ) );
241 childElem = childElem.nextSiblingElement();
245 QStringList collectedServerFids;
262 if ( !collectedServerFids.isEmpty() )
264 serverFids.append( collectedServerFids );
276 if ( project !=
nullptr )
283 if ( filter->hasParserError() || !filter->parserErrorString().isEmpty() )
288 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,...
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
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...
Provides a way to retrieve settings by prioritizing according to environment variables,...
Represents a vector layer which manages a vector based data sets.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QString wfsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WFS service url.
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, 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.