Is there a way of testing whether a layer (name) exists in QGIS in order to write a conditional expression?
My particular problem is that I am trying to rotate a point object (a gate), using a data-defined expression.
If the 'road' layer exists (a line layer), I will use the angle of the nearest road segment (using the approach discussed here: Find angle of segment of line geometry nearest to point).
If the 'road' layer does not exist, I will use the "symbolrotation" field in the point layer.
The challenge is that while the layer is named 'road' in the Layer Panel, it will have a layer ID similar to
'road_b3cb9198_b4d5_4e05_b465_ed2e1c291774'. So checking whether 'road' exists in the @layer_ids variable isn't likely to work.
Is there an alternative way?