[Geoserver-users] SLD: Point symbol on center of line

Hello all.

Excuse me if this topic has been dealt with before, but I couldn’t find
any relevant information on this.

I have a case where I want to display an external graphic on top of a
line geometry. The grahpic is used to indicate certain properties of the
line.

Anyways: I quickly found out that, for labels (i.e. textSymbolizers)
this was easy, make a rule with both a LineSymbolizer and a
TextSymbolizers. The label seems to be drawn on the centerpoint of the
visible part of the line (and, most important: on top of the line).

Following this line of thought i tried using the same approach with a
PointSymbolizer (in this case with a Graphic, but the plan is an
ExternalGraphic).
In this case however, with a LineSymbolizer and a PointSymbolizer in the
same rule, the graphic is drawn at what seems to be the center if the
line is converted to a polygon: i.e. for curved lines not on top of the
line, but in the vinciity.

See the attached image for how the PointSymolizer and TextSymbolizer
places its content relative to the line (the x is a TextSymbolizerm the
dot is a PointSymbolizer).

The SLD I’m currently using is atteched beneath.

So, the question is if it is possible to use a PointSymbolizer to draw
it’s content in the same position (relative to a line) as the
TextSymbolizer does. The easy solution would of course be to use a
TextSymbolizer instead, but we kinda require an icon on the, which calls
for a PointSymbolizer.

And, more out of interest: another question is wether the difference
between Points and Text relative to lines are on purpose, or just
something that noone has thought of?

best regards
Atle Sveen
Geomatikk IKT

<?xml version="1.0" encoding="ISO-8859-1"?>



Message and incident Lines

Message and incident Lines

Points Lines for message and incidents Line type message case 17 #CC00CC 3 circle #FF0000 6 x #FF0000


Atle Frenvik Sveen
Utvikler
Geomatikk IKT AS
tlf: 45 27 86 89
atle.frenvik.sveen@…2699…

geoserver_label_point_on_line.png

On Tue, Nov 2, 2010 at 4:01 PM, Sveen Atle Frenvik (Geomatikk IKT)
<Atle.Frenvik.Sveen@anonymised.com> wrote:

Hello all.

Excuse me if this topic has been dealt with before, but I couldn't find
any relevant information on this.

I have a case where I want to display an external graphic on top of a
line geometry. The grahpic is used to indicate certain properties of the
line.

Anyways: I quickly found out that, for labels (i.e. textSymbolizers)
this was easy, make a rule with both a LineSymbolizer and a
TextSymbolizers. The label seems to be drawn on the centerpoint of the
visible part of the line (and, most important: on _top_ of the line).

Following this line of thought i tried using the same approach with a
PointSymbolizer (in this case with a Graphic, but the plan is an
ExternalGraphic).
In this case however, with a LineSymbolizer and a PointSymbolizer in the
same rule, the graphic is drawn at what seems to be the center if the
line is converted to a polygon: i.e. for curved lines not on top of the
line, but in the vinciity.

See the attached image for how the PointSymolizer and TextSymbolizer
places its content relative to the line (the x is a TextSymbolizerm the
dot is a PointSymbolizer).

The SLD I'm currently using is atteched beneath.

So, the question is if it is possible to use a PointSymbolizer to draw
it's content in the same position (relative to a line) as the
TextSymbolizer does. The easy solution would of course be to use a
TextSymbolizer instead, but we kinda require an icon on the, which calls
for a PointSymbolizer.

And, more out of interest: another question is wether the difference
between Points and Text relative to lines are on purpose, or just
something that noone has thought of?

We basically just followed the SLD spec to the letter. For point
symbolizers it is said:

"In this case, if a line, polygon, or
raster geometry is used with this symbolizer, then the semantic is to
use the centroid of
the geometry, or any similar representative point."

What we did was just to pick the centroid no matter what the geometry is.
For lines we could indeed have picked the midpoint instead, was just more
work to calculate it compared to the centroid, for which we have a ready made
JTS routine.

If you want to contribute a patch changing the behavior for lines I
can show you
the java code that currently extracts the centroid

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

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