Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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,
  • Loading branch information
brushtyler committed Dec 5, 2012
1 parent de3ea74 commit ce31f37
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmake/FindSPATIALITE.cmake
Expand Up @@ -64,7 +64,7 @@ IF (SPATIALITE_FOUND)
ENDIF (NOT SPATIALITE_FIND_QUIETLY)

# Check for symbol gaiaDropTable
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_RECENT_VERSION)
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_VERSION_GE_4_0_0)

ELSE (SPATIALITE_FOUND)

Expand Down
6 changes: 3 additions & 3 deletions src/providers/spatialite/CMakeLists.txt
Expand Up @@ -24,9 +24,9 @@ SET(SPATIALITE_MOC_HDRS

QT4_WRAP_CPP(SPATIALITE_MOC_SRCS ${SPATIALITE_MOC_HDRS})

IF(SPATIALITE_RECENT_VERSION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_RECENT_VERSION")
ENDIF(SPATIALITE_RECENT_VERSION)
IF(SPATIALITE_VERSION_GE_4_0_0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_VERSION_GE_4_0_0")
ENDIF(SPATIALITE_VERSION_GE_4_0_0)


INCLUDE_DIRECTORIES(
Expand Down
18 changes: 8 additions & 10 deletions src/providers/spatialite/qgsspatialiteconnection.cpp
Expand Up @@ -79,7 +79,7 @@ QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGe
}

bool recentVersion = false;
#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
recentVersion = true;
#endif
Expand All @@ -91,7 +91,7 @@ QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGe
return FailedToCheckMetadata;
}

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

bool QgsSpatiaLiteConnection::updateStatistics()
{
#ifdef SPATIALITE_VERSION_GE_4_0_0
QFileInfo fi( mPath );
if ( !fi.exists() )
{
Expand All @@ -126,17 +127,14 @@ bool QgsSpatiaLiteConnection::updateStatistics()
return false;
}

// checking the library version
bool recentVersion = false;
const char *version = spatialite_version();
if ( isdigit( *version ) && *version >= '4' )
recentVersion = true;

bool ret = update_layer_statistics( handle, NULL, NULL );

closeSpatiaLiteDb( handle );

return ret;
#else
return false;
#endif
}

sqlite3 *QgsSpatiaLiteConnection::openSpatiaLiteDb( QString path )
Expand Down Expand Up @@ -251,7 +249,7 @@ int QgsSpatiaLiteConnection::checkHasMetadataTables( sqlite3* handle )
sqlite3_free_table( results );
if ( srsSrid && authName && authSrid && refSysName && proj4text )
rsSpatiaLite = true;
if ( srsSrid && authName && authSrid && refSysName && proj4text )
if ( srsSrid && authName && authSrid && refSysName && proj4text && srtext )
rsSpatiaLite4 = true;

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

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
bool QgsSpatiaLiteConnection::getTableInfoAbstractInterface( sqlite3 * handle, bool loadGeometrylessTables )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteconnection.h
Expand Up @@ -85,7 +85,7 @@ class QgsSpatiaLiteConnection : public QObject
/**Inserts information about the spatial tables into mTables*/
bool getTableInfo( sqlite3 * handle, bool loadGeometrylessTables );

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
/**
Inserts information about the spatial tables into mTables
Expand Down
14 changes: 7 additions & 7 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -437,7 +437,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
bool alreadyDone = false;
bool ret;

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

alreadyDone = false;

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
if ( lyr != NULL )
{
// using the v.4.0 AbstractInterface
Expand Down Expand Up @@ -571,7 +571,7 @@ QgsSpatiaLiteProvider::~QgsSpatiaLiteProvider()
closeDb();
}

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr )
{
Expand Down Expand Up @@ -4362,7 +4362,7 @@ QString QgsSpatiaLiteProvider::quotedValue( QString value )
return value.prepend( "'" ).append( "'" );
}

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface( gaiaVectorLayerPtr lyr )
{
Expand Down Expand Up @@ -4589,7 +4589,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
return count == 1;
}

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface( gaiaVectorLayerPtr lyr )
{
Expand Down Expand Up @@ -5125,7 +5125,7 @@ bool QgsSpatiaLiteProvider::getSridDetails()
return false;
}

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

#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
{
// if libspatialite is v.4.0 (or higher) using the internal library
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteprovider.h
Expand Up @@ -409,7 +409,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
bool getQueryGeometryDetails();
bool getSridDetails();
bool getTableSummary();
#ifdef SPATIALITE_RECENT_VERSION
#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0
bool checkLayerTypeAbstractInterface( gaiaVectorLayerPtr lyr );
bool getGeometryDetailsAbstractInterface( gaiaVectorLayerPtr lyr );
Expand Down

0 comments on commit ce31f37

Please sign in to comment.