MULTIPOINT geometry variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MULTIPOINT geometry variable

Rodrigo Martín LÓPEZ GREGORIO
Hi everybody.

I'm creating a postgres function and I need that it returns a multipoint geometry so then I access to the geometry returned using the geometryN(mymultipoint) function.

I create "mymultipoint" variable like:

mymultipoint geometry;

but I could not find the way to add points to that geometry, except using a linestring and using the AddPoint() function. I dont know if there is a way to add some points to a geometry and then access its using the geometryN() function, but that is what I'm looking for.

Thanks.

Rodrigo.
Reply | Threaded
Open this post in threaded view
|

Re: MULTIPOINT geometry variable

Markus Schaber
Hi, Rodrigo,

"Rodrigo Martín LÓPEZ GREGORIO" <[hidden email]> wrote:

> I'm creating a postgres function and I need that it returns a multipoint
> geometry so then I access to the geometry returned using the
> geometryN(mymultipoint) function.
>
> I create "mymultipoint" variable like:
>
> mymultipoint geometry;
>
> but I could not find the way to add points to that geometry, except using a
> linestring and using the AddPoint() function. I dont know if there is a way
> to add some points to a geometry and then access its using the geometryN()
> function, but that is what I'm looking for.

I see several options:

Use geomunion() or collect() to collect and merge your points.

Create a String representation, and use GeomFromEWKT(), GeomFromText()
or MPointFromText().



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

Reply | Threaded
Open this post in threaded view
|

Re: MULTIPOINT geometry variable

Rodrigo Martín LÓPEZ GREGORIO
Thanks for your answer.

I think that GeomUnion could work. However I have a problem. In my function I have some IF statements that adds points depending on different conditions to "mymultipoint" variable. So what I had to do to add points to mymultipoint variable was:

mymultipoint:=GeomUnion(newpoint,mymultipoint);

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. However I think that there may be a much simple way to do that. I think that must be something like addpoint(mymultipoint,newpoint).
Another solution could be initialize mymultipoint variable in some way that not implies adding a point.

I don't know if you understand what I'm trying to do... just a function that returns a MULTIPOINT variable with a undetermined number of points that depends on some conditions.

Thanks.

Rodrigo.

On 2/14/07, Markus Schaber <[hidden email]> wrote:
Hi, Rodrigo,

"Rodrigo Martín LÓPEZ GREGORIO" <[hidden email]> wrote:

> I'm creating a postgres function and I need that it returns a multipoint
> geometry so then I access to the geometry returned using the
> geometryN(mymultipoint) function.
>
> I create "mymultipoint" variable like:
>
> mymultipoint geometry;
>
> but I could not find the way to add points to that geometry, except using a
> linestring and using the AddPoint() function. I dont know if there is a way
> to add some points to a geometry and then access its using the geometryN()
> function, but that is what I'm looking for.

I see several options:

Use geomunion() or collect() to collect and merge your points.

Create a String representation, and use GeomFromEWKT(), GeomFromText()
or MPointFromText().



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
_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users