Skip to content

Commit

Permalink
[Server][BUGFIX] Resolve relative pathes (SVGMArker, Netcdf, etc)
Browse files Browse the repository at this point in the history
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 4f2b059
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server/qgsserverprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f2b059

Please sign in to comment.