[Libpqxx-general] Polygon data type in postgres

Mark Gabriel Paylaga mpaylaga at gmail.com
Tue Jul 7 02:12:15 UTC 2009


Hello Scott,

Thanks for the suggestion. Unfortunately the number of sides of
the polygon varies so we can't hardcode it like that when doing the
select...
If anyone has experience with the postgres polygons using libpqxx, you may
want
to share how you retrieved the points?

Thanks and best regards,
mark

On Mon, Jul 6, 2009 at 11:22 PM, Scott Gifford <sgifford at suspectclass.com>wrote:

> Mark Gabriel Paylaga <mpaylaga at gmail.com> writes:
>
> > I'm trying to retrieve the points of a polygon that are stored in the
> postgres
> > db.
> > The contents of the db are:
> >  polygonid |
> > vertices
> >
> -----------+---------------------------------------------------------------------
> >          2 | ((1,0),(1.5,-1),(2,-1),(2,1),(1,1),(0,0),(0,2),(3,2),(3,-2),
> > (1,-2))
> >          4 | ((3,3),(4,4),(5,5))
>
> >
> > The vertices column is of type Polygon.
>
> Mark,
>
> I had a similar problem with accessing geo-spatial fields, and I
> solved it by selecting the individual parts of the fields.  For
> example, we were storing some line segments and also a time range as a
> segment type, and I used SQL like this:
>
>    SELECT objid, (time[0])[0] AS etime, (time[1])[0] AS stime,
>           (seg[0])[0] AS segupper_x, (seg[0])[1] AS segupper_y,
>           (seg[1])[0] AS seglower_x, (seg[1])[1] AS seglower_y
>
> Then we could access the fields using their assigne names with normal
> libpqxx syntax.
>
> Not sure if that will work for polygon or not; probably it will depend
> on whether you know how many sides there are.
>
> It would definitely be nice if libpqxx offered better support for this
> (maybe it does and I just couldn't figure it out).
>
> ----Scott.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pgfoundry.org/pipermail/libpqxx-general/attachments/20090707/12d07d32/attachment.html>


More information about the Libpqxx-general mailing list