Skip to content

Commit

Permalink
handle basemaps in QgsPathResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 19, 2020
1 parent 75a991c commit 6bfc719
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/qgspathresolver.cpp
Expand Up @@ -14,13 +14,15 @@
***************************************************************************/

#include "qgspathresolver.h"
#include "qgsbasemappathregistry.h"

#include "qgis.h"
#include "qgsapplication.h"
#include <QFileInfo>
#include <QUrl>
#include <QUuid>


typedef std::vector< std::pair< QString, std::function< QString( const QString & ) > > > CustomResolvers;
Q_GLOBAL_STATIC( CustomResolvers, sCustomResolvers )

Expand Down Expand Up @@ -48,6 +50,12 @@ QString QgsPathResolver::readPath( const QString &f ) const
return QgsApplication::pkgDataPath() + QStringLiteral( "/resources" ) + src.mid( 8 );
}

if ( src.startsWith( QLatin1String( "basemap:" ) ) )
{
// strip away "inbuilt:" prefix, replace with actual inbuilt data folder path
return QgsApplication::basemapPathRegistry()->fullPath( src.mid( 8 ) ) ;
}

if ( mBaseFileName.isNull() )
{
return src;
Expand Down Expand Up @@ -183,6 +191,10 @@ QString QgsPathResolver::writePath( const QString &src ) const
return src;
}

QString basemapPath = QgsApplication::basemapPathRegistry()->relativePath( src );
if ( !basemapPath.isEmpty() )
return QStringLiteral( "basemap:" ) + basemapPath;

if ( src.startsWith( QgsApplication::pkgDataPath() + QStringLiteral( "/resources" ) ) )
{
// replace inbuilt data folder path with "inbuilt:" prefix
Expand Down

0 comments on commit 6bfc719

Please sign in to comment.