<html><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:14px"><div id="yui_3_16_0_1_1420642633324_35230">More info.  Here are my 2 select statements.</div><div id="yui_3_16_0_1_1420642633324_35229" dir="ltr">This one works:</div><div id="yui_3_16_0_1_1420642633324_35228" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34626" dir="ltr">$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromText('POLYGON(($textPoly, $closingLon $closingLat))', 4269), geom)=TRUE");<br style="" class=""></div><div id="yui_3_16_0_1_1420642633324_34630" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34631" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34632" dir="ltr">However, below is my new one, which I can't get to work:</div><div id="yui_3_16_0_1_1420642633324_34633" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34609"><span id="yui_3_16_0_1_1420642633324_34641">$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_AsText(ST_GeomFromGeoJSON('$jsonPoly')), geom)=TRUE");<br style="" class=""></span></div><div id="yui_3_16_0_1_1420642633324_34646"><br><span id="yui_3_16_0_1_1420642633324_34641"></span></div><div id="yui_3_16_0_1_1420642633324_34724"><br><span id="yui_3_16_0_1_1420642633324_34641"></span></div><div id="yui_3_16_0_1_1420642633324_34725" dir="ltr"><span id="yui_3_16_0_1_1420642633324_34641">When I run with my new select statement, I get errors:</span></div><div id="yui_3_16_0_1_1420642633324_34726" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34957" dir="ltr">-----<br><span id="yui_3_16_0_1_1420642633324_34641"></span></div><div id="yui_3_16_0_1_1420642633324_34727" dir="ltr"><span id="yui_3_16_0_1_1420642633324_34641">DBD::Pg::st execute failed: ERROR:  function st_intersects(text, geometry) is not unique<br style="" class="">LINE 1: ...ertseverity,ST_Asgeojson( geom ) from polys where ST_Interse...<br style="" class="">                                                             ^<br style="" class="">HINT:  Could not choose a best candidate function. You might need to add explicit type casts. at ./alertPoly2.cgi line 103.<br style="" class="">DBD::Pg::st execute failed: ERROR:  function st_intersects(text, geometry) is not unique<br style="" class="">LINE 1: ...ertseverity,ST_Asgeojson( geom ) from polys where ST_Interse...<br style="" class="">                                                             ^<br style="" class="">HINT:  Could not choose a best candidate function. You might need to add explicit type casts. at ./alertPoly2.cgi line 103.<br style="" class="">------</span></div><div id="yui_3_16_0_1_1420642633324_34959" dir="ltr"><br><span id="yui_3_16_0_1_1420642633324_34641"></span></div><div id="yui_3_16_0_1_1420642633324_34961">Any help would be great.</div><div id="yui_3_16_0_1_1420642633324_35094"><br></div><div id="yui_3_16_0_1_1420642633324_35095" dir="ltr">Thanks!</div><div id="yui_3_16_0_1_1420642633324_35321" dir="ltr"><br></div><div id="yui_3_16_0_1_1420642633324_34612"><br><div id="yui_3_16_0_1_1420642633324_34625">
<br></div></div><br>  <div id="yui_3_16_0_1_1420642633324_34619" style="font-family: garamond, new york, times, serif; font-size: 14px;"> <div id="yui_3_16_0_1_1420642633324_34618" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_1_1420642633324_34622" dir="ltr"> <hr id="yui_3_16_0_1_1420642633324_34624" size="1">  <font id="yui_3_16_0_1_1420642633324_34623" size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Hugues François <hugues.francois@irstea.fr><br> <b><span style="font-weight: bold;">To:</span></b> Joseph Spenner <joseph85750@yahoo.com>; PostGIS Users Discussion <postgis-users@lists.osgeo.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, January 7, 2015 1:17 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [postgis-users] ST_Intersects ST_GeomFromGeoJSON syntax<br> </font> </div> <div id="yui_3_16_0_1_1420642633324_34617" class="y_msg_container"><br>Hello,<br><br>I'm not very familiar with the use of ST_GeomFromGeoJSON() but looking at the doc, it only accepts a single json string so you'd better remove all the ST_GeomFromText stuff: ST_GeomFromGeoJSON($jsonPolys). There are some examples at the bottom of the page http://www.postgis.org/docs/ST_GeomFromGeoJSON.html.<br><br>HTH<br><br>Hugues.<br><br><br>-------- Message d'origine--------<br>De: <a ymailto="mailto:postgis-users-bounces@lists.osgeo.org" href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a> de la part de Joseph Spenner<br>Date: mar. 06/01/2015 20:31<br>À: PostGIS Users Discussion<br>Objet : [postgis-users] ST_Intersects ST_GeomFromGeoJSON syntax<br> <br>Hello,I currently have a select which works correctly:<br>$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromText('POLYGON(($textPoly, $closingLon $closingLat))', 4269), geom)=TRUE");<br><br><br>I'm trying to do the same thing, using FromGeoJSON instead of Text.  Below is my attempt, but it's not working.  This is my statement, where $jsonPolys contains the JSON:<br>$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromGeoJSON('POLYGON(($jsonPolys))', 4269), geom)=TRUE");<br><br> I think the problem has something to do with the POLYGON text, since it may not be necessary.  But I can't get the syntax right.<br>Any ideas?<br>Thanks!<br>Regards,Joseph Spenner<br><br><br></div> </div> </div>  </div></body></html>