Insert coordinates in MySQL - PolyFromText SQL syntax error / return null

I am trying to insert the geographic coordinates of a polygon into my MySQL database. I have a field named polygon of type POLYGON, and I tried to execute all these queries, but keep getting SQL syntax errors:

SET @g = 'POLYGON((-74.13591384887695 40.93750722242824,-74.13522720336914 40.929726129575016,-74.15102005004883 40.9329683629703,-74.14329528808594 40.94256444133327))';
INSERT INTO 'zones' ('polygon') VALUES (PolyFromText(@g));

INSERT INTO 'zones' ('polygon') VALUES (PolyFromText('POLYGON((-74.13591384887695 40.93750722242824,-74.13522720336914 40.929726129575016,-74.15102005004883 40.9329683629703,-74.14329528808594 40.94256444133327))'));

INSERT INTO 'zones' ('polygon') VALUES (PolyFromText('POLYGON((-74.13591384887695 40.93750722242824,-74.13522720336914 40.929726129575016,-74.15102005004883 40.9329683629703,-74.14329528808594 40.94256444133327))', 0));

The last query was generated using the phpmyadmins proprietary geospatial tools and returns the "Polygon" Column "cannot be zero. Any help is appreciated!

+5
source share
1 answer

, null, , , WKT OSGeo, , mysql , SQL Server .

.

SELECT  Dimension(GeomFromText('POLYGON((-74.13591384887695 40.93750722242824,-74.13522720336914 40.929726129575016,-74.15102005004883 40.9329683629703,-74.14329528808594 40.94256444133327,-74.13591384887695 40.93750722242824)))'));

doc mysql

http://dev.mysql.com/doc/refman/5.0/en/gis-class-polygon.html

doc sqlserver

http://msdn.microsoft.com/en-us/library/bb964739(v=sql.105).aspx

+25

All Articles