| 1 | |
| 2 | == MS RFC - SVG Symbol Support with AGG == |
| 3 | |
| 4 | Kiran Anjaneya Varma Alluri |
| 5 | July 12, 2009 |
| 6 | 1 Overview. |
| 7 | Popular tools such as Inkscape generate SVG graphics natively. So far MapServer has not supported |
| 8 | the SVG format, which leaves many users with the extra work of converting between formats. This |
| 9 | RFC aims to introduce support for SVG graphics as an alternate method to de |
| 10 | ne vector symbols in |
| 11 | the MapServer symbolset. |
| 12 | 2 Method. |
| 13 | The SVG parsing and rendering will be triggered by the following syntax: |
| 14 | |
| 15 | {{{ |
| 16 | SYMBOL |
| 17 | TYPE VECTOR |
| 18 | FILE / path / to / f i l e . svg |
| 19 | END |
| 20 | }}} |
| 21 | |
| 22 | The choice for using a SYMBOL for the task is to allow for the reuse of the SVG symbol easily within |
| 23 | classes. |
| 24 | 3 Technical Overview |
| 25 | In order to support the SVG format, we make use of the AGG library. The reasons for going with the |
| 26 | AGG library are: |
| 27 | 1. It has already been integrated into MapServer. While other popular libraries, such as Cairo, can |
| 28 | be used, they would require eort to integrate into MapServer and would further introduce many |
| 29 | dependencies into the MapServer code. |
| 30 | 2. It is a very lightweight library and delivers performance equal to, and sometimes higher than |
| 31 | other popular libraries. |
| 32 | |
| 33 | There are some disadvantages that emerge from using the AGG library. Foremost, the AGG library |
| 34 | has an incomplete SVG speci |
| 35 | cation. To avoid having to reimplement the missing subset of the |
| 36 | speci |
| 37 | cation (which would, without a doubt, be a non-trivial task, and would add to the complexity |
| 38 | of this RFC), we stick by the following techniques: |
| 39 | |
| 40 | 1. A modular design is used, where the generation of the intermediate pixmap is done by a single |
| 41 | function so that it can be easily modi |
| 42 | ed to adjust to a dierent library. Thus,using a pixmap |
| 43 | will allow us to use any rendering library. |
| 44 | 2. The unimplemented subset of the SVG speci |
| 45 | cation is clearly provided to users in the documen- |
| 46 | tation to prevent frustration on their side. |
| 47 | 1 |
| 48 | To implement this functionality, the following steps needs to be accomplished: |
| 49 | |
| 50 | 1. Implement an SVG parser. For this, we directly make use of the SVG Viewer example provided |
| 51 | along with the AGG sources. |
| 52 | 2. Write a single function to render a parsed SVG |
| 53 | le to a pixmap. The pixmap will be an inter- |
| 54 | mediate form that can then be rendered. The pixmap will be stored in cache memory to prevent |
| 55 | having to constantly be rasterized it every time a symbol is drawn. |
| 56 | 3. Render the pixmap into the |
| 57 | nal image |
| 58 | le. This will be done using a mixture of the AGG and |
| 59 | GD libraries. |
| 60 | 4 Files Added |
| 61 | |
| 62 | Finally, the SVG parsing and pixmap generation functions will be stored in source |
| 63 | files stored at |
| 64 | |
| 65 | {{{ |
| 66 | / mapserver / r e n d e r e r s / agg / svg / |
| 67 | }}} |
| 68 | |
| 69 | The |
| 70 | files within the above directory include the files for: |
| 71 | • SVG Parsing |
| 72 | • Trigger Function (based on Map |
| 73 | file syntax) |
| 74 | • SVG to Pixmap generation |
| 75 | All |
| 76 | files are within the C++ 'mapserver' namespace. |
| 77 | |
| 78 | 5 Documentation |
| 79 | The following documentation needs to be prepared for this project: |
| 80 | 1. Missing SVG speci |
| 81 | cation document. |
| 82 | 2. Basic usage tutorial with examples. |
| 83 | |
| 84 | |