[postgis-users] PHP & PostGIS.

Sandro Santilli strk at keybit.net
Mon Jun 27 06:51:17 PDT 2011


On Sun, Jun 26, 2011 at 09:28:52PM -0700, Eric Sepich wrote:
> <?php
> $dbconn = pg_connect("host=localhost port=5432 dbname=postgismethane
> user=root password=excedrin413");
> 
> $query = "SELECT * FROM polygons WHERE gid = 1";
> $result = pg_exec($dbconn, $query);
> if (!$result) {printf ("ERROR"); exit;}
> $numrows = pg_numrows($result);
> ?>
> 
> I get one row returned but I just don't seem to have any kind of
> documentation on what to do with it. I want to list the coordinates of the
> polygon returned by my query. Does anyone know how to do that?

I suggest you look at GEOS-3.3.0, which contains a PHP binding.
You'd then select ST_AsText (WKT) or ST_AsBinary (WKB) and feed
that to GEOS for reading, and finally use GEOS to inspect and
further analyze.

Mind you: it'll be an adventure!
Most people just ask the database about all they need, in your case
SELECT ST_DumpPoints to get the list of coordinates of your polygon,
for example...

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-users mailing list