[postgis-users] GeomUnion() as aggregate

Michael Fecht michael.fecht at uibk.ac.at
Mon Apr 11 03:15:49 PDT 2005


GeomUnion() as aggregate to union linestrings returns  a multilinestring 
with lineparts in the reverse order than the original linestrings.

Original:
  SRID=-1;LINESTRING(1 1,2.5 1.5,2.5 3)
  SRID=-1;LINESTRING(2.5 3,3 3.5,4.5 3.5)
  SRID=-1;LINESTRING(4.5 3.5,5 4.5,7 4.5)
  SRID=-1;LINESTRING(7 4.5,7.5 4,7 3.5,6.5 3,7 2.5)

process GeomUnion with :
                    
                         select geomunion(geo) from lines;

returns
SRID=-1;MULTILINESTRING((7 4.5,7.5 4,7 3.5,6.5 3,7 2.5),(4.5 3.5,5 4.5,7 
4.5),(2.5 3,3 3.5,4.5 3.5),(1 1,2.5 1.5,2.5 3))
   starting with the last linestring of table "lines".

using :
                      select geomunion(geo) from (select * from lines 
order by id desc) as view;

returns the multilinestring with lineparts ordered like in the original 
dataset:
 SRID=-1;MULTILINESTRING((1 1,2.5 1.5,2.5 3),(2.5 3,3 3.5,4.5 3.5),(4.5 
3.5,5 4.5,7 4.5),(7 4.5,7.5 4,7 3.5,6.5 3,7 2.5))

This behaviour of the GeomUnion() Funktion is not intuitive. Maybe the 
processing order should be adapted.

Michael



-- 
---------------------
Michael Fecht
GRID-IT GmbH
Technikerstraße 21a
A6020 Innsbruck
fon +43 (0) 512 507 4862
e-mail fecht(at)grid-it.at
---------------------




More information about the postgis-users mailing list