Peter Thompson wrote:
> There was an SVG map example thread a few weeks ago.  Following it 
> you could see an SVG file get reduced in size through a series of 
> steps.  The process was pretty impressive and it was fun to see it 
> evolve.
> 
> The steps are:
> 1) use the <path> element vs <polyline> or <polygon>
> 2) use Z (closepath)where appropriate
> 3) remove redundant points
> 3) use relative commands where appropriate
> 4) use horizontal and vertical lineto command where appropriate
> 5) remove all unnecessary whitespace
> 
> Following those steps, I reduced my svg file size from 429K to 322K, 
> and the svgz file size went from 124K to 91K.
> 
> Please respond if I missed any steps.

Two 3) Points? :-)
After 4), you may have to collapse identical consecutive lines: h2h6h1 
can be replaced by h9.

As André mentions, there may be a first step to reduce unecessary 
precision, ie. to keep only a relevant number of digits per coordinate.
How much is the hardest part to estimate: too much and space is lost, 
too low, and precision is lost. It depends on the viewport, and how much 
zoom can go: Adobe limits the zoom capability of its viewer (by 
commands) but zooming by scripting isn't limited.

If somebody has a formula to estimate the necessary number of digits 
based on the above data, I would be interested...

Note that the data I worked on was already rounded to integer values. 
That's why I had so much redundant data: close coordinates, differing 
only by their decimals, are rounded to same values.
And that's why, unlike what André thinks, we can get so many h and l 
commands, because even if two consecutive points have initially 
different x and y coordinates, they can end with same x or y (or both) 
after rounding. And perhaps in some cities (New York?), they can be 
quite common by nature...

To answer two other points by André:

7) Join short paths. Of course, this is relevant only to anonymous 
paths... If paths have IDs, they can't be joined.
For example, on 'my' map, each path was a country outline, including 
islands (jumps with Ms), so each path element has both a semantic 
meaning and a functionnality (fill the country with a color to show it 
is selected), so I couldn't join them.

8) To use cubic spline seems hard to do. Outlines would be smoother, but 
how to be sure they fit to the real data without making extra curves?

Actually, the first and foremost rule is to study the data to be 
optimized, to apply relevant steps. And see the result of each step, to 
see what is the next step to apply.

I am planning to do such routines: one to parse the path and break it 
into elementary steps stored in an array, a linked list, or whatever 
structure is relevant. Then create some routines manipulating such data, 
each doing a simple step. Processing could be optimized (eg. removing 
redundant points and transforming to relative lines) but I prefer to 
separate them to see the results and get extra flexibility, plus it is 
easier to debug.

That's what I did for the program to optimize the map, except it is 
still a bit too dependent on the data format I had then.

Note that I plan to release the Lua program on the Web once I put up a 
decent SVG page, but I can send it to whoever want it (and ask it 
privately... No need to spam this list). It is Lua, so even if you don't 
know this language, it is quite easy to read.
The code is actually quite simple, it just needs to be careful about 
details (number of loops, secondary index, etc.).

-- 
Philippe Lhoste
--  (near) Paris -- France
--  Professional programmer and amateur artist
--  http://Phi.Lho.free.fr
--  For servers mangling my From and Reply-To fields,
--  please send private answers to PhiLho(a)GMX.net
--  --  --  --  --  --  --  --  --  --  --  --  --  --


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to