0

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,'))');
donalg d
  • 194
  • 4
  • 11
  • If you specify what you are trying to accomplish, you may get an answer. This is too vague at the moment. – Yuval F Jun 18 '09 at 08:52

2 Answers2

0

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

john misoskian
  • 574
  • 1
  • 12
  • 32
0

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.

unmounted
  • 33,530
  • 16
  • 61
  • 61