Skip to content
Permalink
Browse files

PG raster enable filters in source select

  • Loading branch information
elpaso committed Mar 3, 2020
1 parent 1e90f30 commit a6679eedd10c519c84c231e33b1b7aefcae48e75
@@ -174,7 +174,6 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper
selItem->setCheckState( Qt::Unchecked );
checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~ Qt::ItemIsUserCheckable );
checkPkUnicityItem->setCheckState( Qt::Unchecked );
sqlItem->setEnabled( false );
}

QList<QStandardItem *> childItemList;
@@ -396,15 +395,21 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn
{
if ( isRaster )
{
// GDAL connection string
// GDAL/PG connection string
const QString schemaName = index.sibling( index.row(), DbtmSchema ).data( Qt::DisplayRole ).toString();
const QString tableName = index.sibling( index.row(), DbtmTable ).data( Qt::DisplayRole ).toString();
const QString geomColumnName = index.sibling( index.row(), DbtmGeomCol ).data( Qt::DisplayRole ).toString();
return QStringLiteral( "PG: %1 mode=2 schema='%2' column='%3' table='%4'" )
.arg( connInfo )
.arg( schemaName )
.arg( geomColumnName )
.arg( tableName );
QString connString { QStringLiteral( "PG: %1 mode=2 schema='%2' column='%3' table='%4'" )
.arg( connInfo )
.arg( schemaName )
.arg( geomColumnName )
.arg( tableName ) };
const QString sql { index.sibling( index.row(), DbtmSql ).data( Qt::DisplayRole ).toString() };
if ( ! sql.isEmpty() )
{
connString.append( QStringLiteral( " sql=%1" ).arg( sql ) );
}
return connString;
}
else
{
@@ -230,6 +230,29 @@ def testOtherSchema(self):
self.assertTrue(rl.isValid())
self.assertTrue(compareWkt(rl.extent().asWktPolygon(), 'POLYGON((-64.79286766849691048 -77.26689086732433509, -62.18292922825105506 -77.26689086732433509, -62.18292922825105506 -74.83694818157819384, -64.79286766849691048 -74.83694818157819384, -64.79286766849691048 -77.26689086732433509))'))

def testUntiledMultipleRows(self):
"""Test multiple rasters (one per row)"""

self._load_test_table('public', 'raster_3035_untiled_multiple_rows')

rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"pk\" = 1".format(table='raster_3035_untiled_multiple_rows', schema='public'), 'pg_layer', 'postgresraster')
self.assertTrue(rl.isValid())
block = rl.dataProvider().block(1, rl.extent(), 2, 2)
data = []
for i in range(2):
for j in range(2):
data.append(int(block.value(i, j)))
self.assertEqual(data, [136, 142, 145, 153])

rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"pk\" = 2".format(table='raster_3035_untiled_multiple_rows', schema='public'), 'pg_layer', 'postgresraster')
self.assertTrue(rl.isValid())
block = rl.dataProvider().block(1, rl.extent(), 2, 2)
data = []
for i in range(2):
for j in range(2):
data.append(int(block.value(i, j)))
self.assertEqual(data, [136, 142, 161, 169])


if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,16 @@
--
-- in-db float32 untiled raster with multiple rows
--

CREATE TABLE "public"."raster_3035_untiled_multiple_rows" ("pk" SERIAL PRIMARY KEY, "rast" raster
);
INSERT INTO "public"."raster_3035_untiled_multiple_rows" ("rast", "pk")
VALUES ('0100000100000000000000394000000000000039C000000000D9204F41000000008F8B424100000000000000000000000000000000DB0B0000020002004A003C1CC66A610843880B0E436E0A1143BBAD1943'::raster, 1);
INSERT INTO "public"."raster_3035_untiled_multiple_rows" ("rast", "pk")
VALUES ('0100000100000000000000394000000000000039C000000000D9204F41000000008F8B424100000000000000000000000000000000DB0B0000020002004A003C1CC66A610843880B0E436E0A2143BBAD2943'::raster, 2)
;

CREATE INDEX ON "public"."raster_3035_untiled_multiple_rows" USING gist (st_convexhull("rast"));
ANALYZE "public"."raster_3035_untiled_multiple_rows";
SELECT AddRasterConstraints('public','raster_3035_untiled_multiple_rows','rast',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE);

0 comments on commit a6679ee

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