Returns the Scalable Vector Graphics (SVG) path data for a geometry or geography object.
Syntax
text ST_AsSVG(geometry geom, integer rel, integer maxdecimaldigits);
text ST_AsSVG(geography geog, integer rel, integer maxdecimaldigits);Description
ST_AsSVG converts a geometry or geography object into SVG path data as a text string.
By default, coordinates use absolute moves (rel=0). Set rel=1 to switch to relative moves.
Parameters
| Parameter | Description |
|---|---|
geom | The geometry object to convert. |
geog | The geography object to convert. |
rel | Path coordinate mode. 0 (default) uses absolute moves. 1 uses relative moves. |
maxdecimaldigits | Maximum number of decimal places in the output. Default: 15. |
Examples
Point (absolute mode)
SELECT ST_AsSVG(ST_GeomFromText('POINT(116 40)',4326));Output:
cx="116" cy="-40"
(1 row)The y-coordinate is negated because SVG uses a top-down coordinate system, while geographic coordinates increase upward.
该文章对您有帮助吗?