Skip to content
Browse files

[Server][BUGFIX] Resolve relative pathes (SVGMArker, Netcdf, etc)

QGIS-Server has some trouble to resolve relative pathes. For example,
 SVGMarker path and NETCDF datasource are not resolved in QGIS Server unlike
 in QGIS Desktop.

To resolve relative path for SVGMarker, the class QgsSombolLayerV2Utils is
 used and it based on QgsProject::instance()->fileName().
To resolve relative path for NETCDF datasource and other GDAL datasources, the
 class QgsMapLayer is used and it based on
 QgsProject::instance()->readPath( filename ).

To fix the issue, the QgsProject instance fileName is set in the
 QgsServerProjectParser constructor.
  • Loading branch information
rldhont committed Sep 22, 2015
1 parent a42b760 commit bcc2f750e80b06c544b233e38ded101d47ee8a08
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/server/qgsserverprojectparser.cpp
@@ -76,6 +76,12 @@ QgsServerProjectParser::QgsServerProjectParser( QDomDocument* xmlDoc, const QStr
// Setting the QgsProject instance fileName
// to help converting relative pathes to absolute
if ( mProjectPath != "" )
QgsProject::instance()->setFileName( mProjectPath );

@@ -169,6 +175,8 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
QDomElement dataSourceElem = elem.firstChildElement( "datasource" );
QString uri = dataSourceElem.text();
QString absoluteUri;
// If QgsProject instance fileName is set,
// Is converting relative pathes to absolute still relevant ?
if ( !dataSourceElem.isNull() )
//convert relative pathes to absolute ones if necessary

0 comments on commit bcc2f75

Please sign in to comment.
You can’t perform that action at this time.