28
28
#include < QRegExp>
29
29
#include < QTextStream>
30
30
#include < QFile>
31
+ #include < QRegularExpression>
31
32
32
33
#include " qgsapplication.h"
33
34
#include " qgslogger.h"
@@ -220,26 +221,28 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
220
221
sCrsStringLock .unlock ();
221
222
222
223
bool result = false ;
223
- QRegExp reCrsId ( " ^(epsg|postgis|internal|user)\\ :(\\ d+)$" , Qt::CaseInsensitive );
224
- if ( reCrsId.indexIn ( definition ) == 0 )
224
+ QRegularExpression reCrsId ( " ^(epsg|postgis|internal|user)\\ :(\\ d+)$" , QRegularExpression::CaseInsensitiveOption );
225
+ QRegularExpressionMatch match = reCrsId.match ( definition );
226
+ if ( match.capturedStart () == 0 )
225
227
{
226
- QString authName = reCrsId. cap ( 1 ).toLower ();
228
+ QString authName = match. captured ( 1 ).toLower ();
227
229
CrsType type = InternalCrsId;
228
230
if ( authName == QLatin1String ( " epsg" ) )
229
231
type = EpsgCrsId;
230
232
if ( authName == QLatin1String ( " postgis" ) )
231
233
type = PostgisCrsId;
232
- long id = reCrsId. cap ( 2 ).toLong ();
234
+ long id = match. captured ( 2 ).toLong ();
233
235
result = createFromId ( id, type );
234
236
}
235
237
else
236
238
{
237
- QRegExp reCrsStr ( " ^(?:(wkt|proj4)\\ :)?(.+)$" , Qt::CaseInsensitive );
238
- if ( reCrsStr.indexIn ( definition ) == 0 )
239
+ QRegularExpression reCrsStr ( " ^(?:(wkt|proj4)\\ :)?(.+)$" , QRegularExpression::CaseInsensitiveOption );
240
+ match = reCrsStr.match ( definition );
241
+ if ( match.capturedStart () == 0 )
239
242
{
240
- if ( reCrsStr. cap ( 1 ).toLower () == QLatin1String ( " proj4" ) )
243
+ if ( match. captured ( 1 ).toLower () == QLatin1String ( " proj4" ) )
241
244
{
242
- result = createFromProj4 ( reCrsStr. cap ( 2 ) );
245
+ result = createFromProj4 ( match. captured ( 2 ) );
243
246
// TODO: createFromProj4 used to save to the user database any new CRS
244
247
// this behavior was changed in order to separate creation and saving.
245
248
// Not sure if it necessary to save it here, should be checked by someone
@@ -254,7 +257,7 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
254
257
}
255
258
else
256
259
{
257
- result = createFromWkt ( reCrsStr. cap ( 2 ) );
260
+ result = createFromWkt ( match. captured ( 2 ) );
258
261
}
259
262
}
260
263
}
0 commit comments