Returns a complete or partial SVG document which renders the geometries in a group.
SELECT ST_Geometry::ST_AsSVGAggr( Shape ) FROM SpatialShapes
The following returns a complete SVG document from SVG path data with relative coordinates limited to 5 digits after the decimal place.
SELECT '<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg viewBox="-10 -10 20 12" xmlns="http://www.w3.org/2000/svg" version="1.1"> <path fill="lightblue" stroke="black" stroke-width="0.1%" d="' || ST_Geometry::ST_AsSVGAggr( Shape, 'PathDataOnly=Yes' ) || '"/></svg>' FROM SpatialShapes
The following statements create a web service that returns a complete SVG document that renders all geometries in the SpatialShapes table. If the database server is started with the -xs http option, you can use a browser that supports SVG to display the SVG. To do this, browse to the address http://localhost/demo/svg_shapes This works assuming that the browser and the database server are on the same computer, and that the database is named demo).
CREATE SERVICE svg_shapes TYPE 'RAW' USER DBA AUTHORIZATION OFF AS CALL svg_shapes();CREATE PROCEDURE svg_shapes() RESULT( svg LONG VARCHAR ) BEGIN CALL sa_set_http_header( 'Content-type', 'image/svg+xml'); SELECT ST_Geometry::ST_AsSVGAggr( Shape ) FROM SpatialShapes; END;
SQL/MM (ISO/IEC 13249-3: 2006) Vendor extension