Constructs a LineString geometry object from a Well-Known Binary (WKB) value and an optional spatial reference identifier (SRID).
Syntax
geometry ST_LineFromWKB(bytea WKB);
geometry ST_LineFromWKB(bytea WKB, integer srid);Parameters
| Parameter | Type | Description |
|---|---|---|
| WKB | bytea | The WKB representation of the geometry. |
| srid | integer | The SRID to assign to the geometry object. |
Usage notes
If
sridis omitted, the default SRID 0 is used.If the WKB value does not represent a LineString, the function returns NULL.
If the input is confirmed to be a LineString, use ST_GeomFromWKB instead, which is more efficient.
Examples
The following example verifies both the normal return value and the NULL return behavior in a single query.
SELECT
ST_AsText(ST_LineFromWKB(E'\\x010200000002000000000000000000f03f000000000000004000000000000008400000000000001040')) AS line_result,
ST_LineFromWKB(E'\\x0101000000000000000000f03f0000000000000040') IS NULL AS null_return;Expected output:
line_result | null_return
-----------------+------------
LINESTRING(1 2,3 4) | t
(1 row)The first column confirms a valid LineString is returned from a LineString WKB input. The second column confirms NULL is returned when the input represents a Point, not a LineString.
该文章对您有帮助吗?