Skip to content
Permalink
Browse files

Consider pk/fid in wfs transaction

  • Loading branch information
mhugent committed Feb 19, 2018
1 parent 551547a commit b3eaedea8487a368157612c028ccdae04909f1b3
Showing with 21 additions and 9 deletions.
  1. +2 −8 src/server/qgsowsserver.cpp
  2. +19 −1 src/server/qgswfsserver.cpp
@@ -72,16 +72,10 @@ QString QgsOWSServer::featureGmlId( const QgsFeature* f, const QgsAttributeList&
return QString();
}

if ( pkAttributes.isEmpty() )
if ( pkAttributes.size() != 1 )
{
return QString::number( f->id() );
}

QString pkId;
QgsAttributeList::const_iterator it = pkAttributes.constBegin();
for ( ; it != pkAttributes.constEnd(); ++it )
{
pkId.append( f->attribute( *it ).toString() );
}
return pkId;
return f->attribute( pkAttributes.at( 0 ) ).toString();
}
@@ -1872,7 +1872,25 @@ QgsFeatureIds QgsWFSServer::getFeatureIdsFromFilter( const QDomElement& filterEl
fid = fidElem.attribute( "fid" );
if ( fid.contains( "." ) )
fid = fid.section( ".", 1, 1 );
fids.insert( fid.toLongLong( &conversionSuccess ) );
if ( provider->pkAttributeIndexes().size() == 1 )
{
//assume ID is the primary key, as it is more stable than the feature ID
QgsFeature feature;
const QgsFields& fields = provider->fields();
QString fieldName = fields[provider->pkAttributeIndexes().at( 0 )].name();
QgsExpression pkExpression( fieldName + " = " + fid );
QgsExpressionContext exprContext = QgsExpressionContextUtils::createFeatureBasedContext( feature, fields );
QgsFeatureRequest fReq( pkExpression, exprContext );
QgsFeatureIterator fIt = provider->getFeatures( fReq );
if ( fIt.nextFeature( feature ) )
{
fids.insert( feature.id() );
}
}
else //assume it is the feture id
{
fids.insert( fid.toLongLong( &conversionSuccess ) );
}
}
}
else

0 comments on commit b3eaede

Please sign in to comment.
You can’t perform that action at this time.