[OSM-dev] Osmarender feature on only one side of road
Martijn van Oosterhout
kleptog at gmail.com
Mon Jul 2 11:48:03 BST 2007
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/
More information about the dev
mailing list