33 return QStringLiteral(
"1.1.0" );
45 static QSet<QString> sFilter
47 QStringLiteral(
"REQUEST" ),
48 QStringLiteral(
"VERSION" ),
49 QStringLiteral(
"SERVICE" ),
55 const auto constQueryItems = q.queryItems();
56 for (
const auto ¶m : constQueryItems )
58 if ( sFilter.contains( param.first.toUpper() ) )
59 q.removeAllQueryItems( param.first );
65 return href.toString();
70 QString name = layer->
name();
73 name = name.replace(
' ',
'_' ).replace(
':',
'-' );
80 for (
const QString &layerId : std::as_const( layerIds ) )
87 if ( layer->
type() != Qgis::LayerType::Vector )
94 return qobject_cast<QgsVectorLayer *>( layer );
103 QStringList collectedServerFids;
111 QDomNodeList fidNodes = filterElem.elementsByTagName( QStringLiteral(
"FeatureId" ) );
112 QDomNodeList goidNodes = filterElem.elementsByTagName( QStringLiteral(
"GmlObjectId" ) );
113 if ( !fidNodes.isEmpty() )
116 QStringList collectedServerFids;
118 for (
int f = 0; f < fidNodes.size(); f++ )
120 fidElem = fidNodes.at( f ).toElement();
121 if ( !fidElem.hasAttribute( QStringLiteral(
"fid" ) ) )
126 QString serverFid = fidElem.attribute( QStringLiteral(
"fid" ) );
127 if ( serverFid.contains( QLatin1String(
"." ) ) )
129 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
131 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
133 collectedServerFids << serverFid;
136 if ( collectedServerFids.isEmpty() )
141 serverFids.append( collectedServerFids );
145 else if ( !goidNodes.isEmpty() )
148 QStringList collectedServerFids;
149 QDomElement goidElem;
150 for (
int f = 0; f < goidNodes.size(); f++ )
152 goidElem = goidNodes.at( f ).toElement();
153 if ( !goidElem.hasAttribute( QStringLiteral(
"id" ) ) && !goidElem.hasAttribute( QStringLiteral(
"gml:id" ) ) )
158 QString serverFid = goidElem.attribute( QStringLiteral(
"id" ) );
159 if ( serverFid.isEmpty() )
160 serverFid = goidElem.attribute( QStringLiteral(
"gml:id" ) );
161 if ( serverFid.contains( QLatin1String(
"." ) ) )
163 if ( serverFid.section( QStringLiteral(
"." ), 0, 0 ) !=
typeName )
165 serverFid = serverFid.section( QStringLiteral(
"." ), 1, 1 );
167 collectedServerFids << serverFid;
170 if ( collectedServerFids.isEmpty() )
175 serverFids.append( collectedServerFids );
179 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"BBOX" ) )
181 QDomElement bboxElem = filterElem.firstChildElement();
182 QDomElement childElem = bboxElem.firstChildElement();
184 while ( !childElem.isNull() )
186 if ( childElem.tagName() == QLatin1String(
"Box" ) )
190 else if ( childElem.tagName() != QLatin1String(
"PropertyName" ) )
196 childElem = childElem.nextSiblingElement();
203 else if ( filterElem.firstChildElement().tagName() == QLatin1String(
"And" ) &&
204 !filterElem.firstChildElement().firstChildElement( QLatin1String(
"BBOX" ) ).isNull() )
206 int nbChildElem = filterElem.firstChildElement().childNodes().size();
209 QDomElement childFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
210 if ( nbChildElem > 2 )
212 QDomElement childAndElement = filterElem.ownerDocument().createElement( QLatin1String(
"And" ) );
213 childFilterElement.appendChild( childAndElement );
217 QDomElement bboxFilterElement = filterElem.ownerDocument().createElement( QLatin1String(
"Filter" ) );
219 QDomElement childElem = filterElem.firstChildElement().firstChildElement();
220 while ( !childElem.isNull() )
223 if ( childElem.tagName() == QLatin1String(
"BBOX" ) )
226 bboxFilterElement.appendChild( childElem.cloneNode(
true ) );
231 if ( nbChildElem > 2 )
233 childFilterElement.firstChildElement().appendChild( childElem.cloneNode(
true ) );
237 childFilterElement.appendChild( childElem.cloneNode(
true ) );
240 childElem = childElem.nextSiblingElement();
244 QStringList collectedServerFids;
261 if ( !collectedServerFids.isEmpty() )
263 serverFids.append( collectedServerFids );
275 if ( project !=
nullptr )
282 if ( filter->hasParserError() || !filter->parserErrorString().isEmpty() )
287 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).
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsExpression * filterExpression() const
Returns the filter expression (if set).
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
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.