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() )
139 throw QgsRequestNotWellFormedException( QStringLiteral(
"No FeatureId element correctly parse against typeName '%1'" ).arg(
typeName ) );
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" ) ) )
156 throw QgsRequestNotWellFormedException(
"GmlObjectId element without gml:id attribute" );
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() )
173 throw QgsRequestNotWellFormedException( QStringLiteral(
"No GmlObjectId element correctly parse against typeName '%1'" ).arg(
typeName ) );
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() )
285 throw QgsRequestNotWellFormedException( filter->parserErrorString() );
288 if ( filter->needsGeometry() )