File tree 6 files changed +36
-2
lines changed
6 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,11 @@ namespace QgsWms
538
538
QVariant ( false ) );
539
539
save ( pWithMapTip );
540
540
541
+ const QgsWmsParameter pWithDisplayName ( QgsWmsParameter::WITH_DISPLAY_NAME,
542
+ QVariant::Bool,
543
+ QVariant ( false ) );
544
+ save ( pWithDisplayName );
545
+
541
546
const QgsWmsParameter pWmtver ( QgsWmsParameter::WMTVER );
542
547
save ( pWmtver );
543
548
@@ -2097,6 +2102,11 @@ namespace QgsWms
2097
2102
return mWmsParameters .value ( QgsWmsParameter::WITH_MAPTIP ).toBool ();
2098
2103
}
2099
2104
2105
+ bool QgsWmsParameters::withDisplayName () const
2106
+ {
2107
+ return mWmsParameters .value ( QgsWmsParameter::WITH_DISPLAY_NAME ).toBool ();
2108
+ }
2109
+
2100
2110
QString QgsWmsParameters::wmtver () const
2101
2111
{
2102
2112
return mWmsParameters .value ( QgsWmsParameter::WMTVER ).toString ();
Original file line number Diff line number Diff line change @@ -181,6 +181,7 @@ namespace QgsWms
181
181
GRID_INTERVAL_Y,
182
182
WITH_GEOMETRY,
183
183
WITH_MAPTIP,
184
+ WITH_DISPLAY_NAME,
184
185
WMTVER,
185
186
ATLAS_PK,
186
187
FORMAT_OPTIONS,
@@ -1287,6 +1288,13 @@ namespace QgsWms
1287
1288
*/
1288
1289
bool withMapTip () const ;
1289
1290
1291
+ /* *
1292
+ * \brief withDisplayName
1293
+ * \returns TRUE if the display name is requested for feature info response
1294
+ * \since QGIS 3.32
1295
+ */
1296
+ bool withDisplayName () const ;
1297
+
1290
1298
/* *
1291
1299
* Returns WMTVER parameter or an empty string if not defined.
1292
1300
* \since QGIS 3.4
Original file line number Diff line number Diff line change @@ -1867,6 +1867,18 @@ namespace QgsWms
1867
1867
featureElement.appendChild ( maptipElem );
1868
1868
}
1869
1869
1870
+ QgsExpression displayExpression = layer->displayExpression ();
1871
+ if ( displayExpression.isValid () && mWmsParameters .withDisplayName () )
1872
+ {
1873
+ QDomElement displayElem = infoDocument.createElement ( QStringLiteral ( " Attribute" ) );
1874
+ displayElem.setAttribute ( QStringLiteral ( " name" ), QStringLiteral ( " displayName" ) );
1875
+ QgsExpressionContext context { renderContext.expressionContext () };
1876
+ context.appendScope ( QgsExpressionContextUtils::layerScope ( layer ) );
1877
+ displayExpression.prepare ( &context );
1878
+ displayElem.setAttribute ( QStringLiteral ( " value" ), displayExpression.evaluate ( &context ).toString () );
1879
+ featureElement.appendChild ( displayElem );
1880
+ }
1881
+
1870
1882
// append feature bounding box to feature info xml
1871
1883
if ( QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry ( *mProject ) &&
1872
1884
layer->wkbType () != Qgis::WkbType::NoGeometry && hasGeometry )
Original file line number Diff line number Diff line change @@ -116,23 +116,25 @@ def testGetFeatureInfo(self):
116
116
'with_geometry=true' ,
117
117
'wms_getfeatureinfo-text-html-geometry' )
118
118
119
- # Test getfeatureinfo response html with maptip
119
+ # Test getfeatureinfo response html with maptip and display name
120
120
self .wms_request_compare ('GetFeatureInfo' ,
121
121
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
122
122
'info_format=text%2Fhtml&transparent=true&' +
123
123
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
124
124
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
125
125
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
126
+ 'with_display_name=true&' +
126
127
'with_maptip=true' ,
127
128
'wms_getfeatureinfo-text-html-maptip' )
128
129
129
- # Test getfeatureinfo response html with maptip in text mode
130
+ # Test getfeatureinfo response html with maptip and display name in text mode
130
131
self .wms_request_compare ('GetFeatureInfo' ,
131
132
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
132
133
'info_format=text%2Fplain&transparent=true&' +
133
134
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
134
135
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
135
136
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
137
+ 'with_display_name=true&' +
136
138
'with_maptip=true' ,
137
139
'wms_getfeatureinfo-text-html-maptip-plain' )
138
140
Original file line number Diff line number Diff line change 9
9
name = 'three'
10
10
utf8nameè = 'three èé↓'
11
11
maptip = 'Name: three'
12
+ displayName = 'three'
12
13
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Content-Type: text/html; charset=utf-8
14
14
<TR><TH>name</TH><TD>three</TD></TR>
15
15
<TR><TH>utf8nameè</TH><TD>three èé↓</TD></TR>
16
16
<TR><TH>maptip</TH><TD>Name: three</TD></TR>
17
+ <TR><TH>displayName</TH><TD>three</TD></TR>
17
18
</TABLE>
18
19
</BR>
19
20
</TABLE>
You can’t perform that action at this time.
0 commit comments