Skip to content

Commit 546c2de

Browse files
tqhienjef-n
authored andcommitted
Fix Blocker issue 8487
Custom CRS are saved if cannot find an existing one with same parameters (except datum which may be optionnal, as GDAL seems to have drop it)
1 parent 9c8bc7d commit 546c2de

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/core/qgscoordinatereferencesystem.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
593593
}
594594
}
595595

596+
QStringList myParam;
596597
if ( myRecord.empty() )
597598
{
598599
// match all parameters individually:
@@ -618,6 +619,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
618619
{
619620
sql += delim + arg;
620621
delim = " AND ";
622+
myParam.append(param);
621623
}
622624
}
623625

@@ -637,9 +639,26 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
637639
{
638640
mySrsId = myRecord["srs_id"].toLong();
639641
QgsDebugMsg( "proj4string param match search for srsid returned srsid: " + QString::number( mySrsId ) );
640-
if ( mySrsId > 0 )
642+
// Bugfix 8487 : test param lists are equal, except for +datum
643+
myParam.sort();
644+
QStringList foundParam;
645+
foreach ( QString paramfound, myRecord["parameters"].split( QRegExp( "\\s+(?=\\+)" ), QString::SkipEmptyParts ) )
641646
{
642-
createFromSrsId( mySrsId );
647+
if ( !paramfound.startsWith( "+datum=" ) )
648+
foundParam.append(paramfound);
649+
}
650+
foundParam.sort();
651+
if ( myParam == foundParam)
652+
{
653+
if ( mySrsId > 0 )
654+
{
655+
createFromSrsId( mySrsId );
656+
}
657+
}
658+
else
659+
{
660+
// Params differ
661+
mIsValidFlag = false;
643662
}
644663
}
645664
else

0 commit comments

Comments
 (0)