Skip to content

Commit

Permalink
[pal] Cleanup some more variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 5, 2021
1 parent 79b00fd commit fc2155e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
29 changes: 14 additions & 15 deletions src/core/pal/feature.cpp
Expand Up @@ -1222,28 +1222,27 @@ std::size_t FeaturePart::createCandidatesAlongLineNearMidpoint( std::vector< std
return lPos.size();
}


std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet *path_positions, const std::vector< double> &path_distances, int &orientation, const double offsetAlongLine, bool &reversed, bool &flip, bool applyAngleConstraints )
std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet *mapShape, const std::vector< double> &pathDistances, int &orientation, const double offsetAlongLine, bool &reversed, bool &flip, bool applyAngleConstraints )
{
double offsetAlongSegment = offsetAlongLine;
int index = 1;
// Find index of segment corresponding to starting offset
while ( index < path_positions->nbPoints && offsetAlongSegment > path_distances[index] )
while ( index < mapShape->nbPoints && offsetAlongSegment > pathDistances[index] )
{
offsetAlongSegment -= path_distances[index];
offsetAlongSegment -= pathDistances[index];
index += 1;
}
if ( index >= path_positions->nbPoints )
if ( index >= mapShape->nbPoints )
{
return nullptr;
}

LabelInfo *li = mLF->curvedLabelInfo();

double string_height = li->characterHeight;
const double characterHeight = li->characterHeight;

const double segment_length = path_distances[index];
if ( qgsDoubleNear( segment_length, 0.0 ) )
const double segmentLength = pathDistances[index];
if ( qgsDoubleNear( segmentLength, 0.0 ) )
{
// Not allowed to place across on 0 length segments or discontinuities
return nullptr;
Expand All @@ -1265,7 +1264,7 @@ std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet
{
const double characterWidth = li->characterWidth( i );
double characterStartX, characterStartY;
if ( !nextCharPosition( characterWidth, path_distances[endindex], path_positions, endindex, _distance, characterStartX, characterStartY, endLabelX, endLabelY ) )
if ( !nextCharPosition( characterWidth, pathDistances[endindex], mapShape, endindex, _distance, characterStartX, characterStartY, endLabelX, endLabelY ) )
{
return nullptr;
}
Expand Down Expand Up @@ -1299,11 +1298,11 @@ std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet
std::unique_ptr< LabelPosition > slp;
LabelPosition *slp_tmp = nullptr;

double old_x = path_positions->x[index - 1];
double old_y = path_positions->y[index - 1];
double old_x = mapShape->x[index - 1];
double old_y = mapShape->y[index - 1];

double new_x = path_positions->x[index];
double new_y = path_positions->y[index];
double new_x = mapShape->x[index];
double new_y = mapShape->y[index];

double dx = new_x - old_x;
double dy = new_y - old_y;
Expand All @@ -1322,7 +1321,7 @@ std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet
continue;

double start_x, start_y, end_x, end_y;
if ( !nextCharPosition( characterWidth, path_distances[index], path_positions, index, offsetAlongSegment, start_x, start_y, end_x, end_y ) )
if ( !nextCharPosition( characterWidth, pathDistances[index], mapShape, index, offsetAlongSegment, start_x, start_y, end_x, end_y ) )
{
return nullptr;
}
Expand Down Expand Up @@ -1375,7 +1374,7 @@ std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset( PointSet
render_angle += M_PI;
}

std::unique_ptr< LabelPosition > tmp = std::make_unique< LabelPosition >( 0, render_x /*- xBase*/, render_y /*- yBase*/, characterWidth, string_height, -render_angle, 0.0001, this, false, LabelPosition::QuadrantOver );
std::unique_ptr< LabelPosition > tmp = std::make_unique< LabelPosition >( 0, render_x /*- xBase*/, render_y /*- yBase*/, characterWidth, characterHeight, -render_angle, 0.0001, this, false, LabelPosition::QuadrantOver );
tmp->setPartId( orientation > 0 ? i : characterCount - i - 1 );
LabelPosition *next = tmp.get();
if ( !slp )
Expand Down
6 changes: 3 additions & 3 deletions src/core/pal/feature.h
Expand Up @@ -265,16 +265,16 @@ namespace pal

/**
* Returns the label position for a curved label at a specific offset along a path.
* \param path_positions line path to place label on
* \param path_distances array of distances to each segment on path
* \param mapShape line path to place label on
* \param pathDistances array of distances to each segment on path
* \param orientation can be 0 for automatic calculation of orientation, or -1/+1 for a specific label orientation
* \param distance distance to offset label along curve by
* \param reversed if TRUE label is reversed from lefttoright to righttoleft
* \param flip if TRUE label is placed on the other side of the line
* \param applyAngleConstraints TRUE if label feature character angle constraints should be applied
* \returns calculated label position
*/
std::unique_ptr< LabelPosition > curvedPlacementAtOffset( PointSet *path_positions, const std::vector<double> &path_distances,
std::unique_ptr< LabelPosition > curvedPlacementAtOffset( PointSet *mapShape, const std::vector<double> &pathDistances,
int &orientation, double distance, bool &reversed, bool &flip, bool applyAngleConstraints );

/**
Expand Down

0 comments on commit fc2155e

Please sign in to comment.