Skip to content

GSoC_SVG_Symbols_FIRST_DRAFT_OF_THE_MS RFC

Thomas Bonfort edited this page Apr 6, 2012 · 2 revisions

Date: 2009/06/26
BR
Author: Kiran Anjaneya Varma Alluri
BR
Contact: kiran.varma2k7 at gmail.com
BR
Last Edited: 2009/07/12
BR
Status: Draft
BR
Version: MapServer 6.0
BR
Id: $Id: $

1 '''Overview'''
Popular tools such as Inkscape generate SVG graphics natively. So far MapServer has not supported
the SVG format, which leaves many users with the extra work of converting between formats. This
RFC aims to introduce support for SVG graphics as an alternate method to de\x1Cne vector symbols in
the MapServer symbolset.

'''2 Method.'''

The SVG parsing and rendering will be triggered by the following syntax:

SYMBOL                                                                                                                                                                                                                                                               
         TYPE VECTOR                                                                                                                                                                                                                                                 
         FILE / path / to / f i l e . svg                                                                                                                                                                                                                            
      END                                                                                                                                                                                                                                                            

The choice for using a SYMBOL for the task is to allow for the reuse of the SVG symbol easily within
classes.

'''3 Technical Overview.'''

In order to support the SVG format, we make use of the AGG library. The reasons for going with the
AGG library are:

  1. It has already been integrated into MapServer. While other popular libraries, such as Cairo, can
    be used, they would require effort to integrate into MapServer and would further introduce many
    dependencies into the MapServer code.
  2. It is a very lightweight library and delivers performance equal to, and sometimes higher than
    other popular libraries.

There are some disadvantages that emerge from using the AGG library. Foremost, the AGG library
has an incomplete SVG specification. To avoid having to reimplement the missing subset of the
specification (which would, without a doubt, be a non-trivial task, and would add to the complexity
of this RFC), we stick by the following techniques:

  1. A modular design is used, where the generation of the intermediate pixmap is done by a single
    function so that it can be easily modified to adjust to a different library. Thus, using a pixmap
    will allow us to use any rendering library.
  2. The unimplemented subset of the SVG specification is clearly provided to users in the Documentation
    to prevent frustration on their side.

To implement this functionality, the following steps needs to be accomplished:

  1. Implement an SVG parser. For this, we directly make use of the SVG Viewer example provided
    along with the AGG sources.
  2. Write a single function to render a parsed SVG \x1Cfile to a pixmap.The pixmap will be an intermediate form that can then be rendered.The pixmap will be stored in cache memory to prevent having to constantly be rasterized it every time a symbol is drawn.
  3. Render the pixmap into the final imagefile. This will be done using a mixture of the AGG and GD libraries.

'''4 Files Added.'''

Finally, the SVG parsing and pixmap generation functions will be stored in source \x1Cfiles stored at

/ mapserver / r e n d e r e r s / agg / svg /                                                                                                                                                                                                                        

The \x1Cfiles within the above directory include the files for:

• SVG Parsing.                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                 
• Trigger Function (based on '''Map\x1Cfile''' syntax).                                                                                                                                                                                                          
• SVG to Pixmap generation.                                                                                                                                                                                                                                      

All \x1Cfiles are within the C++ 'mapserver' namespace.

'''5 Documentation'''

The following documentation needs to be prepared for this project:

  1. Missing SVG specification document.
  2. Basic usage tutorial with examples.
Clone this wiki locally