<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.30.3">
</HEAD>
<BODY>
Hallo<BR>
<BR>
What is the error message that you got?<BR>
<BR>
I don't think this is a PostGIS issue but an issue when building the string.<BR>
<BR>
If I don't misunderstand this, what you are sending to the database is:<BR>
<BR>
select attribute1, the_geom from table1 where st_contains(st_geomfromtext('POLYGON($stringPolygonCoordinate)'), table1.the_geom);<BR>
<BR>
instead of:<BR>
<BR>
select attribute1, the_geom from table1 where st_contains(st_geomfromtext('POLYGON((35.1343 24.15454, 35.2454 24.2565,35.35675 24.3565,35.1343 24.15454))'), table1.the_geom);<BR>
<BR>
What you should do is something like:<BR>
select attribute1, the_geom from table1 where st_contains(st_geomfromtext('POLYGON(". $stringPolygonCoordinate.")'), table1.the_geom);<BR>
<BR>
<BR>
/Nicklas<BR>
<BR>
<BR>
<BR>
On Fri, 2011-03-11 at 09:55 +0000, zhang zhe wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    Hello,<BR>
     <BR>
    I am programming php application with postgres. I need to select the points which locate inside the polygon. Here is my code<BR>
    <?php<BR>
    $stringPolygonCoordinate="(35.1343 24.15454, 35.2454 24.2565,35.35675 24.3565,35.1343 24.15454)";<BR>
    $query1 = "select attribute1, the_geom from table1 where st_contains(st_geomfromtext('POLYGON($stringPolygonCoordinate)'), table1.the_geom);<BR>
    $result1= pg_query($query1) or die('Query failed: ' . pg_last_error());<BR>
    pg_query("select sum(attribute2) from table2 where st_contains(st_geomfromtext('POLYGON($stringPolygonCoordinate)'), table2.the_geom) group by attribute3;") or die('Query failed: ' . pg_last_error());<BR>
     <BR>
    ?><BR>
    But it doesn´t work. I wonder, does the polygon()function only take integer/float as input? Sinct $stringPolygonCoordinate variable is string? I also tried to modify the code like this<BR>
    $query1 = "select attribute1, the_geom from table1 where st_contains(st_geomfromtext('POLYGON(to_number($stringPolygonCoordinate))'), table1.the_geom);<BR>
    It also doesn´t work. If Polygon() doesnot accept string as input, how can I convert the string to Integer without using complicated for loop? Is there ready function in postgres? <BR>
     <BR>
    Can anyone help me?<BR>
    Thanks<BR>
     
<PRE>
_______________________________________________
postgis-users mailing list
<A HREF="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A>
<A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>