バージョンごとのドキュメント一覧

8.8. 幾何データ型 #

<title>Geometric Types</title>

Geometric data types represent two-dimensional spatial objects. <xref linkend="datatype-geo-table"/> shows the geometric types available in <productname>PostgreSQL</productname>. 幾何データ型は2次元空間オブジェクトを表現します。 表 8.20は、PostgreSQLで使用可能な幾何データ型を列挙したものです。

表8.20 幾何データ型

<title>Geometric Types</title>
型名格納サイズ説明表現
point16バイト平面における座標点(x,y)
line32バイト無限の直線{A,B,C}
lseg32バイト有限の線分((x1,y1),(x2,y2))
box32バイト矩形((x1,y1),(x2,y2))
path16+16nバイト閉経路(多角形に類似)((x1,y1),...)
path16+16nバイト開経路[(x1,y1),...]
polygon40+16nバイト多角形(閉経路に類似)((x1,y1),...)
circle24バイト<(x,y),r>(中心と半径)

A rich set of functions and operators is available to perform various geometric operations such as scaling, translation, rotation, and determining intersections. They are explained in <xref linkend="functions-geometry"/>. 拡大縮小、平行移動、回転、交点の算出といった様々な幾何学的操作を行う関数と演算子の集合が豊富に揃っています。 このことについては9.11に説明があります。

8.8.1. 座標点 #

<title>Points</title>

Points are the fundamental two-dimensional building block for geometric types. Values of type <type>point</type> are specified using either of the following syntaxes: 座標点は幾何データ型の基礎となる2次元構成要素です。 point型の値は次の構文のいずれかで指定されます。

( x , y )
  x , y

where <replaceable>x</replaceable> and <replaceable>y</replaceable> are the respective coordinates, as floating-point numbers. ここでxyは、それぞれの座標を浮動小数点数数値で表したものです。

Points are output using the first syntax. 座標点は1番目の構文で出力されます。

8.8.2. 直線 #

<title>Lines</title>

Lines are represented by the linear equation <replaceable>A</replaceable>x + <replaceable>B</replaceable>y + <replaceable>C</replaceable> = 0, where <replaceable>A</replaceable> and <replaceable>B</replaceable> are not both zero. Values of type <type>line</type> are input and output in the following form: 直線は線形方程式Ax + By + C = 0で表現されます。ここでABは同時に0になることはありません。 line型の値は以下の書式で入出力されます。

{ A, B, C }

Alternatively, any of the following forms can be used for input: 入力のためには以下の書式を代替として使用することもできます。

[ ( x1 , y1 ) , ( x2 , y2 ) ]
( ( x1 , y1 ) , ( x2 , y2 ) )
  ( x1 , y1 ) , ( x2 , y2 )
    x1 , y1   ,   x2 , y2

where <literal>(<replaceable>x1</replaceable>,<replaceable>y1</replaceable>)</literal> and <literal>(<replaceable>x2</replaceable>,<replaceable>y2</replaceable>)</literal> are two different points on the line. ここで(x1,y1)(x2,y2)はその直線上の2つの異なる点です。

8.8.3. 線分 #

<title>Line Segments</title>

Line segments are represented by pairs of points that are the endpoints of the segment. Values of type <type>lseg</type> are specified using any of the following syntaxes: 線分は終点を示す2つの点の組み合わせで表現されます。 lseg型の値は以下の構文のいずれかで指定されます。

[ ( x1 , y1 ) , ( x2 , y2 ) ]
( ( x1 , y1 ) , ( x2 , y2 ) )
  ( x1 , y1 ) , ( x2 , y2 )
    x1 , y1   ,   x2 , y2

where <literal>(<replaceable>x1</replaceable>,<replaceable>y1</replaceable>)</literal> and <literal>(<replaceable>x2</replaceable>,<replaceable>y2</replaceable>)</literal> are the end points of the line segment. ここで、(x1,y1)(x2,y2)は線分の終端点です。

Line segments are output using the first syntax. 線分は1番目の構文で出力されます。

8.8.4. 矩形 #

<title>Boxes</title>

