0

I am using GeoServer to produce various layers including points, line and polygons etc. For the map styling CSS code has been used instead of SLD, everything has worked perfectly up until the last point that I need to style. The data in question is about boundary responsibility for a property and each responsibility for that boundary is defined by a letter for example responsibility_number which is number 1 would be defined by the letter 'T' and then would need to be rotated at 120 degrees and then responsibility_number which is defined by number 2 but the same letter is 'T' then needs to be rotated at 45 degrees and so on.

I am trying to get the point to rotate based on a column called text_rotation which has different angles in degrees for each point that needs to be rotated based on that specific angle. I have searched high and low on the internet, stackoverflow and stackexchange but can't see any solutions. I have also tried different codes of CSS but nothing seems to work here are my examples so far.

Example 1

[responsibility_number = '1'] {
  
label: [responsibility_text];
  
font-fill: red;

font-family: Arial;
  
font-size: 12;

font-weight: bold;

label-rotation: [text_rotation];

}

Example 2

[responsibility_number = '1'] {

label: ['T'];
  
font-fill: red;

font-family: Arial;

font-size: 12;

font-weight: bold;

label-rotation: [text_rotation];

}

Example 3

[responsibility_number = '1'] {

label: [responsibility_text];

label-rotation: -157;

label-offset: 0 25;

font-fill: red;

font-family: Arial;

font-size: 12;

font-weight: bold; 

}

Example 4

[responsibility_number = '1'] {
label: ['T'];

label-rotation: -157;

label-offset: 0 25;

font-fill: red;

font-family: Arial;

font-size: 12;

font-weight: bold;
  
}

I can't understand why the T's don't rotate at all I have also tried using mark-rotation, rotation and label-rotation and also tried to use label-offset to force the placement of the label but that doesn't work.

Also I hope this question is okay as its the first time posting :)

2
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Commented Nov 10, 2021 at 9:21
  • Labels are tricky things, you'd be better off using a TrueType font mark as a point graphic.
    – Ian Turton
    Commented Nov 10, 2021 at 9:22

2 Answers 2

1

Did a quick test with the CSS above, the attribute name is label-rotation but indeed the style read and translated to SLD does not contain the rotation anymore... it's lost somehow (CSS is always translated to SLD, there is no specific CSS renderer, just FYI).

Looks like a bug, please open a ticket in Jira.

0

I've had this issue also, tried swapping datatypes for the rotation attribute and whatnot. After figuring out the solution I tried with NUMERIC(10,3) and FLOAT8 datatypes and they both work.

What you need to do is to specify the label-anchor before you add label-rotation. label-anchor by default is set to "0.5 0.5" but for some reason (probably the translation from CSS to SLD I guess?) it needs to be specified in the CSS styling.

Example:

* {
label: [responsibility_text];
font-fill: red;
font-family: Arial;
font-size: 12;
font-weight: bold;
label-rotation: [text_rotation];
label-anchor: 0.5 0.5;
}

Try this out and see if it works for you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.