[mapserver-dev] A Question

Stephen Woodbridge woodbri at swoodbridge.com
Sun Jul 12 12:35:13 EDT 2009


Kiran,

I would defer to Thomas on this but another possibility might be to just 
have one cache slot and to also cache the size of the image asscoated 
with that slot. Then if you need a larger instance, regenerate it at the 
larger size. If you need a copy smaller than the size currently cached, 
then you might be able to scale that down. This would save space if you 
have a lot of images in the cache. This could happen if the sizes are 
floating point numbers and there are roundoff errors so there might be 
some value in rounding the size values so you get better cache hits.

Again, I am unsure of how antialiased images scale and rotate which 
might make the above suggestion worthless. I do think you might need to 
consider rounding the size and angle values to avoid numerical noise in 
the numbers or by applying a floating point EPSILON comparision like:

matches = abs(cacheSize - thisSize) < EPSILON  // this is good

Were EPSILON is a small number, instead of

matches = (cacheSize - thisSize) == 0.0  // this is bad

But you probably already know this. :)

-Steve W.

kiran varma wrote:
> Thanks for that! You explained it perfectly! :)
> 
> On Sun, Jul 12, 2009 at 8:23 PM, Stephen Woodbridge 
> <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.com>> wrote:
> 
>     kiran varma wrote:
> 
>         In the IRC that took place on the 8th July, 2009
>         (http://logs.qgis.org/mapserver/%23mapserver.2009-07-08.log),
>         tbonfort mentioned that we would need to create a special cache
>         to hold SVG symbols based on their size and orientation. I am
>         having trouble grasping the need for such a cache. Would it be
>         possible for someone to elaborate on it a little?
> 
>         So far, what I have understood of the overall proposed solution
>         is the following:
> 
>         1. Trigger the SVG parser and renderer according to
>                SYMBOL
>                        TYPE VECTOR
>                        FILE "/path/to/file.svg"
>                END
>         2. On triggering, generate a pixmap of the SVG file and store it
>         in cache to prevent having to rasterize it every time. Keep this
>         step in a single function to allow for using different rendering
>         libraries later on. Parsing is done throught the svg_viewer
>         example provided in the AGG sources.
>         3. Render the pixmap using a rendering library (such as AGG or GD).
> 
>         Why is there a need to have a cache for SVG symbols based on
>         size and orientation?
> 
> 
>     I'm assuming that this is because each size and orientation will
>     generate a different pixmap image. And while it might be possible to
>     rotate and scale an image, I think that this would generate a less
>     than desirable end result.
> 
>     If you first rendered an svg image very small and cached that, then
>     later needed a larger version of it, scaling it larger would become
>     pixelated, but if you rerendered it larger then that would look
>     better. Also since these might be rendered with antialiasing, that
>     might not scale or rotate nicely either.
> 
>     -Steve W
> 
> 



More information about the mapserver-dev mailing list