Returns a collection of paths shared by two lineal geometry objects.
Syntax
geometry ST_SharedPaths(geometry lineal1, geometry lineal2);Parameters
| Parameter | Description |
|---|---|
lineal1 | The shared path 1. The direction of paths in the returned collection is based on this geometry. |
lineal2 | The shared path 2. |
Description
ST_SharedPaths returns a geometry collection with two elements:
First element: paths that run in the same direction as
lineal1Second element: paths that run in the opposite direction to
lineal1
The direction of lineal1 determines how shared paths are classified.
Examples
Same-direction shared path
The following example finds shared paths between two linestrings that share a segment in the same direction.
SELECT ST_AsText(ST_GeometryN(g,1)), ST_AsText(ST_GeometryN(g,2))
FROM (
SELECT ST_SharedPaths(
'LINESTRING(-1 0,0 0,0 1)'::geometry,
'LINESTRING(0 0,0 1,1 1)'::geometry
) AS g
) AS t;Result:
st_astext | st_astext
----------------------------+-----------------------
MULTILINESTRING((0 0,0 1)) | MULTILINESTRING EMPTY
(1 row)The segment (0 0,0 1) is shared and runs in the same direction as lineal1, so it appears in the first element. The second element is empty because no paths run in the opposite direction.