Osmarender/BezierCurves

From OpenStreetMap Wiki
Jump to navigation Jump to search

There is currently a Perl script called lines2curves.pl in the Osmarender subversion directory which will post-process the SVG generated by Osmarender to change some straight lines in paths into bezier curves. There are still some issues with this approach, but feel free to check it out.

Here is an example:

Before (straight line segments) After (using bezier curves)
Motorway-intersection-before.png Motorway-intersection-after.png
Cambridge-sample.png Cambridge-curvy.png

There are a few points I'd like to make about using beziers (appropriately).

  • Using bezier curves make the map more accurate - in most cases the bezier approximation between points is closer in reality than a linear approximation between points. How often in roads do you see sharp angular changes?
  • The curves make the map look more attractive. No, this isn't a flippant point. Its a form & function thing. A map that 'looks' better while performing the same function is more likely to be used.
  • The curves remove the sharp angular changes. The effect of this is that the person viewing the maps sees the topology of the map as it is meant to be seen, and is not detracted by the angular artifacts of the straight-line approximation. The eye seems to be drawn to the angular joins and it shouldn't be. The eye should be drawn to the relevant parts of the map.

the (known) issues...

I'm sure there are some....

1) sometimes phantom line appears (see osmarender layer [1] [2]) (rendered with modified tilesGen.pl where lines2curves.pl used as postprocessing on map-features.svg). Yep - Jochen is working on an update to osmarender4 to help fix this. Its due to the way that ways are finished off. It sometimes appears where two different ways join at a fairly sharp angle --Dotbaz 21:33, 1 March 2007 (UTC)


2) Sometimes roads do have very sharp turns, especially with right angles. How well does this postprocessor deal with those scenarios, and should we have a way of tagging to denote a sharp turn? Any road with a turn of 90 degrees or less is untouched by the bezier algorithm. --Dotbaz 21:33, 1 March 2007 (UTC)

Do you want Osmarender to automatically draw bezier curves? Why not add such a feature to the API? --Bkr 14:48, 3 June 2008 (UTC)

3) Same for rivers:

RiverBezier.png RiverEdit.png
wrong correct

This small river in the center of [Rauma] is edged with murals. They are absolutely straight and they have sharp corners. You can also see that the bridge is centered in the editor but not in Osmarender because the river is shifted. --Plenz 07:04, 23 November 2007 (UTC)

Wouldn't it be possible to had a tag 'bezier=no' (yes would be default for <90° angle) to the nodes that do not have to be curved ??? --PhilippeP 09:09, 23 November 2007 (UTC)

4) Buildings suffer easily from overaggressive curving; would argue that buildings more usually have sharp edges rather than round ones, though exceptions there are. Perchance assume no curving for building=.* and allow bezier=yes for exceptions such as buildings with prominent round parts?

See a [sample building] that should have a sharp, though not very steep angle towards the south end. The rendering is very wonky with bezier. More similar buildings are in close proximity.

For an example of where one would use bezier=yes, [Chemicum] has one round portion that benefits from it, and the other angles are straight enough that the curving algorithm doesn't mess with them. --Mjr 21:41, 30 December 2007 (UTC)

5) The script doesn't work at all on the output of or/p, due to the assumptions made about the SVG internals.