@@ -364,12 +364,12 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
364
364
365
365
mLayersSupported .clear ();
366
366
367
- for ( int i = 0 ; i < ( hasTopology () ? 3 : 2 ); i++ )
367
+ for ( int i = sctGeometry ; i <= sctPcPatch; ++i )
368
368
{
369
369
QString sql, tableName, schemaName, columnName, typeName, sridName, gtableName, dimName;
370
370
QgsPostgresGeometryColumnType columnType = sctGeometry;
371
371
372
- if ( i == 0 )
372
+ if ( i == sctGeometry )
373
373
{
374
374
tableName = " l.f_table_name" ;
375
375
schemaName = " l.f_table_schema" ;
@@ -380,7 +380,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
380
380
gtableName = " geometry_columns" ;
381
381
columnType = sctGeometry;
382
382
}
383
- else if ( i == 1 )
383
+ else if ( i == sctGeography )
384
384
{
385
385
tableName = " l.f_table_name" ;
386
386
schemaName = " l.f_table_schema" ;
@@ -391,8 +391,10 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
391
391
gtableName = " geography_columns" ;
392
392
columnType = sctGeography;
393
393
}
394
- else if ( i == 2 )
394
+ else if ( i == sctTopoGeometry )
395
395
{
396
+ if ( ! hasTopology () ) continue ;
397
+
396
398
schemaName = " l.schema_name" ;
397
399
tableName = " l.table_name" ;
398
400
columnName = " l.feature_column" ;
@@ -407,6 +409,25 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
407
409
gtableName = " topology.layer" ;
408
410
columnType = sctTopoGeometry;
409
411
}
412
+ else if ( i == sctPcPatch )
413
+ {
414
+ if ( ! hasPointcloud () ) continue ;
415
+
416
+ tableName = " l.\" table\" " ;
417
+ schemaName = " l.\" schema\" " ;
418
+ columnName = " l.\" column\" " ;
419
+ typeName = " 'POLYGON'" ;
420
+ sridName = " l.srid" ;
421
+ dimName = " 2" ;
422
+ gtableName = " pointcloud_columns" ;
423
+ columnType = sctPcPatch;
424
+ }
425
+ else
426
+ {
427
+ QgsMessageLog::logMessage ( tr ( " Unsupported spatial column type %1" )
428
+ .arg ( displayStringForGeomType (( QgsPostgresGeometryColumnType )i ) ) );
429
+ continue ;
430
+ }
410
431
411
432
// The following query returns only tables that exist and the user has SELECT privilege on.
412
433
// Can't use regclass here because table must exist, else error occurs.
@@ -510,7 +531,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
510
531
" WHERE c.relkind IN ('v','r','m')"
511
532
" AND has_schema_privilege( n.nspname, 'usage' )"
512
533
" AND has_table_privilege( '\" ' || n.nspname || '\" .\" ' || c.relname || '\" ', 'select' )"
513
- " AND (t.typname IN ('geometry','geography','topogeometry') OR b.typname IN ('geometry','geography','topogeometry'))" ;
534
+ " AND (t.typname IN ('geometry','geography','topogeometry') OR b.typname IN ('geometry','geography','topogeometry','pcpatch' ))" ;
514
535
515
536
// user has select privilege
516
537
if ( searchPublicOnly )
@@ -522,19 +543,19 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
522
543
// skip columns of which we already derived information from the metadata tables
523
544
if ( nColumns > 0 )
524
545
{
525
- if ( foundInTables & 1 )
546
+ if ( foundInTables & ( 1 << sctGeometry ) )
526
547
{
527
548
sql += " AND (n.nspname,c.relname,a.attname) NOT IN (SELECT f_table_schema,f_table_name,f_geometry_column FROM geometry_columns)" ;
528
549
}
529
550
530
- if ( foundInTables & 2 )
551
+ if ( foundInTables & ( 1 << sctGeography ) )
531
552
{
532
553
sql += " AND (n.nspname,c.relname,a.attname) NOT IN (SELECT f_table_schema,f_table_name,f_geography_column FROM geography_columns)" ;
533
554
}
534
555
535
- if ( foundInTables & 4 )
556
+ if ( foundInTables & ( 1 << sctPcPatch ) )
536
557
{
537
- sql += " AND (n.nspname,c.relname,a.attname) NOT IN (SELECT schema_name,table_name,feature_column FROM topology.layer )" ;
558
+ sql += " AND (n.nspname,c.relname,a.attname) NOT IN (SELECT \" schema \" , \" table \" , \" column \" FROM pointcloud_columns )" ;
538
559
}
539
560
}
540
561
@@ -586,6 +607,10 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
586
607
{
587
608
layerProperty.geometryColType = sctTopoGeometry;
588
609
}
610
+ else if ( coltype == " pcpatch" )
611
+ {
612
+ layerProperty.geometryColType = sctPcPatch;
613
+ }
589
614
else
590
615
{
591
616
Q_ASSERT ( !" Unknown geometry type" );
@@ -747,6 +772,16 @@ bool QgsPostgresConn::hasTopology()
747
772
return mTopologyAvailable ;
748
773
}
749
774
775
+ /* *
776
+ * Check to see if pointcloud is available
777
+ */
778
+ bool QgsPostgresConn::hasPointcloud ()
779
+ {
780
+ // TODO: use mPointcloudAvailable function instead
781
+ QgsPostgresResult result = PQexec ( " SELECT 'pointcloud_columns'::regclass" );
782
+ return result.PQntuples () == 1 ;
783
+ }
784
+
750
785
/* Functions for determining available features in postGIS */
751
786
QString QgsPostgresConn::postgisVersion ()
752
787
{
@@ -1279,12 +1314,15 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
1279
1314
1280
1315
QString query = " SELECT DISTINCT " ;
1281
1316
1317
+ bool castToGeometry = layerProperty.geometryColType == sctGeography ||
1318
+ layerProperty.geometryColType == sctPcPatch;
1319
+
1282
1320
QGis::WkbType type = layerProperty.types .value ( 0 , QGis::WKBUnknown );
1283
1321
if ( type == QGis::WKBUnknown )
1284
1322
{
1285
1323
query += QString ( " upper(geometrytype(%1%2))" )
1286
1324
.arg ( quotedIdentifier ( layerProperty.geometryColName ) )
1287
- .arg ( layerProperty. geometryColType == sctGeography ? " ::geometry" : " " );
1325
+ .arg ( castToGeometry ? " ::geometry" : " " );
1288
1326
}
1289
1327
else
1290
1328
{
@@ -1299,7 +1337,7 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
1299
1337
query += QString ( " %1(%2%3)" )
1300
1338
.arg ( majorVersion () < 2 ? " srid" : " st_srid" )
1301
1339
.arg ( quotedIdentifier ( layerProperty.geometryColName ) )
1302
- .arg ( layerProperty. geometryColType == sctGeography ? " ::geometry" : " " );
1340
+ .arg ( castToGeometry ? " ::geometry" : " " );
1303
1341
}
1304
1342
else
1305
1343
{
@@ -1311,7 +1349,7 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
1311
1349
query += QString ( " ,%1(%2%3)" )
1312
1350
.arg ( majorVersion () < 2 ? " ndims" : " st_ndims" )
1313
1351
.arg ( quotedIdentifier ( layerProperty.geometryColName ) )
1314
- .arg ( layerProperty. geometryColType == sctGeography ? " ::geometry" : " " );
1352
+ .arg ( castToGeometry ? " ::geometry" : " " );
1315
1353
}
1316
1354
1317
1355
query += " FROM " + table;
@@ -1426,10 +1464,10 @@ QString QgsPostgresConn::postgisWkbTypeName( QGis::WkbType wkbType )
1426
1464
return geometryType;
1427
1465
}
1428
1466
1429
- QString QgsPostgresConn::postgisTypeFilter ( QString geomCol, QGis::WkbType geomType, bool isGeography )
1467
+ QString QgsPostgresConn::postgisTypeFilter ( QString geomCol, QGis::WkbType geomType, bool castToGeometry )
1430
1468
{
1431
1469
geomCol = quotedIdentifier ( geomCol );
1432
- if ( isGeography )
1470
+ if ( castToGeometry )
1433
1471
geomCol += " ::geometry" ;
1434
1472
1435
1473
switch ( geomType )
@@ -1601,6 +1639,8 @@ QString QgsPostgresConn::displayStringForGeomType( QgsPostgresGeometryColumnType
1601
1639
return tr ( " Geography" );
1602
1640
case sctTopoGeometry:
1603
1641
return tr ( " TopoGeometry" );
1642
+ case sctPcPatch:
1643
+ return tr ( " PcPatch" );
1604
1644
}
1605
1645
1606
1646
Q_ASSERT ( !" unexpected geometry column type" );
0 commit comments