File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
tests/testdata/control_images/expected_pal_placement/sp_polygon_placement_perimeter Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -748,9 +748,14 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
748
748
double costCenter = 2 * qAbs ( labelCenter - distanceToCenterOfSegment ) / ( distanceToEndOfSegment - distanceToStartOfSegment ); // 0 -> 1
749
749
cost += costCenter * 0.0005 ; // < 0, 0.0005 >
750
750
751
- // penalize positions which are further from absolute center of whole linestring
752
- double costLineCenter = 2 * qAbs ( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
753
- cost += costLineCenter * 0.0005 ; // < 0, 0.0005 >
751
+ if ( !closedLine )
752
+ {
753
+ // penalize positions which are further from absolute center of whole linestring
754
+ // this only applies to non closed linestrings, since the middle of a closed linestring is effectively arbitrary
755
+ // and irrelevant to labeling
756
+ double costLineCenter = 2 * qAbs ( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
757
+ cost += costLineCenter * 0.0005 ; // < 0, 0.0005 >
758
+ }
754
759
755
760
cost += segmentCost * 0.0005 ; // prefer labels on longer straight segments
756
761
cost += segmentAngleCost * 0.0001 ; // prefer more horizontal segments, but this is less important than length considerations
You can’t perform that action at this time.
0 commit comments