Skip to content

Commit c20e441

Browse files
authoredJun 18, 2018
Merge pull request #7244 from elpaso/bugfix-18518-server-gfi-relations
[bugfix][server] respect relations in getfeatureinfo
2 parents e39abc5 + 9c85457 commit c20e441

File tree

7 files changed

+52
-9
lines changed

7 files changed

+52
-9
lines changed
 

‎src/core/qgsproject.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ QgsProject::~QgsProject()
382382
}
383383
}
384384

385+
void QgsProject::setInstance( QgsProject *project )
386+
{
387+
sProject = project;
388+
}
389+
385390

386391
QgsProject *QgsProject::instance()
387392
{

‎src/core/qgsproject.h

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
110110
~QgsProject() override;
111111

112112
/**
113-
* Sets the project's title.
114-
* \param title new title
115-
*
116-
* \note Since QGIS 3.2 this is just a shortcut to setting the title in the project's metadata().
117-
*
118-
* \see title()
119-
* \since QGIS 2.4
120-
*/
113+
* Sets the project's title.
114+
* \param title new title
115+
*
116+
* \note Since QGIS 3.2 this is just a shortcut to setting the title in the project's metadata().
117+
*
118+
* \see title()
119+
* \since QGIS 2.4
120+
*/
121121
void setTitle( const QString &title );
122122

123123
/**
@@ -1257,6 +1257,16 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
12571257

12581258
static QgsProject *sProject;
12591259

1260+
/**
1261+
* Set the current project instance to \a project
1262+
*
1263+
* \note this is used mainly by the server, which caches the projects and (potentially) needs to switch the current instance on every request
1264+
* \see instance()
1265+
* \note not available in Python bindings
1266+
* \since QGIS 3.2
1267+
*/
1268+
static void setInstance( QgsProject *project ) SIP_SKIP;
1269+
12601270
/**
12611271
* Read map layers from project file.
12621272
* \param doc DOM document to parse
@@ -1362,6 +1372,9 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
13621372
QgsProjectMetadata mMetadata;
13631373

13641374
friend class QgsProjectDirtyBlocker;
1375+
1376+
// Required by QGIS Server for switching the current project instance
1377+
friend class QgsConfigCache;
13651378
};
13661379

13671380
/**

‎src/server/qgsconfigcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const QgsProject *QgsConfigCache::project( const QString &path )
4848
mFileSystemWatcher.addPath( path );
4949
}
5050
}
51-
51+
QgsProject::setInstance( mProjectCache[ path ] );
5252
return mProjectCache[ path ];
5353
}
5454

‎tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ def testGetFeatureInfoFilter(self):
286286
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
287287
'wms_getfeatureinfo_filter_no_width')
288288

289+
def test_value_relation(self):
290+
"""Test whether value relations are resolved: regression 18518"""
291+
self.wms_request_compare('GetFeatureInfo',
292+
'&BBOX=537912.30469845747575164,4975501.92125043831765652,577227.89428471261635423,4996610.36656293831765652' +
293+
'&CRS=EPSG:32632' +
294+
'&WIDTH=1328&HEIGHT=713' +
295+
'&LAYERS=test_multi' +
296+
'&STYLES=&FORMAT=image/jpeg' +
297+
'&QUERY_LAYERS=test_multi&INFO_FORMAT=text/xml' +
298+
'&I=429&J=528&FEATURE_COUNT=10',
299+
'wms_getfeatureinfo_value_relation',
300+
project='test_project_value_relation.qgz')
301+
289302

290303
if __name__ == '__main__':
291304
unittest.main()
Binary file not shown.
216 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Content-Length: 238
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="test_multi">
6+
<Feature id="7">
7+
<Attribute value="7" name="fid"/>
8+
<Attribute value="10" name="id"/>
9+
<Attribute value="Piacenza" name="fk_prov"/>
10+
</Feature>
11+
</Layer>
12+
</GetFeatureInfoResponse>

0 commit comments

Comments
 (0)
Please sign in to comment.