[Geoserver-users] Split label style in GeoServer CSS or SLD

Hello,

I would like to split the style of my labels, which consist of 2 attributes. I already managed to separate the lines, but I need to style them differently as well, as the second line should be bold. Unfortunately I’m running out of ideas, how it could work.

Currently my label looks like this:

IDENT

LOWERLIMIT

And I would like it to look like this:

IDENT (small)

LOWERLIMIT (bold)

I would prefer to do it in CSS, but I also prepared the style in SLD, so I would be happy for a solution in either of them.

My code looks like this in CSS:

  • {

label: [IDENT][LOWERLIMIT];

-gt-label-auto-wrap: 1;

font-weight: normal;

font-fill: black;

}

and like this in SLD:

ogc:PropertyNameIDENT</ogc:PropertyName><![CDATA[

]]>

ogc:PropertyNameLOWERLIMIT</ogc:PropertyName>

black

normal

Thanks for any help!

Michaela

Hi Michaela

I am not aware of any way of applying different text styles to different parts of a single text symbolizer.

One thing you could try is split the labels into two separate text symbolizers, and apply an offset equal to the font height to the second one.
So something like this:

ogc:PropertyNameIDENT</ogc:PropertyName>

black

normal

ogc:PropertyNameLOWERLIMIT</ogc:PropertyName>

black

bold

0

14

I’m not too familiar with geocss, so I’m not quite sure how this would translate, but perhaps something like this:

  • {

label: [IDENT];

font-weight: normal;

font-fill: black;

}

  • {

label: [LOWERLIMIT];

font-weight: bold;

font-fill: black;

label-offset: 0 14;

}

Torben

···

On Wed, Sep 20, 2017 at 7:03 AM, Egger Michaela <Michaela.Egger@anonymised.com.6862…> wrote:

Hello,

I would like to split the style of my labels, which consist of 2 attributes. I already managed to separate the lines, but I need to style them differently as well, as the second line should be bold. Unfortunately I’m running out of ideas, how it could work.

Currently my label looks like this:

IDENT

LOWERLIMIT

And I would like it to look like this:

IDENT (small)

LOWERLIMIT (bold)

I would prefer to do it in CSS, but I also prepared the style in SLD, so I would be happy for a solution in either of them.

My code looks like this in CSS:

  • {

label: [IDENT][LOWERLIMIT];

-gt-label-auto-wrap: 1;

font-weight: normal;

font-fill: black;

}

and like this in SLD:

ogc:PropertyNameIDENT</ogc:PropertyName><![CDATA[

]]>

ogc:PropertyNameLOWERLIMIT</ogc:PropertyName>

black

normal

Thanks for any help!

Michaela

Wichtiger Hinweis: Diese E-Mail Nachricht kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Wenn Sie nicht der Adressat sind und diese Nachricht irrtümlich erhalten haben, ist Ihnen eine Verwendung des Inhalts, eine Vervielfältigung oder Weitergabe dieser Nachricht ausdrücklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene Nachricht. Vielen Dank. Please Note: This e-mail message may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this message in error or by mistake any unauthorized use, reproduction or distribution of this message is strictly prohibited. Please notify us immediately and destroy the original transmittal. Thank you for your cooperation. Austro Control Österreichische Gesellschaft für Zivilluftfahrt mit beschränkter Haftung Sitz/Registered address: Wien/ Vienna; Registriert unter/registered under: FN 71000m Competent court/Firmenbuchgericht: HG Wien/commercial court Vienna; Rechtsform/legal form: GmbH Postanschrift/postal address: Wagramer Straße 19 - 1220 Wien/Vienna DVR: 0447277 ‬


Check out the vibrant tech community on one of the world’s most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

Geoserver-users@anonymised.com.382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Wed, Sep 20, 2017 at 6:28 PM, Torben Barsballe <
tbarsballe@anonymised.com> wrote:

I'm not too familiar with geocss, so I'm not quite sure how this would
translate, but perhaps something like this:

Thanks for following up Torben. I've updated your example to avoid the
second rule overriding the first:

* {

    label: [IDENT], [LOWERLIMIT];

    font-weight: normal, bold

    font-fill: black;

       label-offset: 0 0, 0 14;

}

One thing that was not said here or on stackoverflow, is that the two
symbolizers are independent,
so depending on conflict resolution, you might get one label, the other, or
both, but there is
no way to make them be either both visible, or both invisible (that would
be a new feature for
the labeling engine, it's independent of the styling language chosen).

Cheers
Andrea

--

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.