I have a point layer styled with the following geometry generator formula for an irregular polygon. It is the union of (a) a circular buffer with (b) a tree canopy spread buffered by 1m (where that extends beyond (a)).
union(buffer($geometry,"tpzbsrad_m"),buffer(make_polygon(make_line(
translate($geometry,0,max("N",0.2)),
translate($geometry,0.6*max("E",0.2),0.6*max("N",0.2)),
translate($geometry,max("E",0.2),0),
translate($geometry,0.6*max("E",0.2),-0.6*max("S",0.2)),
translate($geometry,0,-max("S",0.2)),
translate($geometry,-0.6*max("W",0.2),-0.6*max("S",0.2)),
translate($geometry,-max("W",0.2),0),
translate($geometry,-0.6*max("W",0.2),0.6*max("N",0.2)),
translate($geometry,0,max("N",0.2)))),1))
I would like to use the geometry generator to draw a 45° line from the tree point ($geometry
) to the edge of this irregular polygon.
For most cases the following suffices - a line to the edge of the circular buffer.
make_line(
$geometry, make_point($x + "tpzbsrad_m"*cos(radians(45)),
$y - ("tpzbsrad_m"*sin(radians(45)))
))
But where the tree canopy extends beyond the buffer in that area it doesn't match up. See image below:
What expression can I use to get the line to be long enough to always touch the edge of the irregular polygon at 45°? shortest_line()
results in angles all over the place, naturally.
(Looking for an expression that ideally works in QGIS 2.18 and 3.x)