[postgis-users] MULTIPOINT geometry variable
Markus Schaber
schabi at logix-tt.com
Mon Feb 19 00:42:45 PST 2007
Hi, Rodrigo,
"Rodrigo Martín LÓPEZ GREGORIO" <rodrigomlg at yahoo.com.ar> wrote:
> But if mymultipoint variable has not points yet, this doesnt work so I must
> check in every assignment if mymultipoint variable is null or empty or
> something like that.
Yes, but you can use an SQL-Level CASE expression to simplify that:
mymultipoint:=CASE WHEN mymultipoint IS NULL THEN newpoint ELSE
GeomUnion(newpoint, mymultipoint) END;
Or even shorter, using COALESCE:
mymultipoint:=COALESCE(GeomUnion(newpoint, mymultipoint), newpoint);
or:
mymultipoint:=GeomUnion(newpoint, COALESCE(mymultipoint, newpoint));
> However I think that there may be a much simple way to do that.
In case you find one, please tell me.
> I think that must be something like
> addpoint(mymultipoint,newpoint).
But for your solution, you also need some notion of an "empty
multipoint" to start with, so that won't change your problem.
> Another solution could be initialize mymultipoint variable in some way that
> not implies adding a point.
Initially, I thougt you could initialize your multipoint variable with
an empty geometry collection, but it seems that geomunion does not
support geometry collections as input argument, which is braindead
IMHO, and I think patches fixing that will be accepted.
Regards,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org
More information about the postgis-users
mailing list