Skip to content

Commit

Permalink
Merge pull request #7244 from elpaso/bugfix-18518-server-gfi-relations
Browse files Browse the repository at this point in the history
[bugfix][server] respect relations in getfeatureinfo
  • Loading branch information
elpaso committed Jun 18, 2018
2 parents e39abc5 + 9c85457 commit c20e441
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 9 deletions.
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
29 changes: 21 additions & 8 deletions src/core/qgsproject.h
Expand Up @@ -110,14 +110,14 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
~QgsProject() override;

/**
* Sets the project's title.
* \param title new title
*
* \note Since QGIS 3.2 this is just a shortcut to setting the title in the project's metadata().
*
* \see title()
* \since QGIS 2.4
*/
* Sets the project's title.
* \param title new title
*
* \note Since QGIS 3.2 this is just a shortcut to setting the title in the project's metadata().
*
* \see title()
* \since QGIS 2.4
*/
void setTitle( const QString &title );

/**
Expand Down Expand Up @@ -1257,6 +1257,16 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera

static QgsProject *sProject;

/**
* 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()
* \note not available in Python bindings
* \since QGIS 3.2
*/
static void setInstance( QgsProject *project ) SIP_SKIP;

/**
* Read map layers from project file.
* \param doc DOM document to parse
Expand Down Expand Up @@ -1362,6 +1372,9 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
QgsProjectMetadata mMetadata;

friend class QgsProjectDirtyBlocker;

// Required by QGIS Server for switching the current project instance
friend class QgsConfigCache;
};

/**
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 whether 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()
Binary file not shown.
Binary file added tests/testdata/qgis_server/value_relation.gpkg
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/testdata/qgis_server/wms_getfeatureinfo_value_relation.txt
@@ -0,0 +1,12 @@
Content-Length: 238
Content-Type: text/xml; charset=utf-8

<GetFeatureInfoResponse>
<Layer name="test_multi">
<Feature id="7">
<Attribute value="7" name="fid"/>
<Attribute value="10" name="id"/>
<Attribute value="Piacenza" name="fk_prov"/>
</Feature>
</Layer>
</GetFeatureInfoResponse>

0 comments on commit c20e441

Please sign in to comment.