[postgis-users] select AsSVG is beyond me, need some help

Darren Houston dhouston at beyondcompliance.ca
Wed Dec 20 06:26:40 PST 2006


Hi Bruce,

It's been years since I've worked in SVG, but I'll try to help you out.

Try starting with a SVG document such as follows;

<svg width="1024" height="768" preserveAspectRatio="xMinYMin" viewBox="27.98 
-26.13 0.16 0.14">

where viewBox = ( minx , miny, width, height ), which I calculated from your 
select extent() output, adding a little extra padding. You'll have to play 
with the values.

preserveAspectRatio is used so aspects are not changed.

Then add your path string (with optional styling) which contains the output of 
AsSvg();

<path id="munbounds" style="stroke:#00FF00;stroke-width:0.02;fill:none" d="M 
28.09089279176353 26.02902221677196 28.090887069700084 26.029689788796819 
28.090881347636643" />

Hope that helps,

Darren H.

On Wednesday 20 December 2006 05:47, Bruce Bushby wrote:
> Hello
>
> I'm trying to display a map layer in an svg document but just can't seem to
> get anything to work, any help would be much appreciated.
>
> The map is in shape file format using decimal degrees. I imported the map
> (munbounds) with the following command:
>
> shp2pgsql -s 4326 -d munbounds munbounds | psql -d SANDTON -U webuser
>
>
> The map imports perfectly and I can select it, but I can't select AsSVG,
> simply because I don't know what I'm doing :) This is what I've done so far
>
>
> I can view the extent like so:
> 	[postgres at svg ~]$
> 	[postgres at svg ~]$ psql -d SANDTON -U webuser -c "select
> astext(extent(the_geom)) from munbounds" astext
> ---------------------------------------------------------------------------
>----------------------------------------------------------------------------
>------------------------------------ POLYGON((27.9827041625977
> -26.1347217559814,27.9827041625977 -25.9942073822021,28.1381454467773
> -25.9942073822021,28.1381454467773 -26.1347217559814,27.9827041625977
> -26.1347217559814)) (1 row)
>
>
> and I get box information like so:
> 	[postgres at svg ~]$ psql -d SANDTON -U webuser -c "select extent (the_geom)
> from munbounds" extent
> 	--------------------------------------------------------------------------
>-- BOX(27.9827041625977 -26.1347217559814,28.1381454467773
> -25.9942073822021) (1 row)
>
> then (and this is where I think I've got it all wrong) I take those values
> and use them in a select: [postgres at svg ~]$ psql -d SANDTON -U webuser -c
> "SELECT  AsSVG(intersection(Simplify(the_geom,80),
> GeometryFromText('POLYGON((27.9827041625977
> -26.1347217559814,27.9827041625977 -25.9942073822021,28.1381454467773
> -25.9942073822021,28.1381454467773 -26.1347217559814,27.9827041625977
> -26.1347217559814))',4326)),1,1) FROM munbounds WHERE the_geom &&
> setSRID('BOX3D(27.9827041625977 -26.1347217559814,28.1381454467773
> -25.9942073822021)'::box3d,4326)" assvg
> 	-------
>
> 	(1 row)
>
> But I get nothing back.
>
> If I do a simple select AsSVG I get rows of numbers, but they don't seem to
> work when I use them in an SVG document: [postgres at svg ~]$ psql -d SANDTON
> -U webuser -t -c "select AsSVG(the_geom) from munbounds" M
> 28.09089279176353 26.02902221677196 28.090887069700084 26.029689788796819
> 28.090881347636643.............lots of these
>
> The map should be a simple municipal boundary about 7 Kilometres x 5
> Kilometres. My svg document has a viewbox of 0 0 1024 768. Is there
> something obvious that I'm not doing? besides not getting svg path results
> :)
>
>
> Cheers
> Bruce
>
>
>
>
> _______________________________________________
> 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