mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 17:12:35 +00:00
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:
parent
ad3ed6739a
commit
a56cbf8a70
59
topology/sql/topoelement/topoelement_agg.sql
Normal file
59
topology/sql/topoelement/topoelement_agg.sql
Normal 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
|
|
@ -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
|
||||
|
|
8
topology/test/regress/topoelementarray_agg.sql
Normal file
8
topology/test/regress/topoelementarray_agg.sql
Normal 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;
|
2
topology/test/regress/topoelementarray_agg_expected
Normal file
2
topology/test/regress/topoelementarray_agg_expected
Normal file
|
@ -0,0 +1,2 @@
|
|||
1|{{1,3}}
|
||||
2|{{2,4},{2,5}}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue