@@ -364,6 +364,9 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
364
364
QgsFeature f;
365
365
QList<QgsFeatureId> intersectList;
366
366
367
+ // Because the new vector api does not allow querying features by id within a nextFeature loop, default constructed QgsFeature() is
368
+ // inserted first and the real features are created in a second loop
369
+
367
370
QgsFeatureIterator fit = vlayer->getFeatures ( QgsFeatureRequest ().setFilterRect ( viewExtent ).setSubsetOfAttributes ( attList ) );
368
371
while ( fit.nextFeature ( f ) )
369
372
{
@@ -389,7 +392,7 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
389
392
{
390
393
found = true ;
391
394
QgsFeature feature;
392
- it->insert ( f.id (), f );
395
+ it->insert ( f.id (), QgsFeature () );
393
396
mDisplacementIds .insert ( f.id () );
394
397
break ;
395
398
}
@@ -398,17 +401,29 @@ void QgsPointDisplacementRenderer::createDisplacementGroups( QgsVectorLayer* vla
398
401
if ( !found )// insert the already existing feature and the new one into a map
399
402
{
400
403
QMap<QgsFeatureId, QgsFeature> newMap;
401
- QgsFeature existingFeature;
402
- vlayer->getFeatures ( QgsFeatureRequest ().setFilterFid ( existingEntry ) ).nextFeature ( existingFeature );
403
- newMap.insert ( existingEntry, existingFeature );
404
+ newMap.insert ( existingEntry, QgsFeature () );
404
405
mDisplacementIds .insert ( existingEntry );
405
- newMap.insert ( f.id (), f );
406
+ newMap.insert ( f.id (), QgsFeature () );
406
407
mDisplacementIds .insert ( f.id () );
407
408
mDisplacementGroups .push_back ( newMap );
408
409
}
409
410
}
410
411
}
411
412
}
413
+
414
+ // insert the real features into mDisplacementGroups
415
+ QList< QMap<QgsFeatureId, QgsFeature> >::iterator it = mDisplacementGroups .begin ();
416
+ for ( ; it != mDisplacementGroups .end (); ++it )
417
+ {
418
+ QMap<QgsFeatureId, QgsFeature>::iterator mapIt = it->begin ();
419
+ for ( ; mapIt != it->end (); ++mapIt )
420
+ {
421
+ QgsFeature fet;
422
+ vlayer->getFeatures ( QgsFeatureRequest ().setFilterFid ( mapIt.key () ) ).nextFeature ( fet );
423
+ mapIt.value () = fet;
424
+ }
425
+ }
426
+
412
427
}
413
428
414
429
QgsRectangle QgsPointDisplacementRenderer::searchRect ( const QgsPoint& p ) const
0 commit comments