@@ -243,8 +243,6 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
243
243
}
244
244
245
245
QStringList wfsLayersId = wfsLayers ();
246
- QMap< QString, QMap< int , QString > > aliasInfo = layerAliasInfo ();
247
- QMap< QString, QSet<QString> > excludedAttrs = wfsExcludedAttributes ();
248
246
249
247
foreach ( const QDomElement &elem, mProjectLayerElements )
250
248
{
@@ -262,21 +260,8 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
262
260
continue ;
263
261
}
264
262
265
- // is there alias info for this vector layer?
266
- QMap< int , QString > layerAliasInfo;
267
- QMap< QString, QMap< int , QString > >::const_iterator aliasIt = aliasInfo.find ( mLayer ->id () );
268
- if ( aliasIt != aliasInfo.constEnd () )
269
- {
270
- layerAliasInfo = aliasIt.value ();
271
- }
272
-
273
263
// hidden attributes for this layer
274
- QSet<QString> layerExcludedAttributes;
275
- QMap< QString, QSet<QString> >::const_iterator exclIt = excludedAttrs.find ( mLayer ->id () );
276
- if ( exclIt != excludedAttrs.constEnd () )
277
- {
278
- layerExcludedAttributes = exclIt.value ();
279
- }
264
+ const QSet<QString>& layerExcludedAttributes = layer->excludeAttributesWFS ();
280
265
281
266
QString typeName = layer->name ();
282
267
typeName = typeName.replace ( QString ( " " ), QString ( " _" ) );
@@ -349,7 +334,7 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
349
334
{
350
335
351
336
QString attributeName = it.value ().name ();
352
- // skip attribute if it has edit type 'hidden'
337
+ // skip attribute if excluded from WFS publication
353
338
if ( layerExcludedAttributes.contains ( attributeName ) )
354
339
{
355
340
continue ;
@@ -367,11 +352,10 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
367
352
368
353
sequenceElem.appendChild ( geomElem );
369
354
370
- // check if the attribute name should be replaced with an alias
371
- QMap<int , QString>::const_iterator aliasIt = layerAliasInfo.find ( it.key () );
372
- if ( aliasIt != layerAliasInfo.constEnd () )
355
+ QString alias = layer->attributeAlias ( it.key () );
356
+ if ( !alias.isEmpty () )
373
357
{
374
- geomElem.setAttribute ( " alias" , aliasIt. value () );
358
+ geomElem.setAttribute ( " alias" , alias );
375
359
}
376
360
}
377
361
}
@@ -1185,52 +1169,6 @@ bool QgsProjectParser::featureInfoWithWktGeometry() const
1185
1169
return ( wktElem.text ().compare ( " true" , Qt::CaseInsensitive ) == 0 );
1186
1170
}
1187
1171
1188
- QMap< QString, QMap< int , QString > > QgsProjectParser::layerAliasInfo () const
1189
- {
1190
- QMap< QString, QMap< int , QString > > resultMap;
1191
-
1192
- QList<QDomElement>::const_iterator layerIt = mProjectLayerElements .constBegin ();
1193
- for ( ; layerIt != mProjectLayerElements .constEnd (); ++layerIt )
1194
- {
1195
- QDomNodeList aNodeList = layerIt->elementsByTagName ( " aliases" );
1196
- if ( aNodeList.size () > 0 )
1197
- {
1198
- QMap<int , QString> aliasMap;
1199
- QDomNodeList aliasNodeList = aNodeList.at ( 0 ).toElement ().elementsByTagName ( " alias" );
1200
- for ( int i = 0 ; i < aliasNodeList.size (); ++i )
1201
- {
1202
- QDomElement aliasElem = aliasNodeList.at ( i ).toElement ();
1203
- aliasMap.insert ( aliasElem.attribute ( " index" ).toInt (), aliasElem.attribute ( " name" ) );
1204
- }
1205
- resultMap.insert ( layerId ( *layerIt ) , aliasMap );
1206
- }
1207
- }
1208
-
1209
- return resultMap;
1210
- }
1211
-
1212
- /* *Returns attributes excluded from WFS publication. Key is layer id, value is a set containing the names of the hidden attributes*/
1213
- QMap< QString, QSet<QString> > QgsProjectParser::wfsExcludedAttributes () const
1214
- {
1215
- QMap< QString, QSet<QString> > resultMap;
1216
- QList<QDomElement>::const_iterator layerIt = mProjectLayerElements .constBegin ();
1217
- for ( ; layerIt != mProjectLayerElements .constEnd (); ++layerIt )
1218
- {
1219
- QDomElement excludeWMSElem = layerIt->firstChildElement ( " excludeAttributesWFS" );
1220
- QDomNodeList attributeNodeList = excludeWMSElem.elementsByTagName ( " attribute" );
1221
- if ( attributeNodeList.size () > 0 )
1222
- {
1223
- QSet<QString> layerExcludedAttributes;
1224
- for ( int i = 0 ; i < attributeNodeList.size (); ++i )
1225
- {
1226
- layerExcludedAttributes.insert ( attributeNodeList.at ( i ).toElement ().text () );
1227
- }
1228
- resultMap.insert ( layerId ( *layerIt ), layerExcludedAttributes );
1229
- }
1230
- }
1231
- return resultMap;
1232
- }
1233
-
1234
1172
QgsRectangle QgsProjectParser::mapRectangle () const
1235
1173
{
1236
1174
if ( !mXMLDoc )
0 commit comments