ST_AsTWKB

更新时间:
复制 MD 格式

Returns the Tiny Well-Known Binary (TWKB) representation of one or more geometry objects as a bytea value.

Syntax

Single geometry

bytea ST_AsTWKB(
    geometry  g1,
    integer   decimaldigitsXY,
    integer   decimaldigitsZ,
    integer   decimaldigitsM,
    boolean   includeSizes,
    boolean   includeBoundingBoxes
);

Geometry array with unique IDs

bytea ST_AsTWKB(
    geometry[]  geometries,
    bigint[]    uniqueIds,
    integer     decimaldigitsXY,
    integer     decimaldigitsZ,
    integer     decimaldigitsM,
    boolean     includeSizes,
    boolean     includeBoundingBoxes
);

Parameters

ParameterTypeDefaultDescription
g1geometryThe geometry object to encode as TWKB.
geometriesgeometry[]The geometry objects to encode as TWKB.
uniqueIdsbigint[]The unique identifiers of the geometry objects in geometries.
decimaldigitsXYinteger0The number of decimal places to retain in the x and y coordinates.
decimaldigitsZinteger0The number of decimal places to retain in the z coordinate.
decimaldigitsMinteger0The number of decimal places to retain in the m coordinate.
includeSizesbooleanfalseSpecifies whether to include the size of each geometry object in the output.
includeBoundingBoxesbooleanfalseSpecifies whether to include the bounding box of each geometry object in the output.

Examples

Convert a point geometry to its TWKB representation:

SELECT ST_AsTWKB(ST_GeomFromText('POINT(116 40)', 4326));

Output:

       st_astwkb
------------------------
 \xa1008082880b80a4e803
(1 row)