Skip to content
Permalink
Browse files

a) applied the patch suggested in ticket #3139

b) fixed the SourceSelect dialog so to avoid
   showing RasterLite-1 related tables


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14435 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
esseffe
esseffe committed Oct 26, 2010
1 parent 1b71ee0 commit df9ad6745ab16d5ca41f9473d855a0624aefe2fe
@@ -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];
@@ -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;
@@ -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;

0 comments on commit df9ad67

Please sign in to comment.
You can’t perform that action at this time.