Skip to content

Commit

Permalink
debian packaging: switch to internal spatialite
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14764 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 25, 2010
1 parent cdae0f6 commit a16d598
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 65 deletions.
8 changes: 4 additions & 4 deletions debian/rules
Expand Up @@ -32,11 +32,11 @@ CMAKE_OPTS := \
-D WITH_MAPSERVER=TRUE \
-D QGIS_CGIBIN_SUBDIR=/usr/lib/cgi-bin

ifeq (,$(findstring $(DISTRIBUTION),"squeeze lucid maverick natty sid"))
#ifeq (,$(findstring $(DISTRIBUTION),"squeeze lucid maverick natty sid"))
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALITE=TRUE
else
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALITE=FALSE
endif
#else
# CMAKE_OPTS += -D WITH_INTERNAL_SPATIALITE=FALSE
#endif

ifneq (,$(findstring $(DISTRIBUTION),"hardy intrepid"))
LDFLAGS += -Wl,--as-needed -Wl,--no-undefined
Expand Down
62 changes: 31 additions & 31 deletions src/app/qgsnewspatialitelayerdialog.cpp
Expand Up @@ -187,7 +187,7 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
}
}

void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata(sqlite3 *sqlite_handle)
void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata( sqlite3 *sqlite_handle )
{
// attempting to perform self-initialization for a newly created DB
int ret;
Expand All @@ -199,37 +199,37 @@ void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata(sqlite3 *sqlite_hand
int rows;
int columns;

if (sqlite_handle == NULL)
if ( sqlite_handle == NULL )
return;
// checking if this DB is really empty
strcpy(sql, "SELECT Count(*) from sqlite_master");
ret = sqlite3_get_table(sqlite_handle, sql, &results, &rows, &columns, NULL);
if (ret != SQLITE_OK)
// checking if this DB is really empty
strcpy( sql, "SELECT Count(*) from sqlite_master" );
ret = sqlite3_get_table( sqlite_handle, sql, &results, &rows, &columns, NULL );
if ( ret != SQLITE_OK )
return;
if (rows < 1)
if ( rows < 1 )
;
else
{
for (i = 1; i <= rows; i++)
count = atoi(results[(i * columns) + 0]);
for ( i = 1; i <= rows; i++ )
count = atoi( results[( i * columns ) + 0] );
}
sqlite3_free_table(results);
sqlite3_free_table( results );

if (count > 0)
if ( count > 0 )
return;

// all right, it's empty: proceding to initialize
strcpy(sql, "SELECT InitSpatialMetadata()");
ret = sqlite3_exec(sqlite_handle, sql, NULL, NULL, &errMsg);
if (ret != SQLITE_OK)
strcpy( sql, "SELECT InitSpatialMetadata()" );
ret = sqlite3_exec( sqlite_handle, sql, NULL, NULL, &errMsg );
if ( ret != SQLITE_OK )
{
QString errCause = tr( "Unable to initialize SpatialMetedata:\n" );
errCause += QString::fromUtf8(errMsg);
errCause += QString::fromUtf8( errMsg );
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), errCause );
sqlite3_free(errMsg);
sqlite3_free( errMsg );
return;
}
spatial_ref_sys_init(sqlite_handle, 0);
spatial_ref_sys_init( sqlite_handle, 0 );
}

bool QgsNewSpatialiteLayerDialog::createDb()
Expand All @@ -256,32 +256,32 @@ bool QgsNewSpatialiteLayerDialog::createDb()

// creating/opening the new database
QString dbPath = newDb.fileName();
spatialite_init(0);
ret = sqlite3_open_v2(dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (ret)
spatialite_init( 0 );
ret = sqlite3_open_v2( dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
if ( ret )
{
// an error occurred
// an error occurred
QString errCause = tr( "Could not create a new database\n" );
errCause += QString::fromUtf8(sqlite3_errmsg(sqlite_handle));
sqlite3_close(sqlite_handle);
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), errCause );
errCause += QString::fromUtf8( sqlite3_errmsg( sqlite_handle ) );
sqlite3_close( sqlite_handle );
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), errCause );
pbnFindSRID->setEnabled( false );
return false;
}
// activating Foreign Key constraints
ret = sqlite3_exec(sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg);
if (ret != SQLITE_OK)
ret = sqlite3_exec( sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg );
if ( ret != SQLITE_OK )
{
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), tr( "Unable to activate FOREIGN_KEY constraints" ) );
sqlite3_free(errMsg);
sqlite3_close(sqlite_handle);
sqlite3_free( errMsg );
sqlite3_close( sqlite_handle );
pbnFindSRID->setEnabled( false );
return false;
}
initializeSpatialMetadata(sqlite_handle);
initializeSpatialMetadata( sqlite_handle );

