From cd3b4730bb06ebd1e1f4e32043d143a637e3754c Mon Sep 17 00:00:00 2001 From: Patrick Hayes Date: Thu, 5 Apr 2012 02:47:12 -0700 Subject: [PATCH] Updating readme to use ewkb for postgis example --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd788f2f..092a47a6 100644 --- a/README.md +++ b/README.md @@ -106,17 +106,17 @@ $pass = 'supersecret'; $connection = pg_connect("host=$host dbname=$database user=$user password=$pass"); -// Working with PostGIS and WKB +// Working with PostGIS and Extended-WKB // ---------------------------- // Using asBinary and GeomFromWKB in PostGIS $result = pg_fetch_all(pg_query($connection, "SELECT asBinary($column) as geom FROM $table")); foreach ($result as $item) { $wkb = pg_unescape_bytea($item['geom']); // Make sure to unescape the hex blob - $geom = geoPHP::load($wkb, 'wkb'); // We now a full geoPHP Geometry object + $geom = geoPHP::load($wkb, 'ewkb'); // We now a full geoPHP Geometry object // Let's insert it back into the database - $insert_string = pg_escape_bytea($geom->out('wkb')); + $insert_string = pg_escape_bytea($geom->out('ewkb')); pg_query($connection, "INSERT INTO $table ($column) values (GeomFromWKB('$insert_string'))"); } @@ -124,10 +124,10 @@ foreach ($result as $item) { $result = pg_fetch_all(pg_query($connection, "SELECT $column as geom FROM $table")); foreach ($result as $item) { $wkb = pack('H*',$item['geom']); // Unpacking the hex blob - $geom = geoPHP::load($wkb, 'wkb'); // We now have a geoPHP Geometry + $geom = geoPHP::load($wkb, 'ewkb'); // We now have a geoPHP Geometry // To insert directly into postGIS we need to unpack the WKB - $unpacked = unpack('H*', $geom->out('wkb')); + $unpacked = unpack('H*', $geom->out('ewkb')); $insert_string = $unpacked[1]; pg_query($connection, "INSERT INTO $table ($column) values ('$insert_string')"); }