Skip to content

Commit

Permalink
a) applied the patch suggested in ticket #3139
Browse files Browse the repository at this point in the history
b) fixed the SourceSelect dialog so to avoid
   showing RasterLite-1 related tables


git-svn-id: http://svn.osgeo.org/qgis/trunk@14435 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
esseffe committed Oct 26, 2010
1 parent 752bad8 commit 510d425
Show file tree
Hide file tree
Showing 4 changed files with 365 additions and 53 deletions.
48 changes: 48 additions & 0 deletions src/app/qgsspatialitesourceselect.cpp
Expand Up @@ -507,6 +507,8 @@ bool QgsSpatiaLiteSourceSelect::getTableInfo( sqlite3 * handle )
{
for ( i = 1; i <= rows; i++ )
{
if ( isRasterlite1Datasource( handle, results[( i * columns ) + 0] ) )
continue;
QString tableName = QString::fromUtf8( results[( i * columns ) + 0] );
QString column = QString::fromUtf8( results[( i * columns ) + 1] );
QString type = results[( i * columns ) + 2];
Expand Down Expand Up @@ -698,6 +700,52 @@ bool QgsSpatiaLiteSourceSelect::checkVirtsGeometryColumns( sqlite3 * handle )
return exists;
}

bool QgsSpatiaLiteSourceSelect::isRasterlite1Datasource (sqlite3 * handle, const char *table)
{
// testing for RasterLite-1 datasources
int ret;
int i;
char **results;
int rows;
int columns;
bool exists = false;
int len;
char table_raster[4192];
char sql[4192];

strcpy ( table_raster, table );
len = strlen( table_raster );
if (strlen( table_raster ) < 9)
return false;
if (strcmp( table_raster + len - 9, "_metadata" ) != 0)
return false;
// ok, possible candidate
strcpy( table_raster + len - 9, "_rasters" );

// checking if the related "_RASTERS table exists
sprintf( sql, "SELECT name FROM sqlite_master WHERE type = 'table' AND name = '%s'", table_raster );

ret = sqlite3_get_table( handle, sql, &results, &rows, &columns, NULL );
if ( ret != SQLITE_OK )
return false;
if ( rows < 1 )
;
else
{
for ( i = 1; i <= rows; i++ )
{
if ( results[( i * columns ) + 0] != NULL )
{
const char *name = results[( i * columns ) + 0];
if ( name )
exists = true;
}
}
}
sqlite3_free_table( results );
return exists;
}

bool QgsSpatiaLiteSourceSelect::isDeclaredHidden( sqlite3 * handle, QString table, QString geom )
{
int ret;
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsspatialitesourceselect.h
Expand Up @@ -117,6 +117,9 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsSpatiaLiteSource
/**Checks if this layer has been declared HIDDEN*/
bool isDeclaredHidden( sqlite3 * handle, QString table, QString geom );

/**Checks if this layer is a RasterLite-1 datasource*/
bool isRasterlite1Datasource( sqlite3 * handle, const char * table );

/**cleaning well-formatted SQL strings*/
QString quotedValue( QString value ) const;

Expand Down

0 comments on commit 510d425

Please sign in to comment.