@@ -443,22 +443,22 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
443
443
gaiaVectorLayerPtr lyr = NULL ;
444
444
bool specialCase = false ;
445
445
if ( mGeometryColumn .isNull () )
446
- specialCase = true ; // non-spatial table
446
+ specialCase = true ; // non-spatial table
447
447
if ( mQuery .startsWith ( " (" ) && mQuery .endsWith ( " )" ) )
448
- specialCase = true ;
448
+ specialCase = true ;
449
449
450
450
if ( specialCase == false )
451
451
{
452
452
// using v.4.0 Abstract Interface
453
453
ret = true ;
454
- list = gaiaGetVectorLayersList ( handle->handle (),
455
- mTableName .toUtf8 ().constData (),
456
- mGeometryColumn .toUtf8 ().constData (),
457
- GAIA_VECTORS_LIST_OPTIMISTIC);
454
+ list = gaiaGetVectorLayersList ( handle->handle (),
455
+ mTableName .toUtf8 ().constData (),
456
+ mGeometryColumn .toUtf8 ().constData (),
457
+ GAIA_VECTORS_LIST_OPTIMISTIC );
458
458
if ( list != NULL )
459
- lyr = list->First ;
459
+ lyr = list->First ;
460
460
if ( lyr == NULL )
461
- ret = false ;
461
+ ret = false ;
462
462
else
463
463
{
464
464
ret = checkLayerTypeAbstractInterface ( lyr );
@@ -501,53 +501,54 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
501
501
if ( lyr != NULL )
502
502
{
503
503
// using the v.4.0 AbstractInterface
504
- if ( !getGeometryDetailsAbstractInterface ( lyr ) ) // gets srid and geometry type
505
- {
506
- // the table is not a geometry table
507
- numberFeatures = 0 ;
508
- valid = false ;
509
- QgsDebugMsg ( " Invalid SpatiaLite layer" );
510
- closeDb ();
511
- gaiaFreeVectorLayersList ( list );
512
- return ;
513
- }
514
- if ( !getTableSummaryAbstractInterface ( lyr ) ) // gets the extent and feature count
515
- {
516
- numberFeatures = 0 ;
517
- valid = false ;
518
- QgsDebugMsg ( " Invalid SpatiaLite layer" );
519
- closeDb ();
520
- gaiaFreeVectorLayersList ( list );
521
- return ;
522
- }
523
- // load the columns list
524
- loadFieldsAbstractInterface ( lyr );
525
- gaiaFreeVectorLayersList ( list );
526
- alreadyDone = true ;
504
+ if ( !getGeometryDetailsAbstractInterface ( lyr ) ) // gets srid and geometry type
505
+ {
506
+ // the table is not a geometry table
507
+ numberFeatures = 0 ;
508
+ valid = false ;
509
+ QgsDebugMsg ( " Invalid SpatiaLite layer" );
510
+ closeDb ();
511
+ gaiaFreeVectorLayersList ( list );
512
+ return ;
513
+ }
514
+ if ( !getTableSummaryAbstractInterface ( lyr ) ) // gets the extent and feature count
515
+ {
516
+ numberFeatures = 0 ;
517
+ valid = false ;
518
+ QgsDebugMsg ( " Invalid SpatiaLite layer" );
519
+ closeDb ();
520
+ gaiaFreeVectorLayersList ( list );
521
+ return ;
522
+ }
523
+ // load the columns list
524
+ loadFieldsAbstractInterface ( lyr );
525
+ gaiaFreeVectorLayersList ( list );
526
+ alreadyDone = true ;
527
527
}
528
528
#endif
529
529
530
- if ( alreadyDone == false ) {
530
+ if ( alreadyDone == false )
531
+ {
531
532
// using the traditional methods
532
- if ( !getGeometryDetails () ) // gets srid and geometry type
533
- {
534
- // the table is not a geometry table
535
- numberFeatures = 0 ;
536
- valid = false ;
537
- QgsDebugMsg ( " Invalid SpatiaLite layer" );
538
- closeDb ();
539
- return ;
540
- }
541
- if ( !getTableSummary () ) // gets the extent and feature count
542
- {
543
- numberFeatures = 0 ;
544
- valid = false ;
545
- QgsDebugMsg ( " Invalid SpatiaLite layer" );
546
- closeDb ();
547
- return ;
548
- }
549
- // load the columns list
550
- loadFields ();
533
+ if ( !getGeometryDetails () ) // gets srid and geometry type
534
+ {
535
+ // the table is not a geometry table
536
+ numberFeatures = 0 ;
537
+ valid = false ;
538
+ QgsDebugMsg ( " Invalid SpatiaLite layer" );
539
+ closeDb ();
540
+ return ;
541
+ }
542
+ if ( !getTableSummary () ) // gets the extent and feature count
543
+ {
544
+ numberFeatures = 0 ;
545
+ valid = false ;
546
+ QgsDebugMsg ( " Invalid SpatiaLite layer" );
547
+ closeDb ();
548
+ return ;
549
+ }
550
+ // load the columns list
551
+ loadFields ();
551
552
}
552
553
if ( sqliteHandle == NULL )
553
554
{
@@ -580,7 +581,7 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
580
581
}
581
582
582
583
attributeFields.clear ();
583
- mPrimaryKey .clear (); // cazzo cazzo cazzo
584
+ mPrimaryKey .clear (); // cazzo cazzo cazzo
584
585
585
586
gaiaLayerAttributeFieldPtr fld = lyr->First ;
586
587
if ( fld == NULL )
@@ -597,7 +598,7 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
597
598
if ( name != mGeometryColumn )
598
599
{
599
600
const char *type = " TEXT" ;
600
- QVariant::Type fieldType = QVariant::String; // default: SQLITE_TEXT
601
+ QVariant::Type fieldType = QVariant::String; // default: SQLITE_TEXT
601
602
if ( fld->IntegerValuesCount != 0 && fld->DoubleValuesCount == 0 &&
602
603
fld->TextValuesCount == 0 && fld->BlobValuesCount == 0 )
603
604
{
@@ -4362,7 +4363,7 @@ QString QgsSpatiaLiteProvider::quotedValue( QString value )
4362
4363
}
4363
4364
4364
4365
#ifdef SPATIALITE_RECENT_VERSION
4365
- // only if libspatialite version is >= 4.0.0
4366
+ // only if libspatialite version is >= 4.0.0
4366
4367
bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface ( gaiaVectorLayerPtr lyr )
4367
4368
{
4368
4369
if ( lyr == NULL )
@@ -4379,24 +4380,24 @@ bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface( gaiaVectorLayerPtr
4379
4380
switch ( lyr->LayerType )
4380
4381
{
4381
4382
case GAIA_VECTOR_TABLE:
4382
- mTableBased = true ;
4383
- break ;
4383
+ mTableBased = true ;
4384
+ break ;
4384
4385
case GAIA_VECTOR_VIEW:
4385
- mViewBased = true ;
4386
- break ;
4386
+ mViewBased = true ;
4387
+ break ;
4387
4388
case GAIA_VECTOR_VIRTUAL:
4388
- mVShapeBased = true ;
4389
- break ;
4389
+ mVShapeBased = true ;
4390
+ break ;
4390
4391
};
4391
4392
4392
4393
if ( lyr->AuthInfos )
4393
4394
{
4394
4395
if ( lyr->AuthInfos ->IsReadOnly )
4395
- mReadOnly = true ;
4396
+ mReadOnly = true ;
4396
4397
}
4397
- else if ( mViewBased == true )
4398
+ else if ( mViewBased == true )
4398
4399
{
4399
- mReadOnly = !hasTriggers ();
4400
+ mReadOnly = !hasTriggers ();
4400
4401
}
4401
4402
4402
4403
if ( !isQuery )
@@ -4589,7 +4590,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
4589
4590
}
4590
4591
4591
4592
#ifdef SPATIALITE_RECENT_VERSION
4592
- // only if libspatialite version is >= 4.0.0
4593
+ // only if libspatialite version is >= 4.0.0
4593
4594
bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface ( gaiaVectorLayerPtr lyr )
4594
4595
{
4595
4596
if ( lyr == NULL )
@@ -4600,29 +4601,29 @@ bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface( gaiaVectorLayer
4600
4601
mIndexTable = mTableName ;
4601
4602
mIndexGeometry = mGeometryColumn ;
4602
4603
4603
- switch (lyr->GeometryType )
4604
+ switch ( lyr->GeometryType )
4604
4605
{
4605
4606
case GAIA_VECTOR_POINT:
4606
- geomType = QGis::WKBPoint;
4607
- break ;
4607
+ geomType = QGis::WKBPoint;
4608
+ break ;
4608
4609
case GAIA_VECTOR_LINESTRING:
4609
- geomType = QGis::WKBLineString;
4610
- break ;
4610
+ geomType = QGis::WKBLineString;
4611
+ break ;
4611
4612
case GAIA_VECTOR_POLYGON:
4612
- geomType = QGis::WKBPolygon;
4613
- break ;
4613
+ geomType = QGis::WKBPolygon;
4614
+ break ;
4614
4615
case GAIA_VECTOR_MULTIPOINT:
4615
- geomType = QGis::WKBMultiPoint;
4616
- break ;
4616
+ geomType = QGis::WKBMultiPoint;
4617
+ break ;
4617
4618
case GAIA_VECTOR_MULTILINESTRING:
4618
- geomType = QGis::WKBMultiLineString;
4619
- break ;
4619
+ geomType = QGis::WKBMultiLineString;
4620
+ break ;
4620
4621
case GAIA_VECTOR_MULTIPOLYGON:
4621
- geomType = QGis::WKBMultiPolygon;
4622
- break ;
4622
+ geomType = QGis::WKBMultiPolygon;
4623
+ break ;
4623
4624
default :
4624
- geomType = QGis::WKBUnknown;
4625
- break ;
4625
+ geomType = QGis::WKBUnknown;
4626
+ break ;
4626
4627
};
4627
4628
mSrid = lyr->Srid ;
4628
4629
if ( lyr->SpatialIndex == GAIA_SPATIAL_INDEX_RTREE )
@@ -4636,17 +4637,17 @@ bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface( gaiaVectorLayer
4636
4637
switch ( lyr->Dimensions )
4637
4638
{
4638
4639
case GAIA_XY:
4639
- nDims = GAIA_XY;
4640
- break ;
4640
+ nDims = GAIA_XY;
4641
+ break ;
4641
4642
case GAIA_XY_Z:
4642
- nDims = GAIA_XY_Z;
4643
- break ;
4643
+ nDims = GAIA_XY_Z;
4644
+ break ;
4644
4645
case GAIA_XY_M:
4645
- nDims = GAIA_XY_M;
4646
- break ;
4646
+ nDims = GAIA_XY_M;
4647
+ break ;
4647
4648
case GAIA_XY_Z_M:
4648
- nDims = GAIA_XY_Z_M;
4649
- break ;
4649
+ nDims = GAIA_XY_Z_M;
4650
+ break ;
4650
4651
};
4651
4652
4652
4653
if ( mViewBased && spatialIndexRTree )
@@ -5125,7 +5126,7 @@ bool QgsSpatiaLiteProvider::getSridDetails()
5125
5126
}
5126
5127
5127
5128
#ifdef SPATIALITE_RECENT_VERSION
5128
- // only if libspatialite version is >= 4.0.0
5129
+ // only if libspatialite version is >= 4.0.0
5129
5130
bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface ( gaiaVectorLayerPtr lyr )
5130
5131
{
5131
5132
if ( lyr == NULL )
@@ -5367,21 +5368,21 @@ QGISEXTERN bool deleteLayer( const QString& dbPath, const QString& tableName, QS
5367
5368
{
5368
5369
// if libspatialite is v.4.0 (or higher) using the internal library
5369
5370
// method is highly recommended
5370
- if ( !gaiaDropTable ( sqlite_handle, tableName.toUtf8 ().constData () ) )
5371
- {
5372
- // unexpected error
5373
- errCause = QObject::tr ( " Unable to delete table %1\n " ).arg ( tableName );
5374
- QgsSpatiaLiteProvider::SqliteHandles::closeDb ( hndl );
5375
- return false ;
5376
- }
5377
- // run VACUUM to free unused space and compact the database
5378
- int ret = sqlite3_exec ( sqlite_handle, " VACUUM" , NULL , NULL , NULL );
5379
- if ( ret != SQLITE_OK )
5380
- {
5381
- QgsDebugMsg ( " Failed to run VACUUM after deleting table on database " + dbPath );
5382
- }
5371
+ if ( !gaiaDropTable ( sqlite_handle, tableName.toUtf8 ().constData () ) )
5372
+ {
5373
+ // unexpected error
5374
+ errCause = QObject::tr ( " Unable to delete table %1\n " ).arg ( tableName );
5383
5375
QgsSpatiaLiteProvider::SqliteHandles::closeDb ( hndl );
5384
- return true ;
5376
+ return false ;
5377
+ }
5378
+ // run VACUUM to free unused space and compact the database
5379
+ int ret = sqlite3_exec ( sqlite_handle, " VACUUM" , NULL , NULL , NULL );
5380
+ if ( ret != SQLITE_OK )
5381
+ {
5382
+ QgsDebugMsg ( " Failed to run VACUUM after deleting table on database " + dbPath );
5383
+ }
5384
+ QgsSpatiaLiteProvider::SqliteHandles::closeDb ( hndl );
5385
+ return true ;
5385
5386
}
5386
5387
#endif
5387
5388
0 commit comments