[postgis-users] AsSVG() and precision control
strk at refractions.net
strk at refractions.net
Thu Oct 14 01:59:24 PDT 2004
On Thu, Oct 14, 2004 at 10:06:23AM +0200, Klaus Foerster wrote:
> the current version of AsSVG() allows specification of the number of
> significant digits as
> second argument. this is meaningful on a single value, but looses meaning
> when coordinates
> are taken into group (e.g. different number of digits in x, y coordinates
> or relative
> path-notation). i've written a patch for postgis_svg.c that uses the
> following approach:
>
> if you omit the second argument, values are preserved as they are and
> formatted as %.*g,
> if you use a second argument, values are formatted with desired precision
> using ".*f"
>
> you can find a patch at http://svg.cc/pg/assvg/assvg-0.5.patch along with a
> test-page,
> showing sample queries and their results at
> http://svg.cc/pg/assvg/1_output.txt
>
> having something like apply_grid() in postgis (1.0?) would make this
> solution obsolete, but
> as long as it's not there, i think we should provide a way to specify
> precision within AsSVG().
> any other thoughts on that subject from the rest of the group?
>
> klaus
Your patch does not do what reported:
if (precision >= 0) sprintf(result, "M %.*f %.*f h%.*f v%.*f h%.*....
else sprintf(result, "M %.*g %.*g h%.*g v%.*g h%.*g ...
Precision defaults to 15, so you need to give it an explicit negative
number for the %g to take effect. Default would be 0 padded numbers.
What I see is that the problem only arises for relative moves, where
number of significant digits wants to be different between absolute
and relative values.
The apply_grid() won't solve this as absolute numbers will fall on a grid,
still relative values would be hard to control in precision.
A proposal I can make is that:
- On "absolute" are requested all values will have 'precision'
number of significant digits
- On "relative" way initial (absolute) values will have 15
significant digits, and relative values will have 'precision'
number of significant digits.
Do you think this would solve the problem ?
--strk;
>
> --
> O-.
> /_ )
> | (U
> klaus* /|
> / /
> ~ ~
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list