Skip to content
Permalink
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 ce62640 commit b54d2790d4b74449bd8f28a6ca838e42f66f55a2
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 );
}
}

QgsServerProjectParser::QgsServerProjectParser()
@@ -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 b54d279

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