3

I need to create a style in QGIS in which the line is moved away from the second line by 2 units, but their ends merge at one point. I created 3 geometry generators - 3 lines. At the ends of the line:

 make_line(
project(  
    start_point(  $geometry ), 
    2/cos(radians(30)), radians(60)+  azimuth(  make_point(  $x_at( 0), $y_at( 0)),  
    make_point(  $x_at( 1), $y_at( 1)))),  start_point(  $geometry ))

 make_line(
project(  
    start_point(  $geometry ), 
    2/cos(radians(30)), radians(60)+  azimuth(  make_point(  $x_at( 0), $y_at( 0)),  
    make_point(  $x_at( 1), $y_at( 1)))),  start_point(  $geometry ))

and offset line:

 difference( 
 difference( 
     $geometry ,  buffer(  end_point(  $geometry ), 2*tan(radians(30)))), 
     buffer(  start_point(  $geometry ), 2*tan(radians(30))))

It looks ok, but there are also errors eg when the last episode is shorter than the offset enter image description here

Is there any way that the style will always work correctly and that the line will always be tightened to the starting point?

Your Answer

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

Browse other questions tagged or ask your own question.