Skip to content

Commit 6bfc719

Browse files
committedMay 19, 2020
handle basemaps in QgsPathResolver
1 parent 75a991c commit 6bfc719

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/core/qgspathresolver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
***************************************************************************/
1515

1616
#include "qgspathresolver.h"
17+
#include "qgsbasemappathregistry.h"
1718

1819
#include "qgis.h"
1920
#include "qgsapplication.h"
2021
#include <QFileInfo>
2122
#include <QUrl>
2223
#include <QUuid>
2324

25+
2426
typedef std::vector< std::pair< QString, std::function< QString( const QString & ) > > > CustomResolvers;
2527
Q_GLOBAL_STATIC( CustomResolvers, sCustomResolvers )
2628

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

53+
if ( src.startsWith( QLatin1String( "basemap:" ) ) )
54+
{
55+
// strip away "inbuilt:" prefix, replace with actual inbuilt data folder path
56+
return QgsApplication::basemapPathRegistry()->fullPath( src.mid( 8 ) ) ;
57+
}
58+
5159
if ( mBaseFileName.isNull() )
5260
{
5361
return src;
@@ -183,6 +191,10 @@ QString QgsPathResolver::writePath( const QString &src ) const
183191
return src;
184192
}
185193

194+
QString basemapPath = QgsApplication::basemapPathRegistry()->relativePath( src );
195+
if ( !basemapPath.isEmpty() )
196+
return QStringLiteral( "basemap:" ) + basemapPath;
197+
186198
if ( src.startsWith( QgsApplication::pkgDataPath() + QStringLiteral( "/resources" ) ) )
187199
{
188200
// replace inbuilt data folder path with "inbuilt:" prefix

0 commit comments

Comments
 (0)
Please sign in to comment.