Add TopoElementArray_agg function, to help with TopoGeometry construction [RT-SIGTA]

git-svn-id: http://svn.osgeo.org/postgis/trunk@6577 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2011-01-07 09:54:49 +00:00
parent ad3ed6739a
commit a56cbf8a70
5 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,59 @@
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.refractions.net
--
-- Copyright (C) 2010 Sandro Santilli <strk@keybit.net>
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- TopoElement management functions
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- Developed by Sandro Santilli <strk@keybit.net>
-- for Faunalia (http://www.faunalia.it) with funding from
-- Regione Toscana - Sistema Informativo per la Gestione del Territorio
-- e dell' Ambiente [RT-SIGTA].
-- For the project: "Sviluppo strumenti software per il trattamento di dati
-- geografici basati su QuantumGIS e Postgis (CIG 0494241492)"
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--{
--
-- TopoElementArray TopoElementArray_append(<TopoElement>)
--
-- Append a TopoElement to a TopoElementArray
--
CREATE OR REPLACE FUNCTION topology.TopoElementArray_append(
topology.TopoElementArray, topology.TopoElement)
RETURNS topology.TopoElementArray
AS
$$
SELECT CASE
WHEN $1 IS NULL THEN
topology.TopoElementArray('{' || $2::text || '}')
ELSE
topology.TopoElementArray($1::int[][]||$2::int[])
END;
$$
LANGUAGE 'sql';
--} TopoElementArray_append
--{
--
-- TopoElementArray TopoElementArray_agg(<setof TopoElement>)
--
-- Aggregates a set of TopoElement values into a TopoElementArray
--
DROP AGGREGATE IF EXISTS topology.TopoElementArray_agg(topology.TopoElement);
CREATE AGGREGATE topology.TopoElementArray_agg(
sfunc = topology.TopoElementArray_append,
basetype = topology.TopoElement,
stype = topology.TopoElementArray
);
--} TopoElementArray_agg

View file

@ -79,7 +79,8 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \
regress/legacy_invalid.sql regress/sqlmm.sql \
regress/legacy_query.sql regress/addnode.sql \
regress/addedge.sql regress/addface.sql \
regress/st_getfacegeometry.sql
regress/st_getfacegeometry.sql \
regress/topoelementarray_agg.sql
check: topo_predicates.sql
$(MAKE) -C ../../regress postgis.sql staged-install

View file

@ -0,0 +1,8 @@
set client_min_messages to WARNING;
SELECT 1,topology.TopoElementArray_agg('{1,3}'::topology.TopoElement);
SELECT 2, topology.TopoElementArray_agg(e) from (
select '{2,4}'::topology.TopoElement as e union
select '{2,5}'
) as foo;

View file

@ -0,0 +1,2 @@
1|{{1,3}}
2|{{2,4},{2,5}}

View file

@ -2309,6 +2309,9 @@ LANGUAGE 'plpgsql' VOLATILE STRICT;
-- Editing
#include "sql/populate.sql"
-- TopoElement
#include "sql/topoelement/topoelement_agg.sql"
--=} POSTGIS-SPECIFIC block
-- SQL/MM block