[Geoserver-users] SLD Label can use two Fields for labeling?

Hi,

i couldnt find any similar question, so i came here to ask if a label can use two fields to get the data from, something like this:

sld:TextSymbolizer
sld:Label
ogc:PropertyNameFIELD_1+FIELD_2</ogc:PropertyName>
</sld:Label>

</sld:TextSymbolizer>

Or use a custom string, like this:

sld:TextSymbolizer
sld:Label
ogc:PropertyName"Zone:"+ZONE_NUMBER</ogc:PropertyName>
</sld:Label>

</sld:TextSymbolizer>

This is possible?

Thanks in advance.

Regards,

Flavio Carmo

On Fri, Nov 12, 2010 at 1:27 PM, Flavio Carmo <flavio.o.carmo@anonymised.com> wrote:

Hi,
i couldnt find any similar question, so i came here to ask if a label can
use two fields to get the data from, something like this:
<sld:TextSymbolizer>
<sld:Label>
<ogc:PropertyName>FIELD_1+FIELD_2</ogc:PropertyName>
</sld:Label>
</sld:TextSymbolizer>
Or use a custom string, like this:
<sld:TextSymbolizer>
<sld:Label>
<ogc:PropertyName>"Zone:"+ZONE_NUMBER</ogc:PropertyName>
</sld:Label>
</sld:TextSymbolizer>
This is possible?

Label is a mixed element, you can have both straight strings and tags mixed
togheter.
Something like:

<sld:Label>
Zone<![CDATA]><ogc:PropertyName>ZONE_NUMBER</ogc:PropertyName
</sld:Label>

or

<sld:Label>
<ogc:PropertyName>FIELD1</ogc:PropertyName<![CDATA[
]]><ogc:PropertyName>FIELD2</ogc:PropertyName
</sld:Label>

should do the trick. As far as I remember spaces have to be kept in
CDATA sections to avoid the
xml parsing rules for that element to wipe them away (can't remember
if all subsequent spaces
are turned into one, or if not even that one is preserved, try without
CDATA and add it back
if necessary)

Cheers
Andrea

-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

Thanks!

Worked just fine. Now how can i use characters with accents, like “ó”,“á”, “ã”? The header for the SLD file begins with <?xml version="1.0" encoding="UTF-8"?> but i couldnt use the “á” char, throwing a error of malformed file.

Regards,

Flávio Carmo

On Fri, Nov 12, 2010 at 10:30, Andrea Aime <andrea.aime@…1107…> wrote:

On Fri, Nov 12, 2010 at 1:27 PM, Flavio Carmo <flavio.o.carmo@anonymised.com> wrote:

Hi,
i couldnt find any similar question, so i came here to ask if a label can
use two fields to get the data from, something like this:
sld:TextSymbolizer
sld:Label
ogc:PropertyNameFIELD_1+FIELD_2</ogc:PropertyName>
</sld:Label>
</sld:TextSymbolizer>
Or use a custom string, like this:
sld:TextSymbolizer
sld:Label
ogc:PropertyName"Zone:"+ZONE_NUMBER</ogc:PropertyName>
</sld:Label>
</sld:TextSymbolizer>
This is possible?

Label is a mixed element, you can have both straight strings and tags mixed
togheter.
Something like:

sld:Label
Zoneogc:PropertyNameZONE_NUMBER</ogc:PropertyName
</sld:Label>

or

sld:Label
ogc:PropertyNameFIELD1</ogc:PropertyNameogc:PropertyNameFIELD2</ogc:PropertyName
</sld:Label>

should do the trick. As far as I remember spaces have to be kept in
CDATA sections to avoid the
xml parsing rules for that element to wipe them away (can’t remember
if all subsequent spaces
are turned into one, or if not even that one is preserved, try without
CDATA and add it back
if necessary)

Cheers
Andrea


Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


On Fri, Nov 12, 2010 at 3:32 PM, Flavio Carmo <flavio.o.carmo@anonymised.com> wrote:

Thanks!
Worked just fine. Now how can i use characters with accents, like "ó","á",
"ã"? The header for the SLD file begins with <?xml version="1.0"
encoding="UTF-8"?> but i couldnt use the "á" char, throwing a error of
malformed file.

Use a xml escape code for it?
http://www.w3.org/TR/xml-entity-names/isolat1.html

Looks like it's &aacute;

Cheers
Andrea

-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

I´ve tried already á but got this error “org.xml.sax.SAXParseException: The entity “aacute” was referenced, but not declared.”.

Regards,

Flávio Carmo

On Fri, Nov 12, 2010 at 13:13, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Fri, Nov 12, 2010 at 3:32 PM, Flavio Carmo <flavio.o.carmo@anonymised.com> wrote:

Thanks!
Worked just fine. Now how can i use characters with accents, like “ó”,“á”,
“ã”? The header for the SLD file begins with <?xml version="1.0" encoding="UTF-8"?> but i couldnt use the “á” char, throwing a error of
malformed file.

Use a xml escape code for it?
http://www.w3.org/TR/xml-entity-names/isolat1.html

Looks like it’s á

Cheers
Andrea


Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

AltlasStyler allows to create labeling rules with two attribute fields,
seperated with a colon. If any of the two fields is null, the colon is
not shown.

You can create such a style with AtlasStyler and then look at the
generated TextSymbolizer or use it directly with Geoserver.

http://en.geopublishing.org/AtlasStyler%20SLD%20Labeling%20Tutorial

Greetings,
Steve

Am 12.11.2010 13:27, schrieb Flavio Carmo:

Hi,

i couldnt find any similar question, so i came here to ask if a label
can use two fields to get the data from, something like this:

      <sld:TextSymbolizer>
        <sld:Label>
          <ogc:PropertyName>FIELD_1+FIELD_2</ogc:PropertyName>
        </sld:Label>
      </sld:TextSymbolizer>

Or use a custom string, like this:

      <sld:TextSymbolizer>
        <sld:Label>
          <ogc:PropertyName>"Zone:"+ZONE_NUMBER</ogc:PropertyName>
        </sld:Label>
      </sld:TextSymbolizer>

This is possible?

Thanks in advance.

Regards,

Flavio Carmo

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzhOdYACgkQdFDQR1G1dv00xwCeMn+fFp4nfM45caen8WUjlYrj
4qwAmwbalKagq9T5Www7vPlxe7VCvc04
=UsyX
-----END PGP SIGNATURE-----