Skip to content

Commit ce31f37

Browse files
committedDec 5, 2012
fix SL provider (follow 90972db):
fix build linking SL < v4, fix SL4 database version check, rename SPATIALITE_RECENT_VERSION macro to the more significant SPATIALITE_VERSION_GE_4_0_0,
1 parent de3ea74 commit ce31f37

6 files changed

+21
-23
lines changed
 

‎cmake/FindSPATIALITE.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ IF (SPATIALITE_FOUND)
6464
ENDIF (NOT SPATIALITE_FIND_QUIETLY)
6565

6666
# Check for symbol gaiaDropTable
67-
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_RECENT_VERSION)
67+
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_VERSION_GE_4_0_0)
6868

6969
ELSE (SPATIALITE_FOUND)
7070

‎src/providers/spatialite/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ SET(SPATIALITE_MOC_HDRS
2424

2525
QT4_WRAP_CPP(SPATIALITE_MOC_SRCS ${SPATIALITE_MOC_HDRS})
2626

27-
IF(SPATIALITE_RECENT_VERSION)
28-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_RECENT_VERSION")
29-
ENDIF(SPATIALITE_RECENT_VERSION)
27+
IF(SPATIALITE_VERSION_GE_4_0_0)
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_VERSION_GE_4_0_0")
29+
ENDIF(SPATIALITE_VERSION_GE_4_0_0)
3030

3131

3232
INCLUDE_DIRECTORIES(

‎src/providers/spatialite/qgsspatialiteconnection.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGe
7979
}
8080

8181
bool recentVersion = false;
82-
#ifdef SPATIALITE_RECENT_VERSION
82+
#ifdef SPATIALITE_VERSION_GE_4_0_0
8383
// only if libspatialite version is >= 4.0.0
8484
recentVersion = true;
8585
#endif
@@ -91,7 +91,7 @@ QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGe
9191
return FailedToCheckMetadata;
9292
}
9393

94-
#ifdef SPATIALITE_RECENT_VERSION
94+
#ifdef SPATIALITE_VERSION_GE_4_0_0
9595
// only if libspatialite version is >= 4.0.0
9696
// using v.4.0 Abstract Interface
9797
if ( !getTableInfoAbstractInterface( handle, loadGeometrylessTables ) )
@@ -114,6 +114,7 @@ QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGe
114114

115115
bool QgsSpatiaLiteConnection::updateStatistics()
116116
{
117+
#ifdef SPATIALITE_VERSION_GE_4_0_0
117118
QFileInfo fi( mPath );
118119
if ( !fi.exists() )
119120
{
@@ -126,17 +127,14 @@ bool QgsSpatiaLiteConnection::updateStatistics()
126127
return false;
127128
}
128129

129-
// checking the library version
130-
bool recentVersion = false;
131-
const char *version = spatialite_version();
132-
if ( isdigit( *version ) && *version >= '4' )
133-
recentVersion = true;
134-
135130
bool ret = update_layer_statistics( handle, NULL, NULL );
136131

137132
closeSpatiaLiteDb( handle );
138133

139134
return ret;
135+
#else
136+
return false;
137+
#endif
140138
}
141139

142140
sqlite3 *QgsSpatiaLiteConnection::openSpatiaLiteDb( QString path )
@@ -251,7 +249,7 @@ int QgsSpatiaLiteConnection::checkHasMetadataTables( sqlite3* handle )
251249
sqlite3_free_table( results );
252250
if ( srsSrid && authName && authSrid && refSysName && proj4text )
253251
rsSpatiaLite = true;
254-
if ( srsSrid && authName && authSrid && refSysName && proj4text )
252+
if ( srsSrid && authName && authSrid && refSysName && proj4text && srtext )
255253
rsSpatiaLite4 = true;
256254

257255
// OK, this one seems to be a valid SpatiaLite DB
@@ -274,7 +272,7 @@ int QgsSpatiaLiteConnection::checkHasMetadataTables( sqlite3* handle )
274272
return false;
275273
}
276274

