Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[bugfix][server] Respect relations in getfeatureinfo
Fixes #18518

QGIS Server 3 GetFeatureInfo doesn't resolve value relations anymore
  • Loading branch information
elpaso committed Jun 14, 2018
1 parent 365fbed commit eb0be33
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/core/auto_generated/qgsproject.sip.in
Expand Up @@ -46,6 +46,7 @@ Most of the time you want to use QgsProject.instance() instead as many component

~QgsProject();


void setTitle( const QString &title );
%Docstring
Sets the project's title.
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsproject.cpp
Expand Up @@ -382,6 +382,11 @@ QgsProject::~QgsProject()
}
}

void QgsProject::setInstance( QgsProject *project )
{
sProject = project;
}


QgsProject *QgsProject::instance()
{
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsproject.h
Expand Up @@ -109,6 +109,18 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera

~QgsProject() override;

#ifndef SIP_RUN

/**
* Set the current project instance to \a project
*
* \note this is used mainly by the server, which caches the projects and (potentially) needs to switch the current instance on every request
* \see instance()
* \since QGIS 3.2
*/
static void setInstance( QgsProject *project );
#endif

/**
* Sets the project's title.
* \param title new title
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsconfigcache.cpp
Expand Up @@ -48,7 +48,7 @@ const QgsProject *QgsConfigCache::project( const QString &path )
mFileSystemWatcher.addPath( path );
}
}

QgsProject::setInstance( mProjectCache[ path ] );
return mProjectCache[ path ];
}

Expand Down
13 changes: 13 additions & 0 deletions tests/src/python/test_qgsserver_wms_getfeatureinfo.py
Expand Up @@ -286,6 +286,19 @@ def testGetFeatureInfoFilter(self):
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
'wms_getfeatureinfo_filter_no_width')

def test_value_relation(self):
"""Test wether value relations are resolved: regression 18518"""
self.wms_request_compare('GetFeatureInfo',
'&BBOX=537912.30469845747575164,4975501.92125043831765652,577227.89428471261635423,4996610.36656293831765652' +
'&CRS=EPSG:32632' +
'&WIDTH=1328&HEIGHT=713' +
'&LAYERS=test_multi' +
'&STYLES=&FORMAT=image/jpeg' +
'&QUERY_LAYERS=test_multi&INFO_FORMAT=text/xml' +
'&I=429&J=528&FEATURE_COUNT=10',
'wms_getfeatureinfo_value_relation',
project='test_project_value_relation.qgz')


if __name__ == '__main__':
unittest.main()

0 comments on commit eb0be33

Please sign in to comment.