Author: Till Adams, terrestris GbR Bonn (Geo-Consortium)


Install unixodbc

Install libmyodbc

(apt-get install [packagename] )


Edit the Files etc/odbcinst.ini and etc/odbc.ini, so that they look like this:


odbcinst.ini:


[MySQL]

DESCRIPTION = MySQL Database connect

DRIVER = /usr/lib/odbc/libmyodbc.so

Setup = /usr/lib/odbc/libodbcmyS.so

FileUsage = 1


where MySQL is the driver name


odbc.ini

[MySQL]

DSN = wpms

DESCRIPTION = mysql driver 3.51

DRIVER = MySQL

SERVER = localhost

PORT = 3306

USER = root

Password =

Database = wpms

SOCKET = /var/run/mysqld/mysqld.sock


where MySQL refers to the [MySQL] in the odbcinst.ini file.


Edit the table "db" of the database "mysql" and insert sth. like:

INSERT INTO `db` VALUES

(localhost, [databasename], [user], 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y');


In our example on top: (localhost, wpms, root, 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y');


Leave the [user] blank, if no user must be specified.


as root do the following:

# mysqladmin reload


Try the connection via:


# isql MySQL test -v


You should get s.th. like:

+---------------------------------------+

| Connected! |

| |

| sql-statement |

| help [tablename] |

| quit |

| |

+---------------------------------------+

SQL>

Get out of there with a


#SQL> q


Then look for your binary ogrinfo (should be in the subfolder of where you've compiled gdal!

Ensure you compiled gdal with the --with-odbc option:


# ./configure --with-odbc

# make

# make install


Otherwise do this now, there should'nt be problems in doing this again (don't bother me!!).


After that you have to recompile your mapserver, so be glad if you've stored the sources somewhere!


OK, another püroblem rised up with me: I have gdal 1.2.6 which depends on the libtff4 v3.7.x, but on my system there was the libtiff v3.6.x - so my default option to compile mapserver --without-tiff didn' work. I got the problem, which nobody want to have, you copy your error to google and there's no reply! Shit. But playing around a little bit I got it working like described above!


So, the system is ready for now.


Fine. Now make an ovf-File, which looks like this (there are many more options, but these are enough for a simple view!!):


<OGRVRTDataSource>

<OGRVRTLayer name="stations">

<SrcDataSource>ODBC:root@MySQL</SrcDataSource> # This means user/passwd @ DNS

<SrcLayer>liste_wea_koordinaten</SrcLayer> # This is your table in the db

<GeometryType>wkbPoint</GeometryType>

<!-- <LayerSRS>WGS84</LayerSRS> -->

<GeometryField encoding="PointFromColumns" x="x" y="y"/> #

</OGRVRTLayer>

</OGRVRTDataSource>


Where x and y are the attributes with the x/y coordinates.


Name it as you like (in this case virtuallayer.ovf)


Now you can run a test using the ogrinfo binary from the ogr library:


# /usr/local/bin/ogrinfo /var/data/ovf/virtuallayer.ovf


should reply with this:


brain:~# /usr/local/bin/ogrinfo /var/data/ovf/virtuallayer.ovf

ERROR 4: Update access not supported for VRT datasources. # normal, ask FW!

Had to open data source read-only.

INFO: Open of `/var/data/ovf/virtuallayer.ovf'

using driver `VRT' successful.

1: stations (Point)


Or use the -al option to actually see the data:

# /usr/local/bin/ogrinfo -al /var/data/ovf/virtuallayer.ovf



MapServer:

Refer in your mapfile to this as: The example below means, that the ovf file is just in the same folder than the mapfile, otherwise specify a path!


LAYER

NAME "My-stations"

TYPE POINT

CONNECTIONTYPE OGR

CONNECTION "virtuallayer.ovf"

DATA 'stations'

STATUS ON


PROJECTION

"init=epsg:32632"

END


TOLERANCE 3


METADATA

WMS_TITLE "stations example"

WMS_ABSTRACT "stations used for any ovf example "

WMS_SRS "EPSG:32632" # 26915

END

CLASS

NAME 's'

SYMBOL 'circle'

SIZE 8

COLOR 0 255 0

OUTLINECOLOR 0 0 0

END


END


Then try!


Cheers, Till