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

strk at refractions.net strk at refractions.net
Tue Jul 25 13:19:31 PDT 2006


I've fixed this in CVS. Thank for pointing out.

Mike: it is intentional to drop SRID from input geoms, as 
we don't really want to be redundant about it (ie: only outer
geom would have a SRID attached).

BTW, I've added a new test unit [ ctor.{sql,_expected} ]
If anyone wants to help adding regression tests there for 
constructors (makePoint, makeLine, etc.) would greatly help.

--strk;

On Mon, Jul 24, 2006 at 07:43:50PM -0600, Michael Fuhr wrote:
> 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