[Geoserver-users] Another question on lines with directional arrows

We've got a number of layers that are consist of migration paths for
various peoples and/or languages. These migration paths are
directional lines and thus we want to display an arrow head at one end
of the line to indicate direction. I'm attaching a snapshot one of our
existing maps so you can see exactly what I'm talking about.

Currently these are being done in ArcIMS using extra line segments to
literally draw the arrow head, but this of course pollutes the feature
geometry with bogus line segments. I'm planning on slowly migrating
these services over to geoserver and it would be really great if I
could find a cleaner solution for this at the same time. I've seen
some stuff on list and on the blog about faking small arrows using a
combination of dashed strokes, but I really just want the arrow head
at the END of the line, not throughout the entire line. My question
is: has anyone done something like this in geoserver already, either
via some SLD magic or maybe with a custom renderer? I'm actually
considering trying my hand at coding up a renderer to handle this but
I don't want to duplicate any other work that someone else may have
already done. This *seems* like a fairly obvious need; I'm actually
surprised that neither ArcIMS nor geoserver can do this out of the
box.

--
This message brought to you by Speed of Light Beer
When you're approaching infinite mass
It's Speed of Light time!

line_arrow.jpg

On Tue, Jun 30, 2009 at 1:32 PM, Joshua M.
Thompson<joshua.thompson@anonymised.com> wrote:

We've got a number of layers that are consist of migration paths for
various peoples and/or languages. These migration paths are
directional lines and thus we want to display an arrow head at one end
of the line to indicate direction. I'm attaching a snapshot one of our
existing maps so you can see exactly what I'm talking about.

Currently these are being done in ArcIMS using extra line segments to
literally draw the arrow head, but this of course pollutes the feature
geometry with bogus line segments. I'm planning on slowly migrating
these services over to geoserver and it would be really great if I
could find a cleaner solution for this at the same time. I've seen
some stuff on list and on the blog about faking small arrows using a
combination of dashed strokes, but I really just want the arrow head
at the END of the line, not throughout the entire line. My question
is: has anyone done something like this in geoserver already, either
via some SLD magic or maybe with a custom renderer? I'm actually
considering trying my hand at coding up a renderer to handle this but
I don't want to duplicate any other work that someone else may have
already done. This *seems* like a fairly obvious need; I'm actually
surprised that neither ArcIMS nor geoserver can do this out of the
box.

It's an interesting use case and does seem like a reasonable one. The
obvious solution that occurs to me is to create end points from the
lines and draw an arrow at that point. We have an arrow symbol (or you
could make one in svg) - each point would need to know the direction
the end of the line was going in to get the rotation right but that
should be easy to calculate (I think).

Ian

Ian Turton ha scritto:

On Tue, Jun 30, 2009 at 1:32 PM, Joshua M.
Thompson<joshua.thompson@anonymised.com> wrote:

We've got a number of layers that are consist of migration paths for
various peoples and/or languages. These migration paths are
directional lines and thus we want to display an arrow head at one end
of the line to indicate direction. I'm attaching a snapshot one of our
existing maps so you can see exactly what I'm talking about.

Currently these are being done in ArcIMS using extra line segments to
literally draw the arrow head, but this of course pollutes the feature
geometry with bogus line segments. I'm planning on slowly migrating
these services over to geoserver and it would be really great if I
could find a cleaner solution for this at the same time. I've seen
some stuff on list and on the blog about faking small arrows using a
combination of dashed strokes, but I really just want the arrow head
at the END of the line, not throughout the entire line. My question
is: has anyone done something like this in geoserver already, either
via some SLD magic or maybe with a custom renderer? I'm actually
considering trying my hand at coding up a renderer to handle this but
I don't want to duplicate any other work that someone else may have
already done. This *seems* like a fairly obvious need; I'm actually
surprised that neither ArcIMS nor geoserver can do this out of the
box.

It's an interesting use case and does seem like a reasonable one. The
obvious solution that occurs to me is to create end points from the
lines and draw an arrow at that point. We have an arrow symbol (or you
could make one in svg) - each point would need to know the direction
the end of the line was going in to get the rotation right but that
should be easy to calculate (I think).

The hard-er part is to make the changes in the full chain:
- extend LineSymbolizer SLD so that it has the ability to show point
   graphics at a certain position (start, end)
- extend the LineSymbolizer class and SLD parser
- extend the Line2D class (the LineSymbolizer brother that has
   all expression and stuff resolved already, for performance)
- extend StyledShapePainter to actually do the drawing

Ah hem... well, hope the outline above is useful :slight_smile:
(hopefully I did not discourage you too much)

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

On Wed, Jul 1, 2009 at 10:19 AM, Andrea Aime<aaime@anonymised.com> wrote:

The hard-er part is to make the changes in the full chain:
- extend LineSymbolizer SLD so that it has the ability to show point
graphics at a certain position (start, end)
- extend the LineSymbolizer class and SLD parser
- extend the Line2D class (the LineSymbolizer brother that has
all expression and stuff resolved already, for performance)
- extend StyledShapePainter to actually do the drawing

Ah hem... well, hope the outline above is useful :slight_smile:
(hopefully I did not discourage you too much)

Nah I didn't think it would be EASY, otherwise someone else would
probably have done it by now :slight_smile:

Calculating the angle for the arrow head should be easy; just take
points along the line in pairs to and calculate the direction of that
particular segment. The ordering of the points in the actual geometry
would indicate the direction of the line. The SLD could then provide
options for a graphic on the first point, last point, or every nth
point, with the option to automatically rotate the graphic to match
the angle of the line.

Ideally in the end I'd like to submit this upstream, because I think
it would be useful generally and because I'd rather not have to
maintain my own branch of geotools. Aside from the usual stuff like
coding style do you have any advice in this regard? I'm especially
wondering about how to extend SLD in an acceptable way.

--
This message brought to you by Speed of Light Beer
When you're approaching infinite mass
It's Speed of Light time!

Joshua M. Thompson ha scritto:

On Wed, Jul 1, 2009 at 10:19 AM, Andrea Aime<aaime@anonymised.com> wrote:

The hard-er part is to make the changes in the full chain:
- extend LineSymbolizer SLD so that it has the ability to show point
graphics at a certain position (start, end)
- extend the LineSymbolizer class and SLD parser
- extend the Line2D class (the LineSymbolizer brother that has
all expression and stuff resolved already, for performance)
- extend StyledShapePainter to actually do the drawing

Ah hem... well, hope the outline above is useful :slight_smile:
(hopefully I did not discourage you too much)

Nah I didn't think it would be EASY, otherwise someone else would
probably have done it by now :slight_smile:

Calculating the angle for the arrow head should be easy; just take
points along the line in pairs to and calculate the direction of that
particular segment. The ordering of the points in the actual geometry
would indicate the direction of the line. The SLD could then provide
options for a graphic on the first point, last point, or every nth
point, with the option to automatically rotate the graphic to match
the angle of the line.

Ideally in the end I'd like to submit this upstream, because I think
it would be useful generally and because I'd rather not have to
maintain my own branch of geotools. Aside from the usual stuff like
coding style do you have any advice in this regard? I'm especially
wondering about how to extend SLD in an acceptable way.

We can discuss this on the gt2-devel ml, I guess it's a more appropriate
place, and there are other people insterested in extending sld as well

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.