14.
MySQL MYGIS
Up one level
MyGIS reference
The MyGIS reference documentation can be found at:
http://dev.mysql.com/doc/refman/4.1/en/spatial-extensions.html
Adding a MyGIS layer
Note: the following instructions have been extracted from the the mapmygis.c source and I have not tried them myself. I am adding them here only to fill a gap in the documentation; comments and suggestions are welcome.
Standard ways of specifiying a MyGIS connection are:
- 'geometry_column from geometry_table'
- 'geometry_column from (<sub query>) as foo using unique <column name>; using SRID=<srid#>'
NOTE: for (2) 'using unique' and 'SRID=' are optional, but its highly recommended that you use them!!!
The most common problem with (1) is incorrectly uploading your data. There must be an entry in the geometry_columns table. This will be automatically done if you used the shp2mysql program or created your geometry column with the AddGeometryColumn() MYGIS function.
Another important thing to check is that the MYGIS user specified in the CONNECTION string does have SELECT permissions on the table(s) specified in your DATA string.
If you are using the (2) method (and have errors), you've probably made a typo. Example:
'the_geom from (select the_geom,oid from mytable) as foo using unique oid using SRID=76'
This is very much like the (1) example. The subquery ('select the_geom,oid from mytable') will be executed, and mapserver will use 'oid' (a postgresql system column) for uniquely specifying a geometry (for mapserver queries). The geometry (the_geom) must have a SRID of 76.
Example:
'roads from (select table1.roads,table1.rd_segment_id,table2.rd_name,table2.rd_type from table1,table2 where table1.rd_segment_id=table2.rd_segment_id) as foo using unique rd_segment_id using SRID=89'
This is a more complex sub-query involving joining two tables. The resulting geometry (column 'roads') has SRID=89, and mapserver will use rd_segment_id to uniquely identify a geometry. The attributes rd_type and rd_name are useable by other parts of mapserver.
To use a view, do something like:
'<geometry_column> from (SELECT * FROM <view>) as foo using unique <column name> using SRID=<srid#>'
For example:
'the_geom from (SELECT * FROM myview) as foo using unique gid using SRID=-1'
NOTE: for the (2) case, the ' as foo ' is requred. The 'using unique <column>' and 'using SRID=' are case sensitive.
Wrong info