[postgis-users] ST_Intersects ST_GeomFromGeoJSON syntax

Joseph Spenner joseph85750 at yahoo.com
Wed Jan 7 08:30:09 PST 2015


More info.  Here are my 2 select statements.This one works:
$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromText('POLYGON(($textPoly, $closingLon $closingLat))', 4269), geom)=TRUE");


However, below is my new one, which I can't get to work:
$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_AsText(ST_GeomFromGeoJSON('$jsonPoly')), geom)=TRUE");


When I run with my new select statement, I get errors:
-----
DBD::Pg::st execute failed: ERROR:  function st_intersects(text, geometry) is not unique
LINE 1: ...ertseverity,ST_Asgeojson( geom ) from polys where ST_Interse...
                                                             ^
HINT:  Could not choose a best candidate function. You might need to add explicit type casts. at ./alertPoly2.cgi line 103.
DBD::Pg::st execute failed: ERROR:  function st_intersects(text, geometry) is not unique
LINE 1: ...ertseverity,ST_Asgeojson( geom ) from polys where ST_Interse...
                                                             ^
HINT:  Could not choose a best candidate function. You might need to add explicit type casts. at ./alertPoly2.cgi line 103.
------
Any help would be great.
Thanks!



      From: Hugues François <hugues.francois at irstea.fr>
 To: Joseph Spenner <joseph85750 at yahoo.com>; PostGIS Users Discussion <postgis-users at lists.osgeo.org> 
 Sent: Wednesday, January 7, 2015 1:17 AM
 Subject: Re: [postgis-users] ST_Intersects ST_GeomFromGeoJSON syntax
   
Hello,

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.

HTH

Hugues.


-------- Message d'origine--------
De: postgis-users-bounces at lists.osgeo.org de la part de Joseph Spenner
Date: mar. 06/01/2015 20:31
À: PostGIS Users Discussion
Objet : [postgis-users] ST_Intersects ST_GeomFromGeoJSON syntax
 
Hello,I currently have a select which works correctly:
$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromText('POLYGON(($textPoly, $closingLon $closingLat))', 4269), geom)=TRUE");


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:
$sth = $dbh->prepare("select ST_Asgeojson( geom ) from polys where ST_Intersects(ST_GeomFromGeoJSON('POLYGON(($jsonPolys))', 4269), geom)=TRUE");

 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.
Any ideas?
Thanks!
Regards,Joseph Spenner


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150107/f7cfca23/attachment.html>


More information about the postgis-users mailing list