Thank you Paul and John for your ideas. :)

Actually what I'm trying to do is to decode simple POINT geoms...

This is what I've done in PHP (using the astext() approach)

      // extract the geometry
      $geometry = str_replace("POINT(","", $loc);
      $geometry = str_replace(")","",$geometry);
      $coordinate = explode(" ",$geometry);
      $lon=$coordinate[0];
      $lat=$coordinate[1];

Now this was for the web interface... ( the user can wait another 100ms or so ... :] ) As far as a server solution is concerned this *is* a time-consuming procedure... especially so when you've got *thousands* of connections per minute...

Furthermore, I'm developing the "beast" in Qt4 and - *ahem* - had never needed to use libpq so I'm a bit lost here... :)

Could someone be so kind as to point to a code example (outside using astext() method) ? :]

P.S. @John - found this to be interesting as I could store it in QByteArray and go from there... ;) -- the real question here is: how to interpret the byte array?

BR,
Pedro.


On 11/23/2009 09:50 PM, Paul Ramsey wrote:
That depends entirely on what you're planning to do with them once you
get them. You'll probably want to serialize them into a known form so
you can use them on the client side. ST_AsText() is one, very heavy,
option. Mapserver, to take an example, uses
encode(ST_AsBinary(ST_Force2D(geom)), 'hex'), so what goes over the
wire is hex strings, but those are easy to turn into binary arrays, in
WKB format, suitable for reading by a number of C++ libraries (like
OGR or GEOG or etc).

Best,

P.

On Mon, Nov 23, 2009 at 1:19 PM, Pedro Doria Meunier
<[email protected]>  wrote:
Hi All,

First off sorry for cross-posting. I'm hoping for a bigger audience... :]

As for my question:

How does one deal with Postgis geom fields in C++ ?
Google hasn't offered much help so far.

I know I can make a "SELECT astext(my_geom) FROM my_table" and after parsing
the resulting text.
This seems a bit awkward and time-consuming...

Is there a better way to deal with it?

Already thankful for any ideas,
BR,
Pedro.
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to