Re: Creating a polygon from existing decimal data
After some more digging I came up with:
UPDATE `grid` SET poly = PolygonFromText(CONCAT('POLYGON(',n,' ',e,', ',s,'
',e,', ',s,' ',w,', ',n,' ',w,', ',n,' ',e,')'));
I had my delimiters mixed up and I know my CONCAT worked:
mysql> select CONCAT('POLYGON(',n,' ',e,', ',s,' ',e,', ',s,' ',w,', ',n,'
',w,', ',n,' ',e,')') from grid limit 3;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| CONCAT('POLYGON(',n,' ',e,', ',s,' ',e,', ',s,' ',w,', ',n,' ',w,', ',n,'
',e,')') |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| POLYGON(49.07756615 101.36211395, 49.07390213 101.36211395, 49.07390213
101.36764145, 49.07756615 101.36764145, 49.07756615 101.36211395) |
| POLYGON(49.08123016 101.36211395, 49.07756615 101.36211395, 49.07756615
101.36764145, 49.08123016 101.36764145, 49.08123016 101.36211395) |
| POLYGON(49.08489418 101.36211395, 49.08123016 101.36211395, 49.08123016
101.36764145, 49.08489418 101.36764145, 49.08489418 101.36211395) |
+-------------------------------------------------------------------------------------------------------------------------------------------+
But after my UPDATE my poly column is still full of NULL values.
I am sure I am missing something simple here.
Dan