[postgis-users] collect() and memcollect() problem: ... GEOMETRIES with different SRIDs

Michael Fuhr mike at fuhr.org
Mon Jul 24 18:43:50 PDT 2006


On Mon, Jul 24, 2006 at 07:55:45PM -0400, George Planansky wrote:
> I get memcollect() giving an error
>   ERROR:  Operation on two GEOMETRIES with different SRIDs
> although collect() works okay.

This behavior appears to be caused by the state transition function
that the memcollect aggregate uses.  That function is named collect(),
not to be confused with the aggregate collect(), which uses geom_accum()
as its state transition function.  Example:

SELECT AsEWKT(collect(NULL, 'SRID=32749;POINT(0 0)'));
        asewkt         
-----------------------
 SRID=32749;POINT(0 0)
(1 row)

SELECT AsEWKT(collect('SRID=32749;POINT(0 0)', NULL));
        asewkt         
-----------------------
 SRID=32749;POINT(0 0)
(1 row)

SELECT AsEWKT(collect('SRID=32749;POINT(0 0)', 'SRID=32749;POINT(1 1)'));
       asewkt        
---------------------
 MULTIPOINT(0 0,1 1)
(1 row)

Near the end of the LWGEOM_collect function in lwgeom_functions_basic.c
is the following code, which I'm guessing is responsible:

    /* Drop input geometries bbox and SRID */
    lwgeom_dropBBOX(lwgeoms[0]);
    lwgeom_dropSRID(lwgeoms[0]);
    lwgeom_dropBBOX(lwgeoms[1]);
    lwgeom_dropSRID(lwgeoms[1]);

    outlwg = (LWGEOM *)lwcollection_construct(
            outtype, lwgeoms[0]->SRID,
            box, 2, lwgeoms);

The comment suggests that dropping the SRID is intentional but I
wonder if it really is.

-- 
Michael Fuhr



More information about the postgis-users mailing list