ST_Accum — Constructs an array of geometries from a set of geometries.
PostgreSQL
geometry[] ST_Accum(
bytea
Geometry_Aggregate)
;
H2
geometry[] ST_AccumAgg(
bytea
Geometry_Aggregate)
;
Constructs an array of geometries from a set of geometries.
ST_Accum is an aggregate function that return a single value, calculated from a set of values (a column or a subset of column values).
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
--Creates an example table, and populates data there create table "lines"(id serial PRIMARY KEY); SELECT AddGeometryColumn ('lines','GEOM',25830,'LINESTRING',2); INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (1 1, 1 4, 1 7)')); INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (1 7, 3 7, 6 7)')); INSERT INTO "lines" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;LINESTRING (6 7, 6 3, 6 1)')); //SELECT DropGeometryTable ('lines');
--Return the Array of Geometries SELECT ST_Accum("lines"."GEOM") from "lines"; SELECT c FROM (SELECT ST_Accum("lines"."GEOM") as c from "lines") as foo; --Return a Subset of the Array SELECT c[1:2] FROM (SELECT ST_Accum("lines"."GEOM") as c from "lines") as foo;
--Return the Array of Geometries SELECT (c) FROM (SELECT ST_AccumAgg("lines"."GEOM") as c from "lines") as foo ; --Result (0102000020e66400000300000000 ... 0000000000000f03f0000000000001c40, 0102000020e664000003000000000 ... 000000000000018400000000000001c40, 0102000020e664000003000000000 ... 400000000000001840000000000000f03f) --Return a Subset of the Array select (c) FROM (SELECT ST_AccumAgg("lines"."GEOM") as c from "lines" where id>2) as foo ; --Result (0102000020e664000003000000000 ... 000008400000000000001840000000000000f03f) --Use the array as an argument for ST_MakeGeomColl SELECT ST_AsText(ST_MakeGeomColl(c)) FROM (SELECT ST_AccumAgg("lines"."GEOM") as c from "lines") as foo; --Result GEOMETRYCOLLECTION (LINESTRING (1 1, 1 4, 1 7), LINESTRING (1 7, 3 7, 6 7), LINESTRING (6 7, 6 3, 6 1))