I have made an example project to help me illustrate what my problem is. I have about 900 curved lines which i want to label using the geometry generator. My label should consist of a line extending from the middle geometry of the line exactly perpendicular. I am labeling an urban map so it would be good if the position on the line can be edited via the attribute table, since there's a danger my labels might overlap or not be in the correct position.
make_point(
x(line_interpolate_point($geometry, length($geometry)/2)),
y(line_interpolate_point($geometry, length($geometry)/2))
)
And screenshot :
and it should look something like this :
EDIT : I used this rather complex code in expression editor to find the angle of each line :
(atan((xat(-1)-xat(0))/(yat(-1)-yat(0)))) * 180/3.14159 + (180 *(((yat(-1)-yat(0)) < 0) + (((xat(-1)-xat(0)) < 0 AND (yat(-1) - yat(0)) >0)*2)))
EDIT2 Far easier :
round(degrees(bearing(start_point($geometry), end_point($geometry),
'EPSG:3857',
'EPSG:7030')),0)
I know have an attribte of each angle.
I am able to draw a line where they all go in the same direction using the following code :
make_line(
make_point(
x(line_interpolate_point($geometry, length($geometry)/2)),
y(line_interpolate_point($geometry, length($geometry)/2))
),
make_point(
x(line_interpolate_point($geometry, length($geometry)/2)) + 20,
y(line_interpolate_point($geometry, length($geometry)/2)) + 20
)
)
how can i add my angle attribute to get my desired result?