Boxes are represented by pairs of points that are opposite corners of the box. Values of type <type>box</type> are specified using any of the following syntaxes: 矩形は、矩形の対角線の両端の座標点の組み合わせで表されます。 box型の値は以下の構文のいずれかで指定されます。

( ( x1 , y1 ) , ( x2 , y2 ) )
  ( x1 , y1 ) , ( x2 , y2 )
    x1 , y1   ,   x2 , y2

where <literal>(<replaceable>x1</replaceable>,<replaceable>y1</replaceable>)</literal> and <literal>(<replaceable>x2</replaceable>,<replaceable>y2</replaceable>)</literal> are any two opposite corners of the box. ここで(x1,y1)(x2,y2)は矩形の対角線の両端です。

Boxes are output using the second syntax. 矩形は2番目の構文で出力されます。

Any two opposite corners can be supplied on input, but the values will be reordered as needed to store the upper right and lower left corners, in that order. 任意の対角頂点を入力として指定することができます。 しかし頂点は右上の頂点を最初に、左下の頂点をその後に格納するよう必要に応じて並べ替えられます。

8.8.5. 経路 #

<title>Paths</title>

Paths are represented by lists of connected points. Paths can be <firstterm>open</firstterm>, where the first and last points in the list are considered not connected, or <firstterm>closed</firstterm>, where the first and last points are considered connected. 経路は接続している座標点のリストで表現されます。 経路は最初の座標点と最後の座標点が接続されていないとみなされる開いている状態か、最初の座標点と最後の座標点が接続されているとみなされる閉じた状態かのいずれかです。

Values of type <type>path</type> are specified using any of the following syntaxes: path型の値は次の構文のいずれかで指定されます。

[ ( x1 , y1 ) , ... , ( xn , yn ) ]
( ( x1 , y1 ) , ... , ( xn , yn ) )
  ( x1 , y1 ) , ... , ( xn , yn )
  ( x1 , y1   , ... ,   xn , yn )
    x1 , y1   , ... ,   xn , yn

where the points are the end points of the line segments comprising the path. Square brackets (<literal>[]</literal>) indicate an open path, while parentheses (<literal>()</literal>) indicate a closed path. When the outermost parentheses are omitted, as in the third through fifth syntaxes, a closed path is assumed. ここで、各座標点は、経路を構成する線分の終端点です。 大括弧([])は開経路を、括弧(())は閉経路を示します。 3番目から4番目の構文のようにもっとも外側の括弧が省略された場合、閉経路と仮定されます。

Paths are output using the first or second syntax, as appropriate. 経路は最初または2番目の適切な構文で出力されます。

8.8.6. 多角形(ポリゴン) #

<title>Polygons</title>

Polygons are represented by lists of points (the vertexes of the polygon). Polygons are very similar to closed paths; the essential difference is that a polygon is considered to include the area within it, while a path is not. 多角形は座標点(多角形の頂点)のリストで表現されます。 多角形は閉経路ととても良く似ています。多角形は領域をその内側に含むと考えますが、閉経路ではそのように考えない点が本質的な違いです。

Values of type <type>polygon</type> are specified using any of the following syntaxes: polygon型の値は次の構文のいずれかで指定されます。

( ( x1 , y1 ) , ... , ( xn , yn ) )
  ( x1 , y1 ) , ... , ( xn , yn )
  ( x1 , y1   , ... ,   xn , yn )
    x1 , y1   , ... ,   xn , yn

where the points are the end points of the line segments comprising the boundary of the polygon. 各座標点は多角形の境界を構成する線分の終端点です。

Polygons are output using the first syntax. 多角形は最初の構文で出力されます。

8.8.7. 円 #

<title>Circles</title>

Circles are represented by a center point and radius. Values of type <type>circle</type> are specified using any of the following syntaxes: 円は中心座標点と半径で表現されます。 circle型の値は次の構文のいずれかで指定されます。

< ( x , y ) , r >
( ( x , y ) , r )
  ( x , y ) , r
    x , y   , r

where <literal>(<replaceable>x</replaceable>,<replaceable>y</replaceable>)</literal> is the center point and <replaceable>r</replaceable> is the radius of the circle. ここで(x,y)は円の中心点、rは円の半径です。

Circles are output using the first syntax. 円は最初の構文で出力されます。