mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[pal] Only apply distance from line midpoint penalty to non closed linestrings
Sponsored by Andreas Neumann
This commit is contained in:
parent
dc0cc32046
commit
c3f720f80b
@ -748,9 +748,14 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
|
||||
double costCenter = 2 * qAbs( labelCenter - distanceToCenterOfSegment ) / ( distanceToEndOfSegment - distanceToStartOfSegment ); // 0 -> 1
|
||||
cost += costCenter * 0.0005; // < 0, 0.0005 >
|
||||
|
||||
if ( !closedLine )
|
||||
{
|
||||
// penalize positions which are further from absolute center of whole linestring
|
||||
// this only applies to non closed linestrings, since the middle of a closed linestring is effectively arbitrary
|
||||
// and irrelevant to labeling
|
||||
double costLineCenter = 2 * qAbs( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
|
||||
cost += costLineCenter * 0.0005; // < 0, 0.0005 >
|
||||
}
|
||||
|
||||
cost += segmentCost * 0.0005; // prefer labels on longer straight segments
|
||||
cost += segmentAngleCost * 0.0001; // prefer more horizontal segments, but this is less important than length considerations
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Loading…
x
Reference in New Issue
Block a user