3

I would like to have font markers flip when they are upside down but otherwise follow the line angle. Here is an image of how they look now:

font markers 'AB' on upper line are upside down

I would like them to look like this:

font markers on both lines are not upside down

I achieved this by switching the line direction but I want to do it through the style and I would like to do it at the marker level not the line level. I have tried a geometry generator to switch the line.

if(y_max( $geometry)>y_min($geometry),$geometry,reverse($geometry))

But this only switches the issue to the bottom line.

font marker on bottom line is upside down

I also tried a data defined override on the font marker rotation with these expressions.

if( @symbol_angle < 180,0,180)
if(y_max( $geometry)<  y_min($geometry),0,180)
  • I'm not sure what kind of font-markers do you have: is there a separate point-layer thay is styled with font-markers? Are do they represent a label? How did you create the font-arkers? – babel Jul 16 at 13:28
  • I don't think this can be done. QGIS has no way of getting the location of a marker. What about using a repeating label? – HeikkiVesanto Jul 16 at 13:41
4

If you're working with "font markers" for your text, set the following for data defined override of the rotation:

if(line_interpolate_angle($geometry,0)>180,180,0)

This checks, whether the line is "flipped" and if it is, tells the symbology to rotate the text by 180 degrees, otherwise it stays, as it is.

I did some additional testing, and this solution does not take changes of line direction into account.

| improve this answer | |
  • Perfect! Thanks! – Baswein Jul 16 at 14:11
  • @Baswein I did some additional testing, and this solution does not take changes of line direction into account, it solely cares about the start direction/orientation of the line. – Erik Jul 16 at 14:35
  • Yes I see that. Maybe not perfect ;). But way better than before! I tried this but it didn't work. if(line_interpolate_angle( segments_to_lines( $geometry),0)>180,180,0) – Baswein Jul 16 at 14:44
  • You probably could make up something with the current label location and angle at vertex for the closest vertex of the line - still, it is rather complicated, I think @Baswein – Erik Jul 16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.