ST_AsSVG

更新时间:
复制 MD 格式

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

ParameterDescription
geomThe geometry object to convert.
geogThe geography object to convert.
relPath coordinate mode. 0 (default) uses absolute moves. 1 uses relative moves.
maxdecimaldigitsMaximum 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.