@@ -49,7 +49,7 @@ bool QgsOSMDatabase::open()
49
49
int res = QgsSLConnect::sqlite3_open_v2 ( mDbFileName .toUtf8 ().data (), &mDatabase , SQLITE_OPEN_READWRITE, nullptr );
50
50
if ( res != SQLITE_OK )
51
51
{
52
- mError = QString ( " Failed to open database [%1]: %2" ).arg ( res ).arg ( mDbFileName );
52
+ mError = QStringLiteral ( " Failed to open database [%1]: %2" ).arg ( res ).arg ( mDbFileName );
53
53
close ();
54
54
return false ;
55
55
}
@@ -180,7 +180,7 @@ QList<QgsOSMTagCountPair> QgsOSMDatabase::usedTags( bool ways ) const
180
180
{
181
181
QList<QgsOSMTagCountPair> pairs;
182
182
183
- QString sql = QString ( " SELECT k, count(k) FROM %1_tags GROUP BY k" ).arg ( ways ? " ways" : " nodes" );
183
+ QString sql = QStringLiteral ( " SELECT k, count(k) FROM %1_tags GROUP BY k" ).arg ( ways ? " ways" : " nodes" );
184
184
185
185
sqlite3_stmt* stmt;
186
186
if ( sqlite3_prepare_v2 ( mDatabase , sql.toUtf8 ().data (), -1 , &stmt, nullptr ) != SQLITE_OK )
@@ -281,7 +281,7 @@ bool QgsOSMDatabase::prepareStatements()
281
281
if ( sqlite3_prepare_v2 ( mDatabase , sql[i], -1 , sqlite[i], nullptr ) != SQLITE_OK )
282
282
{
283
283
const char * errMsg = sqlite3_errmsg ( mDatabase ); // does not require free
284
- mError = QString ( " Error preparing SQL command:\n %1\n SQL:\n %2" )
284
+ mError = QStringLiteral ( " Error preparing SQL command:\n %1\n SQL:\n %2" )
285
285
.arg ( QString::fromUtf8 ( errMsg ), QString::fromUtf8 ( sql[i] ) );
286
286
return false ;
287
287
}
@@ -299,9 +299,9 @@ bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName
299
299
// create SpatiaLite table
300
300
301
301
QString geometryType;
302
- if ( type == Point ) geometryType = " POINT" ;
303
- else if ( type == Polyline ) geometryType = " LINESTRING" ;
304
- else if ( type == Polygon ) geometryType = " POLYGON" ;
302
+ if ( type == Point ) geometryType = QStringLiteral ( " POINT" ) ;
303
+ else if ( type == Polyline ) geometryType = QStringLiteral ( " LINESTRING" ) ;
304
+ else if ( type == Polygon ) geometryType = QStringLiteral ( " POLYGON" ) ;
305
305
else Q_ASSERT ( false && " Unknown export type" );
306
306
307
307
if ( !createSpatialTable ( tableName, geometryType, tagKeys ) )
@@ -333,9 +333,9 @@ bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName
333
333
334
334
bool QgsOSMDatabase::createSpatialTable ( const QString& tableName, const QString& geometryType, const QStringList& tagKeys )
335
335
{
336
- QString sqlCreateTable = QString ( " CREATE TABLE %1 (id INTEGER PRIMARY KEY" ).arg ( quotedIdentifier ( tableName ) );
336
+ QString sqlCreateTable = QStringLiteral ( " CREATE TABLE %1 (id INTEGER PRIMARY KEY" ).arg ( quotedIdentifier ( tableName ) );
337
337
for ( int i = 0 ; i < tagKeys.count (); ++i )
338
- sqlCreateTable += QString ( " , %1 TEXT" ).arg ( quotedIdentifier ( tagKeys[i] ) );
338
+ sqlCreateTable += QStringLiteral ( " , %1 TEXT" ).arg ( quotedIdentifier ( tagKeys[i] ) );
339
339
sqlCreateTable += ' )' ;
340
340
341
341
char *errMsg = nullptr ;
@@ -347,7 +347,7 @@ bool QgsOSMDatabase::createSpatialTable( const QString& tableName, const QString
347
347
return false ;
348
348
}
349
349
350
- QString sqlAddGeomColumn = QString ( " SELECT AddGeometryColumn(%1, 'geometry', 4326, %2, 'XY')" )
350
+ QString sqlAddGeomColumn = QStringLiteral ( " SELECT AddGeometryColumn(%1, 'geometry', 4326, %2, 'XY')" )
351
351
.arg ( quotedValue ( tableName ),
352
352
quotedValue ( geometryType ) );
353
353
ret = sqlite3_exec ( mDatabase , sqlAddGeomColumn.toUtf8 ().constData (), nullptr , nullptr , &errMsg );
@@ -364,7 +364,7 @@ bool QgsOSMDatabase::createSpatialTable( const QString& tableName, const QString
364
364
365
365
bool QgsOSMDatabase::createSpatialIndex ( const QString& tableName )
366
366
{
367
- QString sqlSpatialIndex = QString ( " SELECT CreateSpatialIndex(%1, 'geometry')" ).arg ( quotedValue ( tableName ) );
367
+ QString sqlSpatialIndex = QStringLiteral ( " SELECT CreateSpatialIndex(%1, 'geometry')" ).arg ( quotedValue ( tableName ) );
368
368
char *errMsg = nullptr ;
369
369
int ret = sqlite3_exec ( mDatabase , sqlSpatialIndex.toUtf8 ().constData (), nullptr , nullptr , &errMsg );
370
370
if ( ret != SQLITE_OK )
@@ -380,14 +380,14 @@ bool QgsOSMDatabase::createSpatialIndex( const QString& tableName )
380
380
381
381
void QgsOSMDatabase::exportSpatiaLiteNodes ( const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys )
382
382
{
383
- QString sqlInsertPoint = QString ( " INSERT INTO %1 VALUES (?" ).arg ( quotedIdentifier ( tableName ) );
383
+ QString sqlInsertPoint = QStringLiteral ( " INSERT INTO %1 VALUES (?" ).arg ( quotedIdentifier ( tableName ) );
384
384
for ( int i = 0 ; i < tagKeys.count (); ++i )
385
- sqlInsertPoint += QString ( " ,?" );
386
- sqlInsertPoint += " , GeomFromWKB(?, 4326))" ;
385
+ sqlInsertPoint += QStringLiteral ( " ,?" );
386
+ sqlInsertPoint += QLatin1String ( " , GeomFromWKB(?, 4326))" ) ;
387
387
sqlite3_stmt* stmtInsert;
388
388
if ( sqlite3_prepare_v2 ( mDatabase , sqlInsertPoint.toUtf8 ().constData (), -1 , &stmtInsert, nullptr ) != SQLITE_OK )
389
389
{
390
- mError = " Prepare SELECT FROM nodes failed." ;
390
+ mError = QStringLiteral ( " Prepare SELECT FROM nodes failed." ) ;
391
391
return ;
392
392
}
393
393
@@ -428,7 +428,7 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
428
428
int insertRes = sqlite3_step ( stmtInsert );
429
429
if ( insertRes != SQLITE_DONE )
430
430
{
431
- mError = QString ( " Error inserting node %1 [%2]" ).arg ( n.id () ).arg ( insertRes );
431
+ mError = QStringLiteral ( " Error inserting node %1 [%2]" ).arg ( n.id () ).arg ( insertRes );
432
432
break ;
433
433
}
434
434
@@ -446,14 +446,14 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
446
446
{
447
447
Q_UNUSED ( tagKeys );
448
448
449
- QString sqlInsertLine = QString ( " INSERT INTO %1 VALUES (?" ).arg ( quotedIdentifier ( tableName ) );
449
+ QString sqlInsertLine = QStringLiteral ( " INSERT INTO %1 VALUES (?" ).arg ( quotedIdentifier ( tableName ) );
450
450
for ( int i = 0 ; i < tagKeys.count (); ++i )
451
- sqlInsertLine += QString ( " ,?" );
452
- sqlInsertLine += " , GeomFromWKB(?, 4326))" ;
451
+ sqlInsertLine += QStringLiteral ( " ,?" );
452
+ sqlInsertLine += QLatin1String ( " , GeomFromWKB(?, 4326))" ) ;
453
453
sqlite3_stmt* stmtInsert;
454
454
if ( sqlite3_prepare_v2 ( mDatabase , sqlInsertLine.toUtf8 ().constData (), -1 , &stmtInsert, nullptr ) != SQLITE_OK )
455
455
{
456
- mError = " Prepare SELECT FROM ways failed." ;
456
+ mError = QStringLiteral ( " Prepare SELECT FROM ways failed." ) ;
457
457
return ;
458
458
}
459
459
@@ -470,11 +470,11 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
470
470
471
471
bool isArea = ( polyline.first () == polyline.last () ); // closed way?
472
472
// filter out closed way that are not areas through tags
473
- if ( isArea && ( t.contains ( " highway" ) || t.contains ( " barrier" ) ) )
473
+ if ( isArea && ( t.contains ( QStringLiteral ( " highway" ) ) || t.contains ( QStringLiteral ( " barrier" ) ) ) )
474
474
{
475
475
// make sure tags that indicate areas are taken into consideration when deciding on a closed way is or isn't an area
476
476
// and allow for a closed way to be exported both as a polygon and a line in case both area and non-area tags are present
477
- if (( t.value ( " area" ) != " yes" && !t.contains ( " amenity" ) && !t.contains ( " landuse" ) && !t.contains ( " building" ) && !t.contains ( " natural" ) && !t.contains ( " leisure" ) && !t.contains ( " aeroway" ) ) || !closed )
477
+ if (( t.value ( QStringLiteral ( " area" ) ) != QLatin1String ( " yes" ) && !t.contains ( QStringLiteral ( " amenity" ) ) && !t.contains ( QStringLiteral ( " landuse" ) ) && !t.contains ( QStringLiteral ( " building" ) ) && !t.contains ( QStringLiteral ( " natural" ) ) && !t.contains ( QStringLiteral ( " leisure" ) ) && !t.contains ( QStringLiteral ( " aeroway" ) ) ) || !closed )
478
478
isArea = false ;
479
479
}
480
480
@@ -511,7 +511,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
511
511
int insertRes = sqlite3_step ( stmtInsert );
512
512
if ( insertRes != SQLITE_DONE )
513
513
{
514
- mError = QString ( " Error inserting way %1 [%2]" ).arg ( w.id () ).arg ( insertRes );
514
+ mError = QStringLiteral ( " Error inserting way %1 [%2]" ).arg ( w.id () ).arg ( insertRes );
515
515
break ;
516
516
}
517
517
@@ -526,17 +526,17 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
526
526
527
527
QString QgsOSMDatabase::quotedIdentifier ( QString id )
528
528
{
529
- id.replace ( ' \" ' , " \"\" " );
530
- return QString ( " \" %1\" " ).arg ( id );
529
+ id.replace ( ' \" ' , QLatin1String ( " \"\" " ) );
530
+ return QStringLiteral ( " \" %1\" " ).arg ( id );
531
531
}
532
532
533
533
QString QgsOSMDatabase::quotedValue ( QString value )
534
534
{
535
535
if ( value.isNull () )
536
- return " NULL" ;
536
+ return QStringLiteral ( " NULL" ) ;
537
537
538
- value.replace ( ' \' ' , " ''" );
539
- return QString ( " '%1'" ).arg ( value );
538
+ value.replace ( ' \' ' , QLatin1String ( " ''" ) );
539
+ return QStringLiteral ( " '%1'" ).arg ( value );
540
540
}
541
541
542
542
// /////////////////////////////////
0 commit comments