Changes between Initial Version and Version 1 of MySQLSpatial


Ignore:
Timestamp:
Jul 31, 2009, 11:08:21 AM (15 years ago)
Author:
mikehostetler
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MySQLSpatial

    v1 v1  
     1= MySQL Spatial Support =
     2
     3----
     4The official document is at: http://www.mapserver.org/input/vector/mysql.html
     5----
     6
     7Author: [http://amountaintop.com Mike Hostetler], [http://amountaintop.com A Mountain Top, LLC]
     8
     9== MySQL Spatial + Mapserver + OGR ==
     10
     11We 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:
     12
     13 * As of 2009/07/31, MyGIS support is deprecated and shouldn't be used.
     14 * The method of using OGR with a .ovf file didn't work for us, we were never able to find out why.
     15
     16=== Mapfile Syntax ===
     17
     18Simply specifying the OGR DSN in the CONNECTION statement of your LAYER definition proved successful.
     19
     20{{{
     21  LAYER
     22    NAME "##LAYERNAME##"
     23    STATUS OFF
     24    CONNECTIONTYPE OGR
     25    CONNECTION 'MYSQL:##DATABASE##,user=##USERNAME##,pass=##PASSWORD##,tables=##TABLE##,##TABLE##,##TABLE##'
     26    DATA 'SELECT geom AS the_geom FROM ##TABLE##'
     27
     28    TYPE POINT
     29    METADATA
     30        "WMS_TITLE"      "title"
     31        "WMS_ABSTRACT"   "QRAs"
     32        "WMS_SRS"        "EPSG:4326 EPSG:900913"
     33        "WMS_EXTENT"     "-180 -90 180 90"
     34    END
     35    CLASS
     36      COLOR 255 0 0
     37      SIZE 20
     38    END
     39  END
     40}}}
     41
     42=== TABLE Schema and Data ===
     43
     44Here's the table structure that was used.
     45
     46{{{
     47
     48--
     49-- Table structure for table `oc_ds_data`
     50--
     51
     52CREATE TABLE IF NOT EXISTS `##TABLE##` (
     53  `id` int(10) unsigned NOT NULL auto_increment,
     54  `geom` geometry NOT NULL,
     55  `field0` varchar(255) default NULL,
     56  `field1` varchar(255) default NULL,
     57  `field2` varchar(255) default NULL,
     58  `field3` varchar(255) default NULL,
     59  `field4` varchar(255) default NULL,
     60  `field5` varchar(255) default NULL,
     61  `field6` varchar(255) default NULL,
     62  `field7` varchar(255) default NULL,
     63  `field8` varchar(255) default NULL,
     64  `field9` varchar(255) default NULL,
     65  PRIMARY KEY  (`id`),
     66  KEY `oc_ds_id` (`oc_ds_id`),
     67  KEY `guid` (`guid`)
     68) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
     69
     70INSERT INTO `oc_ds_data` (`id`, `geom`, `field0`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`) VALUES
     71(1, GeomFromText('POINT(-105.08148 39.75366)'), ' One', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
     72(2, GeomFromText('POINT(-105.07148 39.85366)'), ' Two', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
     73(3, GeomFromText('POINT(-105.06148 39.95366)'), ' Three', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
     74(4, GeomFromText('POINT(-105.05148 40.05366)'), ' Four', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
     75(5, GeomFromText('POINT(-105.04148 40.15366)'), ' Five', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     76}}}