@@ -65,7 +65,7 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WFlag
65
65
if ( !customCRSnames.empty () )
66
66
{
67
67
leName->setText ( customCRSnames[0 ] );
68
- teParameters->setPlainText ( customCRSparameters[0 ]. toProj4 () );
68
+ teParameters->setPlainText ( customCRSparameters[0 ] );
69
69
leNameList->setCurrentItem ( leNameList->topLevelItem ( 0 ) );
70
70
}
71
71
@@ -113,7 +113,7 @@ void QgsCustomProjectionDialog::populateList()
113
113
114
114
crs.createFromProj4 ( parameters );
115
115
existingCRSnames[id] = name;
116
- existingCRSparameters[id] = crs;
116
+ existingCRSparameters[id] = crs. toProj4 () ;
117
117
118
118
newItem = new QTreeWidgetItem ( leNameList, QStringList ( ) );
119
119
newItem->setText ( QGIS_CRS_NAME_COLUMN, name );
@@ -241,6 +241,7 @@ bool QgsCustomProjectionDialog::saveCRS(QgsCoordinateReferenceSystem myCRS, QStr
241
241
int return_id;
242
242
QString myProjectionAcronym = myCRS.projectionAcronym ();
243
243
QString myEllipsoidAcronym = myCRS.ellipsoidAcronym ();
244
+ QgsDebugMsg ( QString (" Saving a CRS:%1, %2, %3" ).arg (myName).arg (myCRS.toProj4 ()).arg (newEntry) );
244
245
if ( newEntry )
245
246
{
246
247
return_id=myCRS.saveAsUserCRS (myName);
@@ -287,7 +288,7 @@ bool QgsCustomProjectionDialog::saveCRS(QgsCoordinateReferenceSystem myCRS, QStr
287
288
if (myResult != SQLITE_OK)
288
289
return false ;
289
290
}
290
- existingCRSparameters[myId] = myCRS;
291
+ existingCRSparameters[myId] = myCRS. toProj4 () ;
291
292
existingCRSnames[myId] = myName;
292
293
293
294
// If we have a projection acronym not in the user db previously, add it.
@@ -312,7 +313,7 @@ void QgsCustomProjectionDialog::on_pbnAdd_clicked()
312
313
newItem->setText ( QGIS_CRS_PARAMETERS_COLUMN, parameters.toProj4 ());
313
314
customCRSnames.push_back ( name );
314
315
customCRSids.push_back ( id);
315
- customCRSparameters.push_back ( parameters );
316
+ customCRSparameters.push_back ( parameters. toProj4 () );
316
317
leNameList->setCurrentItem ( newItem );
317
318
}
318
319
@@ -342,7 +343,7 @@ void QgsCustomProjectionDialog::on_leNameList_currentItemChanged( QTreeWidgetIte
342
343
{
343
344
previousIndex = leNameList->indexOfTopLevelItem ( previous );
344
345
customCRSnames[previousIndex] = leName->text ();
345
- customCRSparameters[previousIndex]. createFromProj4 ( teParameters->toPlainText () );
346
+ customCRSparameters[previousIndex] = teParameters->toPlainText ();
346
347
previous->setText ( QGIS_CRS_NAME_COLUMN, leName->text () );
347
348
previous->setText ( QGIS_CRS_PARAMETERS_COLUMN, teParameters->toPlainText () );
348
349
}
@@ -376,7 +377,7 @@ void QgsCustomProjectionDialog::on_pbnCopyCRS_clicked()
376
377
on_pbnAdd_clicked ();
377
378
}
378
379
teParameters->setPlainText ( srs.toProj4 () );
379
- customCRSparameters[leNameList->currentIndex ().row ()]. createFromProj4 ( srs.toProj4 () );
380
+ customCRSparameters[leNameList->currentIndex ().row ()] = srs.toProj4 ();
380
381
leNameList->currentItem ()->setText ( QGIS_CRS_PARAMETERS_COLUMN, srs.toProj4 () );
381
382
382
383
}
@@ -391,35 +392,38 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
391
392
if (i != -1 )
392
393
{
393
394
customCRSnames[i] = leName->text ();
394
- customCRSparameters[i]. createFromProj4 ( teParameters->toPlainText () );
395
+ customCRSparameters[i] = teParameters->toPlainText ();
395
396
}
396
397
397
398
QgsDebugMsg ( " We save the modified CRS." );
398
399
399
400
// Check if all CRS are valid:
401
+ QgsCoordinateReferenceSystem CRS;
400
402
for ( size_t i = 0 ; i < customCRSids.size (); ++i )
401
403
{
402
- if ( customCRSparameters[i].isValid ()==false )
404
+ CRS.createFromProj4 (customCRSparameters[i]);
405
+ if ( CRS.isValid ()==false )
403
406
{
404
407
QMessageBox::information ( this , tr ( " QGIS Custom Projection" ),
405
408
tr ( " The proj4 definition of '%1' is not valid." ).arg (customCRSnames[i]) );
406
409
return ;
407
410
}
408
411
}
409
412
// Modify the CRS changed:
410
- bool save_success;
413
+ bool save_success= true ;
411
414
for ( size_t i = 0 ; i < customCRSids.size (); ++i )
412
415
{
416
+ CRS.createFromProj4 (customCRSparameters[i]);
413
417
// Test if we just added this CRS (if it has no existing ID)
414
418
if ( customCRSids[i] == " " )
415
419
{
416
- save_success = save_success && saveCRS ( customCRSparameters[i] ,customCRSnames[i], " " , true );
420
+ save_success = save_success && saveCRS ( CRS ,customCRSnames[i], " " , true );
417
421
}
418
422
else
419
423
{
420
- if ( existingCRSnames[customCRSids[i]]!=customCRSnames[i] || existingCRSparameters[customCRSids[i]]. toProj4 () != customCRSparameters[i]. toProj4 () )
424
+ if ( existingCRSnames[customCRSids[i]]!=customCRSnames[i] || existingCRSparameters[customCRSids[i]] != customCRSparameters[i] )
421
425
{
422
- save_success = save_success && saveCRS (customCRSparameters[i] , customCRSnames[i], customCRSids[i], false );
426
+ save_success = save_success && saveCRS (CRS , customCRSnames[i], customCRSids[i], false );
423
427
}
424
428
}
425
429
if ( ! save_success )
@@ -433,7 +437,7 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
433
437
save_success=save_success && deleteCRS ( deletedCRSs[i] );
434
438
if ( ! save_success )
435
439
{
436
- QgsDebugMsg ( QString ( " Problem for layer %1 " ).arg ( customCRSparameters[i]. toProj4 () ));
440
+ QgsDebugMsg ( QString ( " Problem for layer '%1' " ).arg ( customCRSparameters[i] ));
437
441
}
438
442
}
439
443
if ( save_success )
0 commit comments