// all done: closing the DB connection
sqlite3_close(sqlite_handle);
sqlite3_close( sqlite_handle );
}

QFileInfo fi( newDb );
Expand Down
60 changes: 30 additions & 30 deletions src/plugins/offline_editing/offline_editing.cpp
Expand Up @@ -253,7 +253,7 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
sqlite3_close( db );
}

void QgsOfflineEditing::initializeSpatialMetadata(sqlite3 *sqlite_handle)
void QgsOfflineEditing::initializeSpatialMetadata( sqlite3 *sqlite_handle )
{
// attempting to perform self-initialization for a newly created DB
int ret;
Expand All @@ -265,37 +265,37 @@ void QgsOfflineEditing::initializeSpatialMetadata(sqlite3 *sqlite_handle)
int rows;
int columns;

if (sqlite_handle == NULL)
if ( sqlite_handle == NULL )
return;
// checking if this DB is really empty
strcpy(sql, "SELECT Count(*) from sqlite_master");
ret = sqlite3_get_table(sqlite_handle, sql, &results, &rows, &columns, NULL);
if (ret != SQLITE_OK)
// checking if this DB is really empty
strcpy( sql, "SELECT Count(*) from sqlite_master" );
ret = sqlite3_get_table( sqlite_handle, sql, &results, &rows, &columns, NULL );
if ( ret != SQLITE_OK )
return;
if (rows < 1)
if ( rows < 1 )
;
else
{
for (i = 1; i <= rows; i++)
count = atoi(results[(i * columns) + 0]);
for ( i = 1; i <= rows; i++ )
count = atoi( results[( i * columns ) + 0] );
}
sqlite3_free_table(results);
sqlite3_free_table( results );

if (count > 0)
if ( count > 0 )
return;

// all right, it's empty: proceding to initialize
strcpy(sql, "SELECT InitSpatialMetadata()");
ret = sqlite3_exec(sqlite_handle, sql, NULL, NULL, &errMsg);
if (ret != SQLITE_OK)
strcpy( sql, "SELECT InitSpatialMetadata()" );
ret = sqlite3_exec( sqlite_handle, sql, NULL, NULL, &errMsg );
if ( ret != SQLITE_OK )
{
QString errCause = tr( "Unable to initialize SpatialMetedata:\n" );
errCause += QString::fromUtf8(errMsg);
errCause += QString::fromUtf8( errMsg );
showWarning( errCause );
sqlite3_free(errMsg);
sqlite3_free( errMsg );
return;
}
spatial_ref_sys_init(sqlite_handle, 0);
spatial_ref_sys_init( sqlite_handle, 0 );
}

bool QgsOfflineEditing::createSpatialiteDB( const QString& offlineDbPath )
Expand All @@ -319,30 +319,30 @@ bool QgsOfflineEditing::createSpatialiteDB( const QString& offlineDbPath )

// creating/opening the new database
QString dbPath = newDb.fileName();
spatialite_init(0);
ret = sqlite3_open_v2(dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (ret)
spatialite_init( 0 );
ret = sqlite3_open_v2( dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
if ( ret )
{
// an error occurred
// an error occurred
QString errCause = tr( "Could not create a new database\n" );
errCause += QString::fromUtf8(sqlite3_errmsg(sqlite_handle));
sqlite3_close(sqlite_handle);
errCause += QString::fromUtf8( sqlite3_errmsg( sqlite_handle ) );
sqlite3_close( sqlite_handle );
showWarning( errCause );
return false;
}
// activating Foreign Key constraints
ret = sqlite3_exec(sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg);
if (ret != SQLITE_OK)
ret = sqlite3_exec( sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg );
if ( ret != SQLITE_OK )
{
showWarning( tr( "Unable to activate FOREIGN_KEY constraints" ) );
sqlite3_free(errMsg);
sqlite3_close(sqlite_handle);
sqlite3_free( errMsg );
sqlite3_close( sqlite_handle );
return false;
}
initializeSpatialMetadata(sqlite_handle);
initializeSpatialMetadata( sqlite_handle );

// all done: closing the DB connection
sqlite3_close(sqlite_handle);
sqlite3_close( sqlite_handle );

return true;
}
Expand Down

0 comments on commit a16d598

Please sign in to comment.