mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
[pal] Fix invalid candidates created for parallel line labeling
mode when a closed linestring is too small for labels to fit within feature Fixes #18283
This commit is contained in:
parent
d7aec7cc5f
commit
a76fb0b469
@ -856,12 +856,17 @@ int FeaturePart::createCandidatesAlongLineNearMidpoint( QList<LabelPosition *> &
|
||||
{
|
||||
lineStepDistance = std::min( std::min( labelHeight, labelWidth ), lineStepDistance / mLF->layer()->pal->line_p );
|
||||
}
|
||||
else // line length < label width => centering label position
|
||||
else if ( !line->isClosed() ) // line length < label width => centering label position
|
||||
{
|
||||
currentDistanceAlongLine = - ( labelWidth - totalLineLength ) / 2.0;
|
||||
lineStepDistance = -1;
|
||||
totalLineLength = labelWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
// closed line, not long enough for label => no candidates!
|
||||
currentDistanceAlongLine = std::numeric_limits< double >::max();
|
||||
}
|
||||
|
||||
double candidateLength;
|
||||
double beta;
|
||||
|
@ -846,3 +846,8 @@ double PointSet::length() const
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool PointSet::isClosed() const
|
||||
{
|
||||
return qgsDoubleNear( x[0], x[nbPoints - 1] ) && qgsDoubleNear( y[0], y[nbPoints - 1] );
|
||||
}
|
||||
|
@ -156,13 +156,18 @@ namespace pal
|
||||
*/
|
||||
double length() const;
|
||||
|
||||
/**
|
||||
* Returns true if pointset is closed.
|
||||
*/
|
||||
bool isClosed() const;
|
||||
|
||||
protected:
|
||||
mutable GEOSGeometry *mGeos = nullptr;
|
||||
mutable bool mOwnsGeom = false;
|
||||
|
||||
int nbPoints;
|
||||
double *x = nullptr;
|
||||
double *y; // points order is counterclockwise
|
||||
double *y = nullptr; // points order is counterclockwise
|
||||
|
||||
int *cHull = nullptr;
|
||||
int cHullSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user