[postgis-users] Postgis functions returning hidden weird characters! (?)
Vyron Antoniou
v.antoniou at ucl.ac.uk
Sat Mar 6 13:37:42 PST 2010
Hi Paul,
Thanks for the response.
Well, this one:
select ST_AsSVG('GEOMETRYCOLLECTION EMPTY'::geometry,0,5);
returns a clean result, no weird characters.
Here is my test PHP code (just to save some typing):
<?php
// put your stuff here:
$con0 = "dbname=$dbname user=$user host=$host password=$password";
$db0 = pg_connect($con0);
if ($db0) {} else {echo "no connection has been established<br>";}
/////////////////////////////////////////////////////////////////////
$sql0 = "select ST_AsSVG('GEOMETRYCOLLECTION EMPTY'::geometry,0,5);";
$stat0 = pg_exec($db0,$sql0);
$rows0 = pg_numrows($stat0);
$data0 = pg_fetch_array($stat0, 0);
$handle0 = fopen("result_0.txt", "a+");
$text0 = "|".$data0 [0]."|\n";
fwrite($handle0, $text0);
fclose($handle0);
////////////////////////////////////////////////////////////////////////
$sql1 = "select ST_AsSVG(ST_Difference(
ST_LineFromText('LINESTRING(528085.304556059
182402.75252444,528057.189235888 182383.627714979,528078.925527415
182348.523254458,528110.016845328 182367.72322892,528119.206862483
182351.764509452,528065.429111811 182316.692226383,528019.682277422
182382.682354742,528076.562322635 182418.577931056,528085.304556059
182402.75252444)'),
ST_Difference(ST_LineFromText('LINESTRING(528085.304556059
182402.75252444,528057.189235888 182383.627714979,528078.925527415
182348.523254458,528110.016845328 182367.72322892,528119.206862483
182351.764509452,528065.429111811 182316.692226383,528019.682277422
182382.682354742,528076.562322635 182418.577931056,528085.304556059
182402.75252444)'), ST_LineFromText('LINESTRING(528609 182468,528009
182468)'))
),0,5)";
$stat1 = pg_exec($db0,$sql1);
$rows1 = pg_numrows($stat1);
$data1 = pg_fetch_array($stat1, 0);
$handle1 = fopen("result_1.txt", "a+");
$text1 = "|".$data1 [0]."|\n";
fwrite($handle1, $text1);
fclose($handle1);
?>
The first one writes || while the second one writes unrecognizable
characters (probably something binary?)
Byron
More information about the postgis-users
mailing list