Skip to content
Permalink
Browse files

[pal] Only apply distance from line midpoint penalty to non closed li…

…nestrings

Sponsored by Andreas Neumann

(cherry-picked from c3f720f)
  • Loading branch information
nyalldawson committed Aug 9, 2016
1 parent a74dd61 commit 7c220086611fabe0b4ee1ba9d106ca9098bbe490
@@ -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 >

// penalize positions which are further from absolute center of whole linestring
double costLineCenter = 2 * qAbs( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
cost += costLineCenter * 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.

0 comments on commit 7c22008

Please sign in to comment.
You can’t perform that action at this time.