artemp/tickets2issues — Issue #416: Rendering curved paths
Author: artemp
Created: 2011-10-11 15:16:13+00:00
State: open
Labels: Agg_Renderer

I have suggestion, to add support for some kind of line and polyline smoothing.
It appears, there was some discussion already:
http://lists.berlios.de/pipermail/mapnik-devel/2008-January/000367.html

Agg and cairo has some support for bezier curves. I tried with agg_renderer.cpp by wrapping path_type with agg::conv_smooth_poly1_curve and adjusting smooth_value, but it only looks acceptable for wide angles, and still generated curves are little too far from source path.
Things to keep in mind:[[BR]]
- don't smooth angles less then specified value (i.e. 100 deg.).[[BR]]
- [http://www.antigrain.com/research/bezier_interpolation/ conv_smooth_poly1_curve] generates curve passing through nodes, maybe better would be cutting turns. In other worlds drawing curves passing through middle points of path segments[[BR]]
- solution should handle all paths, including text placement and polygons. To consider: what would be default behaviour for different symbolizers. Maybe some global option (smoothness) per layer, but this would be just walkaround of current xml format (or use cascadenik).[[BR]]
- there should be some universal approach, to handle agg ang cairo, i.e.: adding new cmd: SEG_CURVETO to map to cairo's cairo_curve_to and agg's path_cmd_curve4 of conv_curve wrapper.[[BR]]
- for polygons, closing should be also curved in case of wide angle.

Probably this could be partly implemented in CoordTransform or some wrapper. For wide angles, it would at first generate SEG_LINETO to middle point of actual segment and SEG_CURVETO to middle of next segment. Bezier control points would be placed along segments and with length dependent on smoothness value. For narrow angles, SEG_LINETO from actual middle, to end of segment, and SEG_LINETO to next middle point (could be omitted in case of two adjacent narrow angles).