= MySQL Spatial Support = ---- The official document is at: http://www.mapserver.org/input/vector/mysql.html ---- Author: [http://amountaintop.com Mike Hostetler], [http://amountaintop.com A Mountain Top, LLC] == MySQL Spatial + Mapserver + OGR == We were able to successfully render an output image from Mapserver with data stored in MySQL Spatial using OGR. There are many methods described around the web on how to successfully accomplish there, here's what we learned: * As of 2009/07/31, MyGIS support is deprecated and shouldn't be used. * The method of using OGR with a .ovf file didn't work for us, we were never able to find out why. === Mapfile Syntax === Simply specifying the OGR DSN in the CONNECTION statement of your LAYER definition proved successful. {{{ LAYER NAME "##LAYERNAME##" STATUS OFF CONNECTIONTYPE OGR CONNECTION 'MYSQL:##DATABASE##,user=##USERNAME##,pass=##PASSWORD##,tables=##TABLE##,##TABLE##,##TABLE##' DATA 'SELECT geom AS the_geom FROM ##TABLE##' TYPE POINT METADATA "WMS_TITLE" "title" "WMS_ABSTRACT" "QRAs" "WMS_SRS" "EPSG:4326 EPSG:900913" "WMS_EXTENT" "-180 -90 180 90" END CLASS COLOR 255 0 0 SIZE 20 END END }}} === TABLE Schema and Data === Here's the table structure that was used. {{{ -- -- Table structure for table `oc_ds_data` -- CREATE TABLE IF NOT EXISTS `##TABLE##` ( `id` int(10) unsigned NOT NULL auto_increment, `geom` geometry NOT NULL, `field0` varchar(255) default NULL, `field1` varchar(255) default NULL, `field2` varchar(255) default NULL, `field3` varchar(255) default NULL, `field4` varchar(255) default NULL, `field5` varchar(255) default NULL, `field6` varchar(255) default NULL, `field7` varchar(255) default NULL, `field8` varchar(255) default NULL, `field9` varchar(255) default NULL, PRIMARY KEY (`id`), KEY `oc_ds_id` (`oc_ds_id`), KEY `guid` (`guid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `oc_ds_data` (`id`, `geom`, `field0`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`) VALUES (1, GeomFromText('POINT(-105.08148 39.75366)'), ' One', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (2, GeomFromText('POINT(-105.07148 39.85366)'), ' Two', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (3, GeomFromText('POINT(-105.06148 39.95366)'), ' Three', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (4, GeomFromText('POINT(-105.05148 40.05366)'), ' Four', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (5, GeomFromText('POINT(-105.04148 40.15366)'), ' Five', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); }}}