How can i insert a geo co-ordinates data inside a polygon field in mysql , Here is a sample query am using for test
INSERT INTO `zones` (`polygon`) VALUES
('POLYGON(34.44 33.56,32.22 31.34,30.23 26.33,34.44 33.56)')
I keep getting this error when i try to submit the query #1416 - Cannot get geometry object from data you send to the GEOMETRY field
CodePudding user response:
You need to convert the string to proper statial typ in your case ST_GeomFromText
CREATE TABLE zones (`polygon` GEOMETRY);
INSERT INTO `zones` (`polygon`) VALUES
(ST_GeomFromText('POLYGON((34.44 33.56,32.22 31.34,30.23 26.33,34.44 33.56))'))
SELECT * FROM zones
polygon |
---|
0000000001030000000100000004000000b81e85eb5138414048e17a14aec740405c8fc2f5281c4040d7a3703d0a573f407b14ae47e13a3e4014ae47e17a543a40b81e85eb5138414048e17a14aec74040 |