Name

ST_LineCrossingDirection — 二つのラインストリングがどのように交差しているかを示す数字を返します。

Synopsis

integer ST_LineCrossingDirection(geometry linestringA, geometry linestringB);

説明

• 0: クロスが無い

• -1: 左クロス

• 1: 右クロス

• -2: 複数クロスで最後が左

• 2: 複数クロスで最後が右

• -3: 複数クロスで開始終了ともに左

• 3: 複数クロスで開始終了ともに右

Availability: 1.4

例

SELECT ST_LineCrossingDirection(lineA, lineB) As A_cross_B,
ST_LineCrossingDirection(lineB, lineA) As B_cross_A
FROM (SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As lineA,
ST_GeomFromText('LINESTRING (20 140, 71 74, 161 53)') As lineB
) As foo;

A_cross_B | B_cross_A
-----------+-----------
-1 |         1

SELECT ST_LineCrossingDirection(lineA, lineB) As A_cross_B,
ST_LineCrossingDirection(lineB, lineA) As B_cross_A
FROM (SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As lineA,
ST_GeomFromText('LINESTRING(171 154,20 140,71 74,161 53)') As lineB
) As foo;

A_cross_B | B_cross_A
-----------+-----------
3 |        -3

SELECT ST_LineCrossingDirection(lineA, lineB) As A_cross_B,
ST_LineCrossingDirection(lineB, lineA) As B_cross_A
FROM (SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As lineA,
ST_GeomFromText('LINESTRING(5 90, 71 74, 20 140, 171 154)') As lineB
) As foo;

A_cross_B | B_cross_A
-----------+-----------
-2 |         2

SELECT s1.gid, s2.gid, ST_LineCrossingDirection(s1.geom, s2.geom)
FROM streets s1 CROSS JOIN streets s2
ON (s1.gid != s2.gid AND s1.geom && s2.geom )
WHERE ST_LineCrossingDirection(s1.geom, s2.geom)
> 0;

ST_Crosses