277-
#ifdef SPATIALITE_RECENT_VERSION
275+
#ifdef SPATIALITE_VERSION_GE_4_0_0
278276
// only if libspatialite version is >= 4.0.0
279277
bool QgsSpatiaLiteConnection::getTableInfoAbstractInterface( sqlite3 * handle, bool loadGeometrylessTables )
280278
{

‎src/providers/spatialite/qgsspatialiteconnection.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class QgsSpatiaLiteConnection : public QObject
8585
/**Inserts information about the spatial tables into mTables*/
8686
bool getTableInfo( sqlite3 * handle, bool loadGeometrylessTables );
8787

88-
#ifdef SPATIALITE_RECENT_VERSION
88+
#ifdef SPATIALITE_VERSION_GE_4_0_0
8989
// only if libspatialite version is >= 4.0.0
9090
/**
9191
Inserts information about the spatial tables into mTables

‎src/providers/spatialite/qgsspatialiteprovider.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
437437
bool alreadyDone = false;
438438
bool ret;
439439

440-
#ifdef SPATIALITE_RECENT_VERSION
440+
#ifdef SPATIALITE_VERSION_GE_4_0_0
441441
// only if libspatialite version is >= 4.0.0
442442
gaiaVectorLayersListPtr list = NULL;
443443
gaiaVectorLayerPtr lyr = NULL;
@@ -497,7 +497,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
497497

498498
alreadyDone = false;
499499

500-
#ifdef SPATIALITE_RECENT_VERSION
500+
#ifdef SPATIALITE_VERSION_GE_4_0_0
501501
if ( lyr != NULL )
502502
{
503503
// using the v.4.0 AbstractInterface
@@ -571,7 +571,7 @@ QgsSpatiaLiteProvider::~QgsSpatiaLiteProvider()
571571
closeDb();
572572
}
573573

574-
#ifdef SPATIALITE_RECENT_VERSION
574+
#ifdef SPATIALITE_VERSION_GE_4_0_0
575575
// only if libspatialite version is >= 4.0.0
576576
void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr )
577577
{
@@ -4362,7 +4362,7 @@ QString QgsSpatiaLiteProvider::quotedValue( QString value )
43624362
return value.prepend( "'" ).append( "'" );
43634363
}
43644364

4365-
#ifdef SPATIALITE_RECENT_VERSION
4365+
#ifdef SPATIALITE_VERSION_GE_4_0_0
43664366
// only if libspatialite version is >= 4.0.0
43674367
bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface( gaiaVectorLayerPtr lyr )
43684368
{
@@ -4589,7 +4589,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
45894589
return count == 1;
45904590
}
45914591

4592-
#ifdef SPATIALITE_RECENT_VERSION
4592+
#ifdef SPATIALITE_VERSION_GE_4_0_0
45934593
// only if libspatialite version is >= 4.0.0
45944594
bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface( gaiaVectorLayerPtr lyr )
45954595
{
@@ -5125,7 +5125,7 @@ bool QgsSpatiaLiteProvider::getSridDetails()
51255125
return false;
51265126
}
51275127

5128-
#ifdef SPATIALITE_RECENT_VERSION
5128+
#ifdef SPATIALITE_VERSION_GE_4_0_0
51295129
// only if libspatialite version is >= 4.0.0
51305130
bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr lyr )
51315131
{
@@ -5363,7 +5363,7 @@ QGISEXTERN bool deleteLayer( const QString& dbPath, const QString& tableName, QS
53635363
}
53645364
sqlite3* sqlite_handle = hndl->handle();
53655365

5366-
#ifdef SPATIALITE_RECENT_VERSION
5366+
#ifdef SPATIALITE_VERSION_GE_4_0_0
53675367
// only if libspatialite version is >= 4.0.0
53685368
{
53695369
// if libspatialite is v.4.0 (or higher) using the internal library

‎src/providers/spatialite/qgsspatialiteprovider.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
409409
bool getQueryGeometryDetails();
410410
bool getSridDetails();
411411
bool getTableSummary();
412-
#ifdef SPATIALITE_RECENT_VERSION
412+
#ifdef SPATIALITE_VERSION_GE_4_0_0
413413
// only if libspatialite version is >= 4.0.0
414414
bool checkLayerTypeAbstractInterface( gaiaVectorLayerPtr lyr );
415415
bool getGeometryDetailsAbstractInterface( gaiaVectorLayerPtr lyr );

0 commit comments

Comments
 (0)