Skip to content

Commit e1ff0ed

Browse files
committed
support relative paths for gpx datasources (fixes #11131)
1 parent c8a76f8 commit e1ff0ed

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/core/qgsmaplayer.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
191191
theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
192192
mDataSource = theURIParts.join( "|" );
193193
}
194+
else if ( provider == "gpx" )
195+
{
196+
QStringList theURIParts = mDataSource.split( "?" );
197+
theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
198+
mDataSource = theURIParts.join( "?" );
199+
}
194200
else if ( provider == "delimitedtext" )
195201
{
196202
QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() );
@@ -466,6 +472,12 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
466472
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath );
467473
src = theURIParts.join( "|" );
468474
}
475+
else if ( vlayer && vlayer->providerType() == "gpx" )
476+
{
477+
QStringList theURIParts = src.split( "?" );
478+
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath );
479+
src = theURIParts.join( "?" );
480+
}
469481
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
470482
{
471483
QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
@@ -1066,6 +1078,11 @@ QString QgsMapLayer::saveNamedStyle( const QString &theURI, bool &theResultFlag
10661078
QStringList theURIParts = theURI.split( "|" );
10671079
filename = theURIParts[0];
10681080
}
1081+
else if ( vlayer && vlayer->providerType() == "gpx" )
1082+
{
1083+
QStringList theURIParts = theURI.split( "?" );
1084+
filename = theURIParts[0];
1085+
}
10691086
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
10701087
{
10711088
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
@@ -1244,6 +1261,11 @@ QString QgsMapLayer::saveSldStyle( const QString &theURI, bool &theResultFlag )
12441261
QStringList theURIParts = theURI.split( "|" );
12451262
filename = theURIParts[0];
12461263
}
1264+
else if ( vlayer->providerType() == "gpx" )
1265+
{
1266+
QStringList theURIParts = theURI.split( "?" );
1267+
filename = theURIParts[0];
1268+
}
12471269
else if ( vlayer->providerType() == "delimitedtext" )
12481270
{
12491271
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();

0 commit comments

Comments
 (0)