RSS

Map File and MySQL

15 Mar

Introduction
The following methods connect to MySQL through OGR’s MySQL driver, thus avoiding the need to set up an ODBC connection.

Connecting to Spatial Data in MySQL
This section describes how to display a spatial MySQL table (meaning that the table has a column of type geometry) in MapServer. OGR’s MySQL driver was expanded in OGR version 1.3.2 to support access to MySQL spatial tables.

Requirements

  • MapServer compiled with OGR support
  • OGR/GDAL version 1.3.2 or more recent compiled with MySQL support

Create MapServer Layer
LAYER
NAME “spain_provinces_mysql_spatial”
TYPE POLYGON
STATUS DEFAULT
CONNECTIONTYPE OGR
CONNECTION “MySQL:test,user=root,password=mysql,port=3306”
DATA “SELECT SHAPE,admin_name from province”
LABELITEM “admin_name”
CLASS
NAME “Spain Provinces”
STYLE
COLOR 240 240 240
OUTLINECOLOR 199 199 199
END
LABEL
COLOR 0 0 0
FONT sans
TYPE truetype
SIZE 8
POSITION AUTO
PARTIALS FALSE
OUTLINECOLOR 255 255 255
END
END
END # layer
The DATA parameter is used to perform the SQL select statement to access your table in MySQL. The geometry column is required in the select statement; in the above example the SHAPE column is the geometry column in the province table.

Connecting to non-Spatial Data in MySQL
This section describes how to display a non-spatial MySQL table (meaning the table does not have a column of type geometry) in MapServer.
Support for this functionality is found in GDAL/OGR 1.2.6 and older on Windows and GDAL/OGR 1.3.2 on Linux.

Requirements
MySQL database containing a table with fields containing x and y coordinates
.ovf file, a small xml file you will create
MapServer compiled with OGR version supporting this functinality

More Information
OGR (MapServer OGR document)
Vector Data (MapServer Vector Data Access Guide)
MySQL wiki page (describes the deprecated mygis support)

http://mapserver.org/input/vector/mysql.html

 
Tinggalkan komentar

Ditulis oleh pada 15 Maret, 2012 in Database Spasial

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: