Returns a complete or partial SVG document which renders the geometries in a group.
ST_Geometry::ST_AsSVGAggr(geometry-column[ ORDER BY order-by-expression [ ASC | DESC ], ... ] [, format])
Name | Type | Description |
---|---|---|
geometry-column |
ST_Geometry |
The geometry value to contribute to the SVG figure. Typically this is a column. |
format |
VARCHAR(128) |
A string defining the parameters to use when converting each geometry value to a SVG representation. If not specified, the default is 'SVG'. |
LONG VARCHAR Returns a complete or partial SVG document which renders the geometries in a group.
The ST_AsSVGAggr method returns a complete or partial SVG document that can be used to graphically display the union of a group of geometries using an SVG viewer. Most major web browsers with the exception of Microsoft Internet Explorer include built-in SVG viewers.
A number of different options are supported and the desired format is selected using the optional format parameter. If the format parameter is not specified, the default is 'SVG'.
The format string defines an output format and parameters to the format. The format string has one of the following formats:
format-name |
format-name(parameter1=value1;parameter2=value2;...) |
parameter1=value1;parameter2=value2;... |
The first format specifies the format name and no parameters. All format parameters use their default values. The second format specifies the format name and a list of named parameter values. Parameters that are not supplied use their default values. The last format specifies only parameter values, and the format name defaults to 'SVG'.
The following format names may be used:
SVG The Scalable Vector Graphics (SVG) 1.1 format defined by the World Wide Web Consortium (W3C).
The following format parameters can be specified:
Format Name | Parameter Name | Default Value | Allowed Values | Description |
---|---|---|---|---|
SVG | Approximate | Yes | Yes or No | The Approximate parameter specifies whether or not to reduce the size of the output SVG document with a slight reduction in visible detail. The SVG data is approximated by not including points which are within the line width of the last point. With multiple megabyte geometries this can result in compression rates of 80% or more. |
SVG | Attribute | Automatically generated optional attributes | One or more SVG attributes that can be applied to SVG shape elements | By default, optional SVG shape attributes such as fill, stroke and stroke-width are generated. If the Attributes parameter is specified, then no optional SVG shape attributes are generated, and the Attribute value is used instead. Ignored if PathDataOnly=Yes is specified. |
SVG | DecimalDigits | Based on the number of decimal digits in the spatial reference system's snap to grid grid-size. The maximum default value is 5 and the minimum is 0. | integer | The DecimalDigits parameter limits the number of digits after the decimal place for coordinates generated in the SVG output. Specifying a negative number of digits indicates that the full precision of coordinates should be included in the SVG output. |
SVG | PathDataOnly | No (a complete SVG document is generated) | Yes or No | The PathDataOnly parameter specifies whether or not only data for the SVG Path Element should be generated. The PathDataOnly example below demonstrates how PathDataOnly=Yes can be used to build a complete SVG document that can be displayed. By default a complete SVG document is generated. The path data returned by PathDataOnly=Yes can be used to build more flexible SVG documents containing other elements, such as text. |
SVG | RandomFill | Yes | Yes or No | The RandomFill parameter specifies whether or not polygons should be filled by a randomly generated color. The sequence of colors used does not follow a well-defined sequence, and typically changes each time SVG output is generated. No indicates that only an outline of each polygon is drawn. The RandomFill parameter is ignored if the Attribute or PathDataOnly=Yes parameter is specified. |
SVG | Relative | Yes | Yes or No | The Relative parameter specifies if coordinates should be output in relative (offset) or absolute formats. Relative coordinate data is typically more compact than absolute coordinate data. |
The ORDER BY clause can be specified to control how overlapping geometries are displayed, with geometries displayed in order from back to front. If not specified, the geometries are displayed in an order that depends on the execution plan selected by the query optimizer, and this may vary between executions.
By default, ST_AsSVGAggr uses the original format for a geometry, if it is available. Otherwise, the internal format is used. For more information about internal and original formats, see STORAGE FORMAT clause, CREATE SPATIAL REFERENCE SYSTEM statement.
SQL/MM (ISO/IEC 13249-3: 2006) Vendor extension
The following returns a complete SVG document with polygons filled with random colors.
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; |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |