Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash in geometry checker when empty geometries are found
Fixes #38983
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Jun 10, 2021
1 parent 607b44b commit f31405e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Expand Up @@ -35,7 +35,7 @@ QgsVectorDataProviderFeaturePool::QgsVectorDataProviderFeaturePool( QgsVectorLay
QgsFeatureIterator it = layer->getFeatures( req );
while ( it.nextFeature( feature ) )
{
if ( feature.hasGeometry() )
if ( feature.hasGeometry() && !feature.geometry().isEmpty() )
{
insertFeature( feature );
featureIds.insert( feature.id() );
Expand Down
1 change: 1 addition & 0 deletions tests/src/geometry_checker/testqgsgeometrychecks.cpp
Expand Up @@ -408,6 +408,7 @@ void TestQgsGeometryChecks::testDuplicateCheck()
layers.insert( "point_layer.shp", "" );
layers.insert( "line_layer.shp", "" );
layers.insert( "polygon_layer.shp", "" );
layers.insert( "polygon_layer_empty_geometries.geojson", "" );
auto testContext = createTestContext( dir, layers );

// Test detection
Expand Down
@@ -0,0 +1,11 @@
{
"type": "FeatureCollection",
"name": "polygon_layer_empty_geometries",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 8, "attr": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } },
{ "type": "Feature", "properties": { "id": 9, "attr": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } },
{ "type": "Feature", "properties": { "id": 10, "attr": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ ] } },
{ "type": "Feature", "properties": { "id": null, "attr": 5 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -0.683682008368201, 0.502928870292887 ], [ -0.1581589958159, -0.104602510460251 ], [ -0.700418410041841, -0.091213389121339 ], [ -0.683682008368201, 0.502928870292887 ] ] ] ] } }
]
}

0 comments on commit f31405e

Please sign in to comment.