PostGIS function AsSVG()

As of PostGIS version 0.9, AsSVG() is part of the standard distribution. Thanks to Olivier Courtin for providing patches and for integrating it within PostGIS. AsSVG() allows you to deliver absolute and relative SVG path-notation for lines, multilines, polygons and multipolygons and SVG cx,cy or x,y notation for point and multipoint features. Multipoint geometries are delimited by commas (","), GeometryCollection geometries are delimited by semicolons (";").

AsSVG() PostGIS function

Usage:SELECT AsSvg(geometry,[rel],[precision]) FROM <table>

Note: svg has a y-down coordinate system so y-coords are multiplied by -1

AsSVGBox() plPgsql function

As of PostGIS version 1.0 the default data-type for geometry has changed to LWGEOM. As LWGEOM does not have a BOX-only subclass there's no way to receive SVGViewBox-notation from a Box3D or Box2D query. I've written a simple plpgsql function to accomplish this task. It returns SVGRect- or SVGViewBox notation for the geometry's bounding box.

Usage:SELECT AsSvgBox(geometry,[rel],[precision]) FROM <table>

Download postgis_assvgbox-1.0.tar.gz