[mapserver-dev] Re: Update on SVG

Daniel Morissette dmorissette at mapgears.com
Mon Jul 27 23:49:07 EDT 2009


Hi Kiran,

Let's discuss your questions on the -dev list where other developers can 
provide advice as well.

kiran varma wrote:
> 
> 1. In the MapServer code, where is the Mapfile getting parsed? I want to 
> add to the parser so that it calls my parsing function when it comes 
> across the SVG part in the Mapfile.

New parser tokens are defined in maplexer.l, which is processed by flex 
to generate maplexer.c. The Linux Makefile takes care of calling flex 
automatically.

Then most of the parser logic is in mapfile.c. That's where you add the 
code to read the new token and set its value in the corresponding C 
structure. The symbolObj is one of a few exceptions and its parser logic 
is in mapsymbol.c instead of mapfile.c... look for loadSymbol().

The parser also comes with write functions for each data structure, used 
by msSaveMap().

I see that your draft RFC suggests that the following format will be 
used for the SVG symbols:

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

However I think it was discussed at some point that using an explicit 
SVG type would be better to avoid confusion with the VECTOR type:

       SYMBOL
          TYPE SVG
          FILE "/path/to/file.svg"
       END


> 2. How exactly do I store the SVG data? You mentioned pixmaps, but the 
> concept is very generic. Is there some specific format that MapServer 
> already uses or should  I be coming up with my own format (eg. a 2D 
> array of int's)?

I don't think we need to "store the SVG data"... since I believe the AGG 
code takes care of reading and rendering the SVG symbol for us.

What we need to do is create a temporary pixmap to which we render the 
SVG... what we store (or cache) is the rendered version of the symbol 
for a given size and symbol combination, and then that image is "pasted" 
on top of the map at the correct location.

You should NOT come up with your own pixmap format. You need to find 
something that will work with both the GD and AGG renderers. A 
gdImagePtr might be an option but I'm not sure. I think Thomas would be 
best to advise on the pixmap format to use.

> 3. Once the pixmap is created, we had discussed about storing different 
> versions of the SVG symbol based on orientation and size. Do we want 
> this to be on demand (the user requests a new size or orientation, so we 
> generate one and add it to the cache) or is it done automatically in the 
> beggining for all possible sizes and rotations (seems like a bad idea!).
> 

On demand, of course.

Daniel
-- 
Daniel Morissette
http://www.mapgears.com/


More information about the mapserver-dev mailing list