名前

ST_Touches — 二つのジオメトリが少なくとも一つの共有点を持ち、かつ内部でインタセクトしていないようになっているかテストします。

概要

boolean ST_Touches(geometry A, geometry B);

説明

AとBがインタセクトするがAの内部とBの内部がインタセクトしない場合にはTRUEを返します。AとBが少なくとも一つの共有点があり、共有点が少なくとも一つの境界の上にあることと同じです。ポイント/ポイント入力では、ポイントは境界を持たないため、常にFALSEを返します。

数学用語では: ST_Touches(A, B) ⇔ (Int(A) ⋂ Int(B) = ∅) ∧ (A ⋂ B ≠ ∅)

この関係は、二つのジオメトリのDE-9IM交差行列がどれか一つに合致すると、関係が保持されていることになります:

  • FT*******

  • F**T*****

  • F***T****

[注記]

この関数を実行すると、対象ジオメトリにおいて使用できるインデックスを使用したバウンディングボックスによる比較が自動的に行われます。 インデックスの使用を避けるには_ST_Touchesを代わりに使います。

Enhanced: 3.0.0 GEOMETRYCOLLECTIONへの対応が可能となりました

このメソッドはOGC Simple Features Implementation Specification for SQL 1.1の実装です。 s2.1.1.2 // s2.1.13.3

このメソッドはSQL/MM仕様の実装です。 SQL-MM 3: 5.1.28

次の例ではST_Touches述語はTRUEを返します。

Two Polygons touching along a boundary segment.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'POLYGON ((10 190,10 70,80 70,80 130,50 160,120 160,120 190,10 190))'::geometry AS a,
  'POLYGON ((80 110,140 140,190 110,180 40,140 10,80 50,80 70,80 110))'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-01

Two Polygons touching at a boundary point.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'POLYGON ((10 190,10 70,80 70,80 130,50 160,120 160,120 190,10 190))'::geometry AS a,
  'POLYGON ((140 140,190 110,180 40,140 10,80 70,140 140))'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-02

A Polygon and a LineString touching at the line endpoint.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'POLYGON ((80 10,50 40,50 90,80 130,140 120,160 70,140 30,80 10))'::geometry AS a,
  'LINESTRING (30 190,180 150,160 70)'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-03

Two LineStrings touching at their endpoints.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'LINESTRING (10 10,60 140,140 190)'::geometry AS a,
  'LINESTRING (140 190,190 10)'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-04

Two LineStrings touching where an endpoint meets the other line.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'LINESTRING (10 10,60 140,140 190)'::geometry AS a,
  'LINESTRING (60 140,190 10)'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-05

A Point touching a Polygon boundary.

Code
SELECT ST_Touches(a, b)
FROM (SELECT
  'POLYGON ((30 30,10 110,40 190,120 170,180 180,170 100,130 10,30 30))'::geometry AS a,
  'POINT (170 100)'::geometry AS b
) AS example;
出力:
t
Figure
Geometry figure for visual-st-touches-06
Code
SELECT ST_Touches('LINESTRING(0 0,1 1,0 2)'::geometry, 'POINT(1 1)'::geometry);
出力:
f
Figure
Geometry figure for visual-st-touches-07
Code
SELECT ST_Touches('LINESTRING(0 0,1 1,0 2)'::geometry, 'POINT(0 2)'::geometry);
出力:
t
Figure
Geometry figure for visual-st-touches-08