Skip to content

Commit

Permalink
GPKG: proper handling of unknown geometry
Browse files Browse the repository at this point in the history
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 14, 2017
1 parent 97d168e commit ad2f760
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit ad2f760

Please sign in to comment.