1-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2--
3-- PostGIS - Spatial Types for PostgreSQL
4-- http://postgis.net
5--
6-- Copyright (C) 2010, 2011 Sandro Santilli <strk@kbt.io>
7--
8-- This is free software; you can redistribute and/or modify it under
9-- the terms of the GNU General Public Licence. See the COPYING file.
10--
11-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12--
13-- TopoElement management functions
14--
15-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16--
17-- Developed by Sandro Santilli <strk@kbt.io>
18-- for Faunalia (http://www.faunalia.it) with funding from
19-- Regione Toscana - Sistema Informativo per la Gestione del Territorio
20-- e dell' Ambiente [RT-SIGTA].
21-- For the project: "Sviluppo strumenti software per il trattamento di dati
22-- geografici basati su QuantumGIS e Postgis (CIG 0494241492)"
23--
24-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25
26--{
27--
28-- TopoElementArray TopoElementArray_append(<TopoElement>)
29--
30-- Append a TopoElement to a TopoElementArray
31--
32CREATE OR REPLACE FUNCTION topology.TopoElementArray_append(topology.TopoElementArray, topology.TopoElement)
33	RETURNS topology.TopoElementArray
34AS
35$$
36	SELECT CASE
37		WHEN $1 IS NULL THEN
38			topology.TopoElementArray('{' || $2::text || '}')
39		ELSE
40			topology.TopoElementArray($1::int[][]||$2::int[])
41		END;
42$$
43LANGUAGE 'sql' IMMUTABLE;
44--} TopoElementArray_append
45
46--{
47--
48-- TopoElementArray TopoElementArray_agg(<setof TopoElement>)
49--
50-- Aggregates a set of TopoElement values into a TopoElementArray
51--
52-- Availability: 2.0.0
53DROP AGGREGATE IF EXISTS topology.TopoElementArray_agg(topology.TopoElement);
54CREATE AGGREGATE topology.TopoElementArray_agg(
55	sfunc = topology.TopoElementArray_append,
56	basetype = topology.TopoElement,
57	stype = topology.TopoElementArray
58	);
59--} TopoElementArray_agg
60