Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #42100 from elpaso/bugfix-unreported-wms-cascading…
…-fid

WMS cascading: fix unreported issue wih missing fids
  • Loading branch information
elpaso authored and nyalldawson committed Mar 11, 2021
1 parent fbe1cf8 commit 4ec6c81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -3489,6 +3489,23 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
params.insert( QStringLiteral( "getFeatureInfoUrl" ), requestUrl.toString() );
featureStore.setParams( params );

// Try to parse and set feature id if matches "<some string>.<integer>"
if ( f.value( QLatin1String( "id" ) ).isString() )
{
const thread_local QRegularExpression re{ R"raw(\.(\d+)$)raw" };
const QString idVal { f.value( QLatin1String( "id" ) ).toString() };
const QRegularExpressionMatch match { re.match( idVal ) };
if ( match.hasMatch() )
{
bool ok;
QgsFeatureId id { match.captured( 1 ).toLongLong( &ok ) };
if ( ok )
{
feature.setId( id );
}
}
}

feature.setValid( true );
featureStore.addFeature( feature );

Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2508,7 +2508,7 @@ namespace QgsWms
if ( layer && layer->dataProvider() )
fid = QgsServerFeatureId::getServerFid( *feat, layer->dataProvider()->pkAttributeIndexes() );
else
fid = feat->id();
fid = FID_TO_STRING( feat->id() );

typeNameElement.setAttribute( QStringLiteral( "fid" ), QStringLiteral( "%1.%2" ).arg( typeName, fid ) );

Expand Down

0 comments on commit 4ec6c81

Please sign in to comment.