Skip to content

Commit fe71b49

Browse files
committedSep 16, 2018
[bugfix][server] WMS GFI value relation array fields
Fixes #19827 - GetFeatureInfo on "value relation" widget with array field (multiple selections)
1 parent 5112a0a commit fe71b49

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed
 

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ namespace QgsWms
418418
QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
419419
QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
420420
QgsLayoutMeasurement height( layout->convertFromLayoutUnits( layoutSize.height(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
421-
exportSettings.imageSize = QSize( ( int )( width.length() * dpi / 25.4 ), ( int )( height.length() * dpi / 25.4 ) );
421+
exportSettings.imageSize = QSize( static_cast<int>( width.length() * dpi / 25.4 ), static_cast<int>( height.length() * dpi / 25.4 ) );
422422
// Export first page only (unless it's a pdf, see below)
423423
exportSettings.pages.append( 0 );
424424
QgsLayoutExporter exporter( layout.get() );
@@ -1019,11 +1019,11 @@ namespace QgsWms
10191019
if ( !mapExtent.isEmpty() && height > 0 && width > 0 )
10201020
{
10211021
double mapWidthHeightRatio = mapExtent.width() / mapExtent.height();
1022-
double imageWidthHeightRatio = ( double )width / ( double )height;
1022+
double imageWidthHeightRatio = static_cast<double>( width ) / static_cast<double>( height );
10231023
if ( !qgsDoubleNear( mapWidthHeightRatio, imageWidthHeightRatio, 0.0001 ) )
10241024
{
10251025
// inspired by MapServer, mapdraw.c L115
1026-
double cellsize = ( mapExtent.width() / ( double )width ) * 0.5 + ( mapExtent.height() / ( double )height ) * 0.5;
1026+
double cellsize = ( mapExtent.width() / static_cast<double>( width ) ) * 0.5 + ( mapExtent.height() / static_cast<double>( height ) ) * 0.5;
10271027
width = mapExtent.width() / cellsize;
10281028
height = mapExtent.height() / cellsize;
10291029
}
@@ -1174,8 +1174,8 @@ namespace QgsWms
11741174
int height = mWmsParameters.heightAsInt();
11751175
if ( ( i != -1 && j != -1 && width != 0 && height != 0 ) && ( width != outputImage->width() || height != outputImage->height() ) )
11761176
{
1177-
i *= ( outputImage->width() / ( double )width );
1178-
j *= ( outputImage->height() / ( double )height );
1177+
i *= ( outputImage->width() / static_cast<double>( width ) );
1178+
j *= ( outputImage->height() / static_cast<double>( height ) );
11791179
}
11801180

11811181
// init search variables
@@ -1573,11 +1573,13 @@ namespace QgsWms
15731573

15741574
QDomElement attributeElement = infoDocument.createElement( QStringLiteral( "Attribute" ) );
15751575
attributeElement.setAttribute( QStringLiteral( "name" ), attributeName );
1576+
const QgsEditorWidgetSetup setup = layer->editorWidgetSetup( i );
15761577
attributeElement.setAttribute( QStringLiteral( "value" ),
1577-
replaceValueMapAndRelation(
1578-
layer, i,
1579-
featureAttributes[i].isNull() ? QString() : QgsExpression::replaceExpressionText( featureAttributes[i].toString(), &renderContext.expressionContext() )
1580-
)
1578+
QgsExpression::replaceExpressionText(
1579+
replaceValueMapAndRelation(
1580+
layer, i,
1581+
featureAttributes[i] ),
1582+
&renderContext.expressionContext() )
15811583
);
15821584
featureElement.appendChild( attributeElement );
15831585
}
@@ -1878,11 +1880,11 @@ namespace QgsWms
18781880

18791881
const int bytes_per_line = ( ( width * depth + 31 ) >> 5 ) << 2; // bytes per scanline (must be multiple of 4)
18801882

1881-
if ( std::numeric_limits<int>::max() / depth < ( uint )width
1883+
if ( std::numeric_limits<int>::max() / depth < static_cast<uint>( width )
18821884
|| bytes_per_line <= 0
18831885
|| height <= 0
1884-
|| std::numeric_limits<int>::max() / uint( bytes_per_line ) < ( uint )height
1885-
|| std::numeric_limits<int>::max() / sizeof( uchar * ) < uint( height ) )
1886+
|| std::numeric_limits<int>::max() / static_cast<uint>( bytes_per_line ) < static_cast<uint>( height )
1887+
|| std::numeric_limits<int>::max() / sizeof( uchar * ) < static_cast<uint>( height ) )
18861888
return false;
18871889

18881890
return true;
@@ -2245,7 +2247,7 @@ namespace QgsWms
22452247
QString fieldTextString = featureAttributes.at( i ).toString();
22462248
if ( layer )
22472249
{
2248-
fieldTextString = replaceValueMapAndRelation( layer, i, QgsExpression::replaceExpressionText( fieldTextString, &expressionContext ) );
2250+
fieldTextString = QgsExpression::replaceExpressionText( replaceValueMapAndRelation( layer, i, fieldTextString ), &expressionContext );
22492251
}
22502252
QDomText fieldText = doc.createTextNode( fieldTextString );
22512253
fieldElem.appendChild( fieldText );
@@ -2270,7 +2272,7 @@ namespace QgsWms
22702272
return typeNameElement;
22712273
}
22722274

2273-
QString QgsRenderer::replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QString &attributeVal )
2275+
QString QgsRenderer::replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QVariant &attributeVal )
22742276
{
22752277
const QgsEditorWidgetSetup setup = vl->editorWidgetSetup( idx );
22762278
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ namespace QgsWms
278278
QStringList *attributes = nullptr ) const;
279279

280280
//! Replaces attribute value with ValueRelation or ValueRelation if defined. Otherwise returns the original value
281-
static QString replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QString &attributeVal );
281+
static QString replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QVariant &attributeVal );
282282
//! Gets layer search rectangle (depending on request parameter, layer type, map and layer crs)
283283
QgsRectangle featureInfoSearchRect( QgsVectorLayer *ml, const QgsMapSettings &ms, const QgsRenderContext &rct, const QgsPointXY &infoPoint ) const;
284284

‎tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ def testGetFeatureInfoValueRelation(self):
224224
'wms_getfeatureinfo-values1-text-xml',
225225
'test_project_values.qgz')
226226

227-
# TODO make GetFeatureInfo show the dictionary values and enable test
228-
@unittest.expectedFailure
229227
def testGetFeatureInfoValueRelationArray(self):
230228
"""Test GetFeatureInfo on "value relation" widget with array field (multiple selections)"""
231229
mypath = self.testdata_path + "test_project_values.qgz"

0 commit comments

Comments
 (0)