Skip to content

Commit 4ec6c81

Browse files
elpasonyalldawson
authored andcommittedMar 11, 2021
Merge pull request #42100 from elpaso/bugfix-unreported-wms-cascading-fid
WMS cascading: fix unreported issue wih missing fids
1 parent fbe1cf8 commit 4ec6c81

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
 

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,23 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
34893489
params.insert( QStringLiteral( "getFeatureInfoUrl" ), requestUrl.toString() );
34903490
featureStore.setParams( params );
34913491

3492+
// Try to parse and set feature id if matches "<some string>.<integer>"
3493+
if ( f.value( QLatin1String( "id" ) ).isString() )
3494+
{
3495+
const thread_local QRegularExpression re{ R"raw(\.(\d+)$)raw" };
3496+
const QString idVal { f.value( QLatin1String( "id" ) ).toString() };
3497+
const QRegularExpressionMatch match { re.match( idVal ) };
3498+
if ( match.hasMatch() )
3499+
{
3500+
bool ok;
3501+
QgsFeatureId id { match.captured( 1 ).toLongLong( &ok ) };
3502+
if ( ok )
3503+
{
3504+
feature.setId( id );
3505+
}
3506+
}
3507+
}
3508+
34923509
feature.setValid( true );
34933510
featureStore.addFeature( feature );
34943511

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ namespace QgsWms
25082508
if ( layer && layer->dataProvider() )
25092509
fid = QgsServerFeatureId::getServerFid( *feat, layer->dataProvider()->pkAttributeIndexes() );
25102510
else
2511-
fid = feat->id();
2511+
fid = FID_TO_STRING( feat->id() );
25122512

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

0 commit comments

Comments
 (0)
Please sign in to comment.