[Geoserver-users] How can I create complex SLD-features?

Hi All,

I would like to make composed features for my maps, e.g.
http://la-bw.de/test/burg03.png. I know there are several ways to do so, but
I'm stuck somehow. I tried this:

- making an SVG which is referenced by the SLD. But no symbol is shown,
neither in the map nor in the legend.

- making a PNG from the SVG. It is rendered pretty nice, but without
transparency. This produces an ugly white box around the symbol, in every
browser I can get (IE6, IE7, Firefox, Opera). Is there any trick in defining
the transparency?

- third there is possibly a way in composing the parts solely in the
SLD-file itself, but I couldn't find a docu for this. If this feature
exists, there should be a way to define positioned PointSymbolizer-chunks in
the SLD.

Is there anybody who knows some help to get one way work?

With best wishes,

Tilo

Tilo Wütherich ha scritto:

Hi All,

I would like to make composed features for my maps, e.g.
http://la-bw.de/test/burg03.png. I know there are several ways to do so, but
I'm stuck somehow. I tried this:

- making an SVG which is referenced by the SLD. But no symbol is shown,
neither in the map nor in the legend.

This should be working... can I have the SVG?

- making a PNG from the SVG. It is rendered pretty nice, but without
transparency. This produces an ugly white box around the symbol, in every
browser I can get (IE6, IE7, Firefox, Opera). Is there any trick in defining
the transparency?

If the PNG is transparent it should be rendered accordingly with transparency... which version of GeoServer are you using?
Can I see the WMS request and a sample of the output?

- third there is possibly a way in composing the parts solely in the
SLD-file itself, but I couldn't find a docu for this. If this feature
exists, there should be a way to define positioned PointSymbolizer-chunks in
the SLD.

This one would be hard, and would require a very big SLD because you would have to build the geometries one by one for each point you want
to depict...

Cheers
Andrea

Sorry, URL should be: http://www.la-bw.de/test/burg03.png

-----Original Message-----
From: geoserver-users-bounces@lists.sourceforge.net
[mailto:geoserver-users-bounces@lists.sourceforge.net]On Behalf Of Tilo
Wutherich
Sent: Thursday, October 11, 2007 10:36 AM
To: Mailingliste Geoserver
Subject: [Geoserver-users] How can I create complex SLD-features?

SNIP

Hi Andrea,

This should be working... can I have the SVG?

have a look at the attachment or the code below.

If the PNG is transparent it should be rendered accordingly with
transparency... which version of GeoServer are you using?
Can I see the WMS request and a sample of the output?

I'm using Geoserver 1.5.3.

The WMS-request for the legend is:

http://129.143.96.78:8080/geoserver/wms/GetLegendGraphic?VERSION=1.0.0&FORMA
T=image/png&WIDTH=20&HEIGHT=20&LAYER=geo_postgis:gemeinden

it returns:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE
ServiceExceptionReport SYSTEM
"http://129.143.96.78:8080/geoserver/schemas//wms/1.1.1/WMS_exception_1_1_1.
dtd"> <ServiceExceptionReport version="1.1.1">
<ServiceException>org/apache/batik/dom/util/DocumentFactory
org/apache/batik/dom/util/DocumentFactory</ServiceException>
</ServiceExceptionReport>

This one would be hard, and would require a very big SLD because you
would have to build the geometries one by one for each point you want
to depict...

... 20x20=400, so we should not consider it any further :slight_smile:

Cheers,

Tilo

-----------
My SVG:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Tilo Wuetherich, Landesarchiv Baden-Wuerttemberg SVG
Version: 6.00 Build 51448 -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot; [
  <!ENTITY ns_svg "http://www.w3.org/2000/svg&quot;&gt;
  <!ENTITY ns_xlink "http://www.w3.org/1999/xlink&quot;&gt;
]>
<svg version="1.1" id="Ebene_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;"
width="20" height="20"
   viewBox="0 0 20 20" overflow="visible" enable-background="new 0 0 20 20"
xml:space="preserve">
<line fill="none" stroke="#000000" stroke-width="1" x1="10" y1="10" x2="10"
y2="0"/>
<ellipse fill="none" stroke="#000000" stroke-width="1" cx="10" cy="15"
rx="4" ry="4"/>
<polygon fill="#FF0000" stroke="#000000" stroke-width="1" points="18,4 10,7
10,0 "/>
</svg>

burg02.svg

Hi,

If the PNG is transparent it should be rendered accordingly with
transparency...

after some testing with Gimp and transparency it works. So it's ok for me to
use Gimp-made PNG.

Cheers,

Tilo

Tilo Wütherich ha scritto:

Hi,

If the PNG is transparent it should be rendered accordingly with
transparency...

after some testing with Gimp and transparency it works. So it's ok for me to
use Gimp-made PNG.

Hi Tilo,
I tested both the png and the svg. Attached you can find the sld that uses the svg version, with a minor modification you can have it point
to the png.

The attached image demFlags.png is the output of using your png against
the following request (that uses our sample data):
http://localhost:8080/geoserver/wms?HEIGHT=500&WIDTH=500&LAYERS=sf%3Adem%2Csf%3Aarchsites&STYLES=%2CpointFlag&SRS=EPSG%3A26713&FORMAT=image%2Fpng8&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=589229.210229517,4910245.300931541,609489.3473411091,4930505.438043134

I see there are little white spots, which have probably been generated
during the svg rasterization and are not transparent like the rest of the image. To have them fully transparent one would have to hand edit
the png. Is this consistent with your results?

The svg in fact did not work, it seems we are missing quite some pieces
of the Batik liibrary in our current configuration. After adding the
required jars, the result I get does not have any artifact (attached
as demFlagsSvg.png).
If you don't want to wait for a release, you have to alter your geoserver install by adding the following jars:
batik-dom-1.6.jar
batik-bridge-1.6.jar
batik-gvt-1.6.jar
batik-svg-dom-1.6.jar
batik-css-1.6.jar
batik-ext-1.6.jar
batik-xml-1.6.jar
batik-script-1.6.jar
batik-parser-1.6.jar

You can download them from http://repo1.maven.org/maven2/batik/.

Btw, your svg is little and nice, can I keep it and add it to the
GeoServer default configuration so that people have examples of
how to use svg symbols in GeoServer out of the box?

Cheers
Andrea

demFlags.png

demFlagsSvg.png

pointFlag.sld (1.44 KB)

Hi Andrea,

thank you very much for your help!

I see there are little white spots, which have probably been generated
during the svg rasterization and are not transparent like the rest of
the image. To have them fully transparent one would have to hand edit
the png. Is this consistent with your results?

Yes, I presume these are artifacts from my workflow: writing the SVG,
calling it by a browser from local path, screencopy, cut in Photoshop or
Gimp, adding transparency-colour and saving as PNG. The browsers produce
some anti-aliasing and so the white spots are in fact a very light grey for
which the transparency doesn't work.

The svg in fact did not work, it seems we are missing quite some pieces
of the Batik liibrary in our current configuration. After adding the
required jars, the result I get does not have any artifact (attached
as demFlagsSvg.png).
If you don't want to wait for a release, you have to alter your
geoserver install by adding the following jars:

[...]

I added the files and it works great! I will prefer the SVG, because it's
much easier to scale the symbols.

Btw, your svg is little and nice, can I keep it and add it to the
GeoServer default configuration so that people have examples of
how to use svg symbols in GeoServer out of the box?

Yes of course, I'm glad to hear that :slight_smile:

Cheers,

Tilo