[mapserver-dev] Rendering smoothed lines

thomas bonfort thomas.bonfort at gmail.com
Tue Sep 18 09:46:23 PDT 2012


Hi Daniel

On Mon, Sep 17, 2012 at 7:38 PM, Daniel Morissette
<dmorissette at mapgears.com> wrote:
> Hi Devs,
>
> Has anyone been thinking about adding support for line smoothing (b-spline,
> Bezier curves, ?) in MapServer? I believe AGG supports this already, is this
> an option that we could enable easily for AGG rendering?
Mapserver's AGG driver itself does not currently support splines
natively, and that would probably not be hard to add (for cairo also,
gd is another problem). This would need modifications to our shapeObj
structure (to allow it to contain spline control points) which has
repercussions throughout the code which does not seem like a good
idea.

>
> More specifically, we've been asked about the ability to smooth contour
> lines as we zoom out (probably more a combination of simplifying and
> smoothing). In the contour case it would not be sufficient to do the
> smoothing at the renderer level (i.e. in AGG) since we also want the contour
> labels to be positioned properly on top of the smoothed contour. For this
> reason we may instead want to implement smoothing as a GEOMTRANSFORM
> operation.
>
> This raises another question: Do GEOMTRANSFORM operations also apply to
> labels? (RFC-72 suggests that this planned enhancement would not be in place
> yet)

A *layer* level geomtransform would be the way to go I guess, i.e.
apply the transformation directly even before it gets handed down to
the drawing functions (i.e. a hook in msLayerGetNextShape). In that
case the labelling will follow transparently. Your use-case would boil
down to two major tasks:
- implement layer level geomtransforms
- implement a smoothing geomtransform who's output is converted back
to a regular shapeobj. the geomtransform operation can use splines
internally or whatever other technique, as long as it is fed in a
shapeobj and it returns a smoothed version of it.

Coming back to your client's request, I imagine that they have a need
for this because the contours are too densely sampled for the zoomed
out levels? If that is the case, then there is a chance for them to be
rather "short" in zoomed out views, in which case their labelling will
not be pleasant. Joining multiple features together before smoothing
them would be the way to go in that case, but should probably be done
as a pre-processing step.

--
thomas

>
> Daniel
> --
> Daniel Morissette
> http://www.mapgears.com/
> Provider of Professional MapServer Support since 2000
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev


More information about the mapserver-dev mailing list