codejunkie
codejunkie

Reputation: 968

Error while inserting values into a MySQL multipolygon data type field

My understanding of the multipolygon field is - a field that can hold information about multiple polygons in a single cell.

My table structure is -

CREATE TABLE `test_table` (
  `key` int(11) NOT NULL AUTO_INCREMENT,
  `selected_polygon` multipolygon DEFAULT NULL,
  PRIMARY KEY (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

I am trying to insert the following data into a multipolygon field -

SET @g ='MULTIPOLYGON(((45.55215127678357 -122.65701296506451, 
45.52329405876074 -122.63572695432232, 
45.52473727138698 -122.56156923947856, 
45.54397656857749- 122.56088259397076, 
45.559363267325914 -122.60345461545514, 
45.56224780438123 -122.65220644650982, 
45.55215127678357 -122.65701296506451)))';

INSERT INTO test_table(selected_polygon) VALUES (GeomFromText(@g));

I get the following the error every time I tried to execute the above statement -

Error Code: 3037. Invalid GIS data provided to function st_geometryfromtext.

Upvotes: 4

Views: 2703

Answers (1)

e4c5
e4c5

Reputation: 53774

When you look at your data, there is a subtle error that's hard to spot.

SET @g ='MULTIPOLYGON(((45.55215127678357 -122.65701296506451, 
45.52329405876074 -122.63572695432232, 
45.52473727138698 -122.56156923947856, 
45.54397656857749  -122.56088259397076,  
45.559363267325914 -122.60345461545514, /* this line had - in wrong place */
45.56224780438123 -122.65220644650982, 
45.55215127678357 -122.65701296506451)))';

Please use the above.

Upvotes: 3

Related Questions