[OSM-dev] Osmarender feature on only one side of road
80n
80n80n at gmail.com
Mon Jul 2 12:00:37 BST 2007
Martijn
I'll trust your maths on this but it still only offsets a single segment.
You would need to do this for each segment in a path and you would need to
deal with the ends of each segment. A lateral shift means that the end of
one segment would no longer connect up to the start of the next. I suppose
you could add a pseudo segment to bridge that gap though.
One other approach that might work would be to use the close paths algorithm
to fill one side of a path. You could then paint over it a slightly wider
stroke and use the first path as a mask. I think this would mask out the
wider path on the filled side but leave it showing on the other side as a
thin asymmetrical stroke.
BTW the next version of Osmarender will have the ability to apply masks to
paths, so if this works theoretically then all that would be necessary would
be a reasonable close paths algorithm (in XSL anybody?).
Etienne
On 7/2/07, Martijn van Oosterhout <kleptog at gmail.com> wrote:
>
> On 7/2/07, Frederik Ramm <frederik at remote.org> wrote:
> > But wouldn't you have to individually compute the offset for every
> > line segment using trigonometric functions if you want a constant
> > distance between the original path and the offset path?
>
> I wonder. (If anyone spots errors in the reasoning below, let me know).
>
> Say you have a line going from (a,b) to (c,d). What you really want is
> a transformation that translates (0,0) to (a,b) and rotates the world
> so (c,d) is somewhere along the x-axis. This rotation requires the
> angle and trig functions, or so you think. Assume the length of the
> line is L. Then:
>
> sin(theta) = (d-b)/L
> cos(theta) = (c-a)/L
>
> Thus with the following SVG transforms:
>
> transform(a,b) scale(1/L) matrix( c-a d-b b-d c-a 0 0 )
>
> You map the line (L,0) to the original line and a line (L,1) will be
> parallel and one pixel offset. This requires no trig functions and
> should be within the capability of XSLT, right?
>
> (The proof is in the pudding I suppose, I'll try it out this afternoon).
>
> What do you think?
> --
> Martijn van Oosterhout <kleptog at gmail.com> http://svana.org/kleptog/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070702/e0f04429/attachment.html>
More information about the dev
mailing list