Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curved labels improved #3313

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/gps/gmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <math.h>
#include <float.h>

double remainder(double X, double Y) { return fmod(X, Y); }

/**
* \fn nmea_degree2radian
* \brief Convert degree to radian
Expand Down
13 changes: 10 additions & 3 deletions src/core/pal/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ LabelPosition* FeaturePart::curvedPlacementAtOffset( PointSet* path_positions, d
delete slp;
return nullptr;
}
// Shift the character downwards since the draw position is specified at the baseline
// and we're calculating the mean line here
double dist = 0.9 * li->label_height / 2;
if (orientation < 0)
dist = -dist;
start_x += dist * cos(angle + M_PI_2);
start_y -= dist * sin(angle + M_PI_2);

double render_angle = angle;

Expand Down Expand Up @@ -1042,11 +1049,11 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition* >& lPos,
double angle_avg = atan2( sin_avg / li->char_num, cos_avg / li->char_num );
// displacement
if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() ) );
positions.append( _createCurvedCandidate( slp, angle_avg, mLF->distLabel() + li->label_height / 2 ) );
if ( flags & FLAG_ON_LINE )
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 ) );
positions.append( _createCurvedCandidate( slp, angle_avg, 0 ) );
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height - mLF->distLabel() ) );
positions.append( _createCurvedCandidate( slp, angle_avg, -li->label_height / 2 - mLF->distLabel() ) );

// delete original candidate
delete slp;
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2517,7 +2517,8 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
}

GEOSGeometry* geos_geom_clone;
if ( GEOSGeomTypeId_r( QgsGeometry::getGEOSHandler(), geos_geom ) == GEOS_POLYGON && repeatDistance > 0 && placement == Line )
GEOSGeomTypes geomType = (GEOSGeomTypes) GEOSGeomTypeId_r( QgsGeometry::getGEOSHandler(), geos_geom );
if ( (geomType == GEOS_POLYGON || geomType == GEOS_MULTIPOLYGON) && repeatDistance > 0 && placement == Line )
{
geos_geom_clone = GEOSBoundary_r( QgsGeometry::getGEOSHandler(), geos_geom );
}
Expand Down