[Libpqxx-general] Polygon data type in postgres
Scott Gifford
sgifford at suspectclass.com
Mon Jul 6 15:22:18 UTC 2009
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))
> 3 | ((3,3),(4,4))
> 4 | ((3,3),(4,4),(5,5))
> 5 | ((0,1))
>
> 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.
More information about the Libpqxx-general
mailing list