ST_Collect — ジオメトリの集合からジオメトリコレクションまたはマルチ系ジオメトリを生成します。
geometry ST_Collect(geometry g1, geometry g2);
geometry ST_Collect(geometry[] g1_array);
geometry ST_Collect(geometry set g1field);
ジオメトリを集めてジオメトリコレクションにします。結果はマルチ系ジオメトリかジオメトリコレクションかのいずれかで、この差は、入力ジオメトリのタイプが同じか異なるか(均質か不均質か)で決まります。入力ジオメトリはコレクション内で変更されることはありません。
1番目の形式: 二つの入力ジオメトリを受け付ける。
2番目の形式: ジオメトリの配列を受け付ける。
3番目の形式: ジオメトリの行集合を受け付ける集約関数。
|
|
|
|
If any input geometry is a collection (Multi* or GeometryCollection), ST_Collect returns a GeometryCollection, since that is the only type which can contain nested collections. To prevent this, use ST_Dump in a subquery to expand input collections to their atomic elements (see example below).
Availability: 1.4.0 - ST_Collect(geometry)が導入されました。ST_Collectがより多くのジオメトリをより早く扱えるよう強化されました。
この関数は3次元に対応し、Z値を削除しません。
このメソッドは曲線ストリングと曲線に対応しています。
Two-input variant.
2次元ポイントを収集します。
SELECT ST_Collect(
'POINT(1 2)',
'POINT(-2 3)' );
MULTIPOINT((1 2),(-2 3))
2次元ポイントの収集
SELECT ST_Collect(
'POINT(1 2 3)',
'POINT(1 2 4)' );
MULTIPOINT(1 2 3,1 2 4)
曲線を収集します。
SELECT ST_Collect(
'CIRCULARSTRING(220268 150415,220227 150505,220227 150406)',
'CIRCULARSTRING(220227 150406,2220227 150407,220227 150406)');
MULTICURVE(CIRCULARSTRING(220268 150415,220227 150505,220227 150406), CIRCULARSTRING(220227 150406,2220227 150407,220227 150406))
Array variant.
サブクエリから配列を生成するコンストラクタの使用。
SELECT ST_Collect(ARRAY(SELECT geom FROM sometable));
値から配列を生成するコンストラクタの使用。
SELECT ST_Collect(
ARRAY[ 'LINESTRING(1 2,3 4)'::geometry,
'LINESTRING(3 4,4 5)'::geometry ] ) As wktcollect;
MULTILINESTRING((1 2,3 4),(3 4,4 5))
Aggregate variant.
テーブル内のジオメトリのグループ化による複数コレクションを生成します。
SELECT stusps, ST_Collect(geom) AS geom FROM ( SELECT stusps, (ST_Dump(geom)).geom AS geom FROM somestatetable ) AS f GROUP BY stusps;