[postgis-devel] dump(geometry)

strk at refractions.net strk at refractions.net
Fri Jan 7 08:19:12 PST 2005


I've tested the code on all supported PGSQL versions.
It works from 73 to 80.

During the process I did more cleanups and tests,
making all *_garray() functions work from 72 to 80
and doing some more cleanups.  Among them, joinsel
function for geometry && geometry will only *really*
do something for 80 (previous PG versions didn't have
custom statistics).

I think RC1 gets closer.

--strk;

On Fri, Jan 07, 2005 at 01:50:21AM +0100, strk at refractions.net wrote:
> I've been researching and implementing a geometry dumper
> capable of removing the dead-end constraint on GEOMETRYCOLLECTION.
> 
> It is a set-returning function (SRF) returning each of the
> input geometry components togheter with it's internal "path".
> 
> The returned row is of the custom geometry_dump type:
> 
> CREATE TYPE geometry_dump AS (path integer[], geom geometry);
> 
> I've made it work on 'single' geometry types as well, using
> an empty 'path' for them.
> 
> The path expresses the component position inside it's original
> structure, to allow further analisys using SQL.
> 
> Single geometries are returned with an empty array as path, so
> you can use a single select to completely explode a relation
> containing mixed geometry types.
> 
> I'm not sure about the use of arrays, but I think returning
> a SETOF 'geometry_dump' instead of a SETOF 'geometry' gives
> more power to the users.
> 
> Also, this is only tested against postgresql 8.0.0.
> Tests on previous postgresql versions are *very* welcome.
> 
> The (alpha) code is in lwgeom_dump.c.
> The file also contains SQL enabler code to be manually added
> to lwpostgis.sql.in.
> 
> Carl: happy hacking ;)
> 
> 
> Example run:
> 
> strk=# select id,astext(geom) from test1 where id = 277;
>  id  |                                                                                                                                                               astext                                                                                                                                                     
> -----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  277 | GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(0 -3,1 10),POINT(2 2),GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(0 -3,1 10),POINT(2 2)),GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(0 -3,1 10),POINT(2 2),GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(0 -3,1 10),POINT(2 2))),LINESTRING(0 0,2 2,10 10,10 50))
> (1 row)
> 
> 
> strk=# select id,astext(geom(dump(geom))),path(dump(geom)) from test1
> strk-# where id = 277;
>  id  |             astext              |  path
> -----+---------------------------------+---------
>  277 | LINESTRING(0 0,1 1)             | {1}
>  277 | LINESTRING(0 -3,1 10)           | {2}
>  277 | POINT(2 2)                      | {3}
>  277 | LINESTRING(0 0,1 1)             | {4,1}
>  277 | LINESTRING(0 -3,1 10)           | {4,2}
>  277 | POINT(2 2)                      | {4,3}
>  277 | LINESTRING(0 0,1 1)             | {5,1}
>  277 | LINESTRING(0 -3,1 10)           | {5,2}
>  277 | POINT(2 2)                      | {5,3}
>  277 | LINESTRING(0 0,1 1)             | {5,4,1}
>  277 | LINESTRING(0 -3,1 10)           | {5,4,2}
>  277 | POINT(2 2)                      | {5,4,3}
>  277 | LINESTRING(0 0,2 2,10 10,10 50) | {6}
> (13 rows)
> 
> Comment welcome.
> 
> --strk;
> 
> For standing up against patentability of software,
> 
>   Thank You, Poland!
> 
> Read the intervention:    http://kwiki.ffii.org/ConsPolon041221En
> Send your thanks:         thankyoupoland.info
> Read/do more:		  http://www.noepatents.org/
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel

-- 

For standing up against patentability of software,

  Thank You, Poland!

Read the intervention:    http://kwiki.ffii.org/ConsPolon041221En
Send your thanks:         thankyoupoland.info
Read/do more:		  http://www.noepatents.org/



More information about the postgis-devel mailing list