views:

227

answers:

2

I'm trying to write a query in PHP for a spatial index. But I'm having trouble writing the query for the following line of code...

SET @p = CONCAT('Polygon((',lat1,'',lon1,',',lat1,'',lon2,',',lat2,'',lon2,',',lat2,'',lon1,',',lat1,'',lon1,'))');
A: 

if you use mysql extension in php , this query returned to error. if use mysql extension , please use mysqli extension

john misoskian
A: 

The generally correct order (with a few odd exceptions) is (long lat), not (lat long). Or are you just missing a space in your concat between lat1 long1? The WKT syntax is:

GeomFromText('POLYGON(long1 lat1, long2 lat2, long3 lat3)')

Coordinates are separated by a space, points by a comma. There may even be a case sensitivity problem, though the spec is case insensitive, it is best to use ALL CAPS, and I have gotten errors that I think were related to case.

bvmou