Skip to content

Commit

Permalink
check validity of CRS before saving
Browse files Browse the repository at this point in the history
  • Loading branch information
leyan committed May 4, 2013
1 parent c5a8ab6 commit 60b4369
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 60b4369

Please sign in to comment.