Skip to content
Permalink
Browse files

check validity of CRS before saving

  • Loading branch information
leyan committed May 4, 2013
1 parent c5a8ab6 commit 60b4369bf67beb10bc7b42588a2b6b4d62e2ab99
Showing with 17 additions and 9 deletions.
  1. +16 −9 src/app/qgscustomprojectiondialog.cpp
  2. +1 −0 src/core/qgscoordinatereferencesystem.cpp
@@ -395,6 +395,17 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
}

QgsDebugMsg( "We save the modified CRS." );

//Check if all CRS are valid:
for( size_t i = 0; i < customCRSids.size(); ++i )
{
if( customCRSparameters[i].isValid()==false )
{
QMessageBox::information( this, tr( "QGIS Custom Projection" ),
tr( "The proj4 definition of '%1' is not valid." ).arg(customCRSnames[i]) );
return;
}
}
//Modify the CRS changed:
bool save_success;
for( size_t i = 0; i < customCRSids.size(); ++i )
@@ -403,22 +414,18 @@ void QgsCustomProjectionDialog::on_buttonBox_accepted()
if( customCRSids[i] == "" )
{
save_success = save_success && saveCRS( customCRSparameters[i],customCRSnames[i], "", true);
if( ! save_success )
{
QgsDebugMsg( QString( "Problem for layer %1" ).arg( customCRSparameters[i].toProj4() ));
}
}
else
{
if ( existingCRSnames[customCRSids[i]]!=customCRSnames[i] || existingCRSparameters[customCRSids[i]].toProj4() != customCRSparameters[i].toProj4() )
{
save_success = save_success && saveCRS(customCRSparameters[i], customCRSnames[i], customCRSids[i], false );
if( ! save_success )
{
QgsDebugMsg( QString( "Problem for layer %1" ).arg( customCRSparameters[i].toProj4() ));
}
save_success = save_success && saveCRS(customCRSparameters[i], customCRSnames[i], customCRSids[i], false );
}
}
if( ! save_success )
{
QgsDebugMsg( QString( "Error when saving CRS '%1'" ).arg( customCRSnames[i] ));
}
}
QgsDebugMsg( "We remove the deleted CRS." );
for( size_t i = 0; i < deletedCRSs.size(); ++i )
@@ -663,6 +663,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
if ( !mIsValidFlag )
{
QgsDebugMsg( "Projection is not found in databases." );
//setProj4String will set mIsValidFlag to true if there is no issue
setProj4String( myProj4String );
}

0 comments on commit 60b4369

Please sign in to comment.
You can’t perform that action at this time.