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 c8d625a commit 4f2b059e94aad8fff5d21e8b9fdb981fe5008aae
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 4f2b059

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