Skip to content
Permalink
Browse files
WMS cascading: fix unreported issue wih missing fids
1. in WMS provider try to set fid from external getFeatureInfo JSON response
2. in WMS server, make sure we transform integer FID to string

This fixes an unreported issue where getFeatureInfo from cascaded WMS in
JSON format have no feature IDs.

Funded by Gis3W https://www.gis3w.it

(cherry picked from commit 0189efa)
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2021
1 parent 3bba063 commit 44d2b4b7eef2e538c1888d963ad007da8e8d10b9
Showing with 18 additions and 1 deletion.
  1. +17 −0 src/providers/wms/qgswmsprovider.cpp
  2. +1 −1 src/server/services/wms/qgswmsrenderer.cpp
@@ -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() )
{
static const 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 );

@@ -2432,7 +2432,7 @@ namespace QgsWms
if ( layer && layer->dataProvider() )
fid = QgsServerFeatureId::getServerFid( *feat, layer->dataProvider()->pkAttributeIndexes() );
else
fid = feat->id();
fid = QString::number( feat->id() );

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

0 comments on commit 44d2b4b

Please sign in to comment.