|
46 | 46 | #include "qgsrectangle.h"
|
47 | 47 | #include "qgsvectorlayer.h"
|
48 | 48 |
|
| 49 | + |
49 | 50 | QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
|
50 | 51 | QString lyrname,
|
51 | 52 | QString source ) :
|
@@ -291,6 +292,34 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
|
291 | 292 | }
|
292 | 293 | // <<< BACKWARD COMPATIBILITY < 1.9
|
293 | 294 | }
|
| 295 | + else if ( provider == "gdal" ) |
| 296 | + { |
| 297 | + QStringList theURIParts = mDataSource.split( ":" ); |
| 298 | + if ( theURIParts[0] == "NETCDF" ) |
| 299 | + { |
| 300 | + QString src = theURIParts[1]; |
| 301 | + src.replace( "\"", "" ); |
| 302 | + src = QgsProject::instance()->readPath( src ); |
| 303 | + theURIParts[1] = "\"" + src + "\""; |
| 304 | + } |
| 305 | + else if ( theURIParts[0] == "HDF4_SDS" ) |
| 306 | + { |
| 307 | + theURIParts[2] = QgsProject::instance()->readPath( theURIParts[2] ); |
| 308 | + } |
| 309 | + else if ( theURIParts[0] == "HDF5" ) |
| 310 | + { |
| 311 | + theURIParts[1] = QgsProject::instance()->readPath( theURIParts[1] ); |
| 312 | + } |
| 313 | + else if ( theURIParts[0] == "NITF_IM" ) |
| 314 | + { |
| 315 | + theURIParts[2] = QgsProject::instance()->readPath( theURIParts[2] ); |
| 316 | + } |
| 317 | + else if ( theURIParts[0] == "RADARSAT_2_CALIB" ) |
| 318 | + { |
| 319 | + theURIParts[2] = QgsProject::instance()->readPath( theURIParts[2] ); |
| 320 | + } |
| 321 | + mDataSource = theURIParts.join( ":" ); |
| 322 | + } |
294 | 323 | else
|
295 | 324 | {
|
296 | 325 | mDataSource = QgsProject::instance()->readPath( mDataSource );
|
@@ -488,6 +517,39 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
|
488 | 517 | urlDest.setQueryItems( urlSource.queryItems() );
|
489 | 518 | src = QString::fromAscii( urlDest.toEncoded() );
|
490 | 519 | }
|
| 520 | + else if ( !vlayer ) |
| 521 | + { |
| 522 | + QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( this ); |
| 523 | + // Update path for subdataset |
| 524 | + if ( rlayer && rlayer->providerType() == "gdal" ) |
| 525 | + { |
| 526 | + QStringList theURIParts = src.split( ":" ); |
| 527 | + if ( theURIParts[0] == "NETCDF" ) |
| 528 | + { |
| 529 | + src = theURIParts[1]; |
| 530 | + src.replace( "\"", "" ); |
| 531 | + src = QgsProject::instance()->writePath( src, relativeBasePath ); |
| 532 | + theURIParts[1] = "\"" + src + "\""; |
| 533 | + } |
| 534 | + else if ( theURIParts[0] == "HDF4_SDS" ) |
| 535 | + { |
| 536 | + theURIParts[2] = QgsProject::instance()->writePath( theURIParts[2], relativeBasePath ); |
| 537 | + } |
| 538 | + else if ( theURIParts[0] == "HDF5" ) |
| 539 | + { |
| 540 | + theURIParts[1] = QgsProject::instance()->writePath( theURIParts[1], relativeBasePath ); |
| 541 | + } |
| 542 | + else if ( theURIParts[0] == "NITF_IM" ) |
| 543 | + { |
| 544 | + theURIParts[2] = QgsProject::instance()->writePath( theURIParts[2], relativeBasePath ); |
| 545 | + } |
| 546 | + else if ( theURIParts[0] == "RADARSAT_2_CALIB" ) |
| 547 | + { |
| 548 | + theURIParts[2] = QgsProject::instance()->writePath( theURIParts[2], relativeBasePath ); |
| 549 | + } |
| 550 | + src = theURIParts.join( ":" ); |
| 551 | + } |
| 552 | + } |
491 | 553 | else
|
492 | 554 | {
|
493 | 555 | src = QgsProject::instance()->writePath( src, relativeBasePath );
|
|
0 commit comments