Skip to content

Commit df9ad67

Browse files
author
esseffe
committedOct 26, 2010
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

File tree

4 files changed

+365
-53
lines changed

4 files changed

+365
-53
lines changed
 

‎src/app/qgsspatialitesourceselect.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ bool QgsSpatiaLiteSourceSelect::getTableInfo( sqlite3 * handle )
507507
{
508508
for ( i = 1; i <= rows; i++ )
509509
{
510+
if ( isRasterlite1Datasource( handle, results[( i * columns ) + 0] ) )
511+
continue;
510512
QString tableName = QString::fromUtf8( results[( i * columns ) + 0] );
511513
QString column = QString::fromUtf8( results[( i * columns ) + 1] );
512514
QString type = results[( i * columns ) + 2];
@@ -698,6 +700,52 @@ bool QgsSpatiaLiteSourceSelect::checkVirtsGeometryColumns( sqlite3 * handle )
698700
return exists;
699701
}
700702

703+
bool QgsSpatiaLiteSourceSelect::isRasterlite1Datasource (sqlite3 * handle, const char *table)
704+
{
705+
// testing for RasterLite-1 datasources
706+
int ret;
707+
int i;
708+
char **results;
709+
int rows;
710+
int columns;
711+
bool exists = false;
712+
int len;
713+
char table_raster[4192];
714+
char sql[4192];
715+
716+
strcpy ( table_raster, table );
717+
len = strlen( table_raster );
718+
if (strlen( table_raster ) < 9)
719+
return false;
720+
if (strcmp( table_raster + len - 9, "_metadata" ) != 0)
721+
return false;
722+
// ok, possible candidate
723+
strcpy( table_raster + len - 9, "_rasters" );
724+
725+
// checking if the related "_RASTERS table exists
726+
sprintf( sql, "SELECT name FROM sqlite_master WHERE type = 'table' AND name = '%s'", table_raster );
727+
728+
ret = sqlite3_get_table( handle, sql, &results, &rows, &columns, NULL );
729+
if ( ret != SQLITE_OK )
730+
return false;
731+
if ( rows < 1 )
732+
;
733+
else
734+
{
735+
for ( i = 1; i <= rows; i++ )
736+
{
737+
if ( results[( i * columns ) + 0] != NULL )
738+
{
739+
const char *name = results[( i * columns ) + 0];
740+
if ( name )
741+
exists = true;
742+
}
743+
}
744+
}
745+
sqlite3_free_table( results );
746+
return exists;
747+
}
748+
701749
bool QgsSpatiaLiteSourceSelect::isDeclaredHidden( sqlite3 * handle, QString table, QString geom )
702750
{
703751
int ret;

‎src/app/qgsspatialitesourceselect.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsSpatiaLiteSource
117117
/**Checks if this layer has been declared HIDDEN*/
118118
bool isDeclaredHidden( sqlite3 * handle, QString table, QString geom );
119119

120+
/**Checks if this layer is a RasterLite-1 datasource*/
121+
bool isRasterlite1Datasource( sqlite3 * handle, const char * table );
122+
120123
/**cleaning well-formatted SQL strings*/
121124
QString quotedValue( QString value ) const;
122125

0 commit comments

Comments
 (0)
Please sign in to comment.