Skip to content

Commit ff37f8e

Browse files
committedJul 26, 2016
Fix features are not labeled when using merged connected lines and
lines are touching but not at endpoints (cherry-picked from 9007d5c)
1 parent c08b6d7 commit ff37f8e

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed
 

‎src/core/pal/layer.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void Layer::joinConnectedFeatures()
362362
QLinkedList<FeaturePart*>* parts = mConnectedHashtable.value( labelText );
363363

364364
// go one-by-one part, try to merge
365-
while ( !parts->isEmpty() )
365+
while ( !parts->isEmpty() && parts->count() > 1 )
366366
{
367367
// part we'll be checking against other in this round
368368
FeaturePart* partCheck = parts->takeFirst();
@@ -371,24 +371,29 @@ void Layer::joinConnectedFeatures()
371371
if ( otherPart )
372372
{
373373
// remove partCheck from r-tree
374-
double bmin[2], bmax[2];
375-
partCheck->getBoundingBox( bmin, bmax );
376-
mFeatureIndex->Remove( bmin, bmax, partCheck );
377-
mFeatureParts.removeOne( partCheck );
374+
double checkpartBMin[2], checkpartBMax[2];
375+
partCheck->getBoundingBox( checkpartBMin, checkpartBMax );
378376

379-
mConnectedFeaturesIds.insert( partCheck->featureId(), connectedFeaturesId );
380-
otherPart->getBoundingBox( bmin, bmax );
377+
double otherPartBMin[2], otherPartBMax[2];
378+
otherPart->getBoundingBox( otherPartBMin, otherPartBMax );
381379

382380
// merge points from partCheck to p->item
383381
if ( otherPart->mergeWithFeaturePart( partCheck ) )
384382
{
383+
// remove the parts we are joining from the index
384+
mFeatureIndex->Remove( checkpartBMin, checkpartBMax, partCheck );
385+
mFeatureIndex->Remove( otherPartBMin, otherPartBMax, otherPart );
386+
387+
// reinsert merged line to r-tree (probably not needed)
388+
otherPart->getBoundingBox( otherPartBMin, otherPartBMax );
389+
mFeatureIndex->Insert( otherPartBMin, otherPartBMax, otherPart );
390+
391+
mConnectedFeaturesIds.insert( partCheck->featureId(), connectedFeaturesId );
385392
mConnectedFeaturesIds.insert( otherPart->featureId(), connectedFeaturesId );
386-
// reinsert p->item to r-tree (probably not needed)
387-
mFeatureIndex->Remove( bmin, bmax, otherPart );
388-
otherPart->getBoundingBox( bmin, bmax );
389-
mFeatureIndex->Insert( bmin, bmax, otherPart );
393+
394+
mFeatureParts.removeOne( partCheck );
395+
delete partCheck;
390396
}
391-
delete partCheck;
392397
}
393398
}
394399

0 commit comments

Comments
 (0)
Please sign in to comment.