Skip to content
Permalink
Browse files

GPKG: proper handling of unknown geometry

This handles the test use case for layer:
Layer name: geometry2d
Geometry: Unknown (any)
Feature Count: 8

The browser tree will now show the different geometry
layers and allow them to be added in the canvas,
GeometryCollections are skipped.
  • Loading branch information
elpaso committed Aug 13, 2017
1 parent 97d168e commit ad2f760c0eac75ca0681f48ebb432eb39f333fb0
Showing with 13 additions and 5 deletions.
  1. +13 −5 src/providers/ogr/qgsgeopackagedataitems.cpp
@@ -156,11 +156,19 @@ QVector<QgsDataItem *> QgsGeoPackageConnectionItem::createChildren()
layerType = layerTypeFromDb( geometryType );
if ( layerType != QgsLayerItem::LayerType::NoType )
{
// example URI: '/path/gdal_sample_v1.2_no_extensions.gpkg|layerid=7'
QString uri = QStringLiteral( "%1|layerid=%2" ).arg( mPath, layerId );
QgsGeoPackageVectorLayerItem *item = new QgsGeoPackageVectorLayerItem( this, name, mPath, uri, layerType );
QgsDebugMsg( QStringLiteral( "Adding GPKG Vector item %1 %2 %3" ).arg( name, uri, geometryType ) );
children.append( item );
if ( geometryType.contains( QStringLiteral( "Collection" ), Qt::CaseInsensitive ) )
{
QgsDebugMsgLevel( QStringLiteral( "Layer %1 is a geometry collection: skipping %2" ).arg( name, mPath ), 3 );
}
else
{
// example URI: '/path/gdal_sample_v1.2_no_extensions.gpkg|layerid=7|geometrytype=Point'
QString uri = QStringLiteral( "%1|layerid=%2|geometrytype=%3" ).arg( mPath, layerId, geometryType );
// TODO?: not sure, but if it's a collection, an expandable node would be better?
QgsGeoPackageVectorLayerItem *item = new QgsGeoPackageVectorLayerItem( this, name, mPath, uri, layerType );
QgsDebugMsgLevel( QStringLiteral( "Adding GPKG Vector item %1 %2 %3" ).arg( name, uri, geometryType ), 3 );
children.append( item );
}
}
else
{

0 comments on commit ad2f760

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