@@ -297,9 +297,9 @@ bool QgsOSMDatabase::prepareStatements()
297
297
return true ;
298
298
}
299
299
300
-
301
-
302
- bool QgsOSMDatabase::exportSpatiaLite ( ExportType type, const QString& tableName, const QStringList& tagKeys )
300
+ bool QgsOSMDatabase::exportSpatiaLite ( ExportType type, const QString& tableName,
301
+ const QStringList& tagKeys,
302
+ const QStringList& notNullTagKeys )
303
303
{
304
304
mError .clear ();
305
305
@@ -321,9 +321,9 @@ bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName
321
321
Q_UNUSED ( retX );
322
322
323
323
if ( type == Polyline || type == Polygon )
324
- exportSpatiaLiteWays ( type == Polygon, tableName, tagKeys );
324
+ exportSpatiaLiteWays ( type == Polygon, tableName, tagKeys, notNullTagKeys );
325
325
else if ( type == Point )
326
- exportSpatiaLiteNodes ( tableName, tagKeys );
326
+ exportSpatiaLiteNodes ( tableName, tagKeys, notNullTagKeys );
327
327
else
328
328
Q_ASSERT ( false && " Unknown export type" );
329
329
@@ -338,7 +338,7 @@ bool QgsOSMDatabase::exportSpatiaLite( ExportType type, const QString& tableName
338
338
}
339
339
340
340
341
- bool QgsOSMDatabase::createSpatialTable ( const QString& tableName, const QString& geometryType, const QStringList& tagKeys )
341
+ bool QgsOSMDatabase::createSpatialTable ( const QString& tableName, const QString& geometryType, const QStringList& tagKeys)
342
342
{
343
343
QString sqlCreateTable = QString ( " CREATE TABLE %1 (id INTEGER PRIMARY KEY" ).arg ( quotedIdentifier ( tableName ) );
344
344
for ( int i = 0 ; i < tagKeys.count (); ++i )
@@ -385,7 +385,7 @@ bool QgsOSMDatabase::createSpatialIndex( const QString& tableName )
385
385
}
386
386
387
387
388
- void QgsOSMDatabase::exportSpatiaLiteNodes ( const QString& tableName, const QStringList& tagKeys )
388
+ void QgsOSMDatabase::exportSpatiaLiteNodes ( const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys )
389
389
{
390
390
QString sqlInsertPoint = QString ( " INSERT INTO %1 VALUES (?" ).arg ( quotedIdentifier ( tableName ) );
391
391
for ( int i = 0 ; i < tagKeys.count (); ++i )
@@ -408,6 +408,11 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
408
408
if ( t.count () == 0 )
409
409
continue ;
410
410
411
+ // check not null tags
412
+ for ( int i = 0 ; i < notNullTagKeys.count (); ++i )
413
+ if ( !t.contains ( notNullTagKeys[i] ) )
414
+ continue ;
415
+
411
416
QgsGeometry* geom = QgsGeometry::fromPoint ( n.point () );
412
417
int col = 0 ;
413
418
sqlite3_bind_int64 ( stmtInsert, ++col, n.id () );
@@ -440,7 +445,9 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
440
445
}
441
446
442
447
443
- void QgsOSMDatabase::exportSpatiaLiteWays ( bool closed, const QString& tableName, const QStringList& tagKeys )
448
+ void QgsOSMDatabase::exportSpatiaLiteWays ( bool closed, const QString& tableName,
449
+ const QStringList& tagKeys,
450
+ const QStringList& notNullTagKeys)
444
451
{
445
452
Q_UNUSED ( tagKeys );
446
453
@@ -477,6 +484,16 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
477
484
if ( closed != isArea )
478
485
continue ; // skip if it's not what we're looking for
479
486
487
+ bool skipNull = false ;
488
+
489
+ // check not null tags
490
+ for ( int i = 0 ; i < notNullTagKeys.count () && skipNull == false ; ++i )
491
+ if ( !t.contains ( notNullTagKeys[i] ) )
492
+ skipNull = true ;
493
+
494
+ if (skipNull)
495
+ continue ;
496
+
480
497
QgsGeometry* geom = closed ? QgsGeometry::fromPolygon ( QgsPolygon () << polyline ) : QgsGeometry::fromPolyline ( polyline );
481
498
int col = 0 ;
482
499
sqlite3_bind_int64 ( stmtInsert, ++col, w.id () );
0 commit comments