I need help making an expression for labelling points, such that the label is placed in one of the 8 quadrants (above point excluded), based on the azimuth field of the point.
For example, if the azimuth is from 338-23 degrees, place in quadrant 1, if the azimuth is from 24-69 degrees, place in quadrant 2, and so on.
Answer
You can databind the label Placement Quadrant with this expression structure:
CASE
WHEN azimuth < 23 OR azimuth > 338 THEN
1
WHEN azimuth > 24 AND azimuth < 69 THEN
2
ELSE
3
END
You may also need an expression calculating a more appropriate offset depending on the azimuth.
Update:
The offset can databind to an expression like this:
CASE
WHEN azimuth < 23 OR azimuth > 338 THEN
'0,-1'
WHEN azimuth > 24 AND azimuth < 69 THEN
'1,0'
ELSE
'-1,0'
END
Negative x-values moves label west. Negative y-values moves label north. So '0,-1' means an x,y offset in 0 for x and 1 up north. Pick the unit used as map units, if you not using lat-long coordinates.
No comments:
Post a Comment