Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cleanup on e50f042
  • Loading branch information
jef-n committed Sep 15, 2013
1 parent 078a941 commit 5d60b28
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -593,7 +593,6 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
}
}

QStringList myParam;
if ( myRecord.empty() )
{
// match all parameters individually:
Expand All @@ -608,6 +607,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
// split on spaces followed by a plus sign (+) to deal
// also with parameters containing spaces (e.g. +nadgrids)
// make sure result is trimmed (#5598)
QStringList myParams;
foreach ( QString param, myProj4String.split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
{
QString arg = QString( "' '||parameters||' ' LIKE %1" ).arg( quotedValue( QString( "% %1 %" ).arg( param.trimmed() ) ) );
Expand All @@ -619,7 +619,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
{
sql += delim + arg;
delim = " AND ";
myParam.append(param);
myParams << param.trimmed();
}
}

Expand All @@ -633,32 +633,34 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
// datum might have disappeared in definition - retry without it
myRecord = getRecord( sql + " order by deprecated" );
}

if ( !myRecord.empty() )
{
// Bugfix 8487 : test param lists are equal, except for +datum
QStringList foundParams;
foreach ( QString param, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
{
if ( !param.startsWith( "+datum=" ) )
foundParams << param.trimmed();
}

myParams.sort();
foundParams.sort();

if ( myParams != foundParams )
{
myRecord.clear();
}
}
}

if ( !myRecord.empty() )
{
mySrsId = myRecord["srs_id"].toLong();
QgsDebugMsg( "proj4string param match search for srsid returned srsid: " + QString::number( mySrsId ) );
// Bugfix 8487 : test param lists are equal, except for +datum
myParam.sort();
QStringList foundParam;
foreach ( QString paramfound, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
{
if ( !paramfound.startsWith( "+datum=" ) )
foundParam.append(paramfound);
}
foundParam.sort();
if ( myParam == foundParam)
{
if ( mySrsId > 0 )
{
createFromSrsId( mySrsId );
}
}
else
if ( mySrsId > 0 )
{
// Params differ
mIsValidFlag = false;
createFromSrsId( mySrsId );
}
}
else
Expand Down

0 comments on commit 5d60b28

Please sign in to comment.