MySql Spatial Database

Frank Warmerdam warmerdam at POBOX.COM
Thu Oct 5 10:13:46 EDT 2006


Murat BEYHAN wrote:
> Frank,
> I'm really getting love mapserver.
> Its easy to learn and to do any kind of powerful map.
> But There is another problem.I store the data in the mysql and draw it but How
> can I query data stored in mysql by using ogr.
> I mean how can I send variable from php to OGR
> 
> I would like to make select statement for the ogr. But How?
> By following expression I can draw point layer. But the data are not in
> spatial database. They are Just table and I read the column from table for lat
> lon and by using connectiontype ogr connection I can draw point.
> My second issiu to draw polygone layer stored in Mysql spatial database. OK O
> have succeeded to do, too. And third issiu to draw only one district which
> data stored in Mysql spatial databese.
> So I think I have to construct one select statement as follows but How can I
> construct select statement for the mysql spatial database. I dont have any
> experiences. Could you give me some point about that. If I could this I can
> finalize my study then will be ready to publish it on the net.
> Regards 
> Murat
> 
> <OGRVRTDataSource>
>     <OGRVRTLayer name="koymrk">
>        
> <SrcDataSource>MYSQL:bina,user=root,password=mysql_123,host=localhost,port=3306,tables=zoneson</SrcDataSource>
>         <SrcSQL>SELECT lat,lon,koyadi from zoneson  </SrcSQL>
>         <GeometryType>wkbPoint</GeometryType>
>         <GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
>     </OGRVRTLayer>
> </OGRVRTDataSource>
> ~

Murat,

There are a few query concepts that come into play.  MapServer has a concept
of query that should operate against your layers without changing the OVF
XML or regular connection info.  There should be description of that on the
MapServer site ... I've only rarely used it from mapscript.

But if you just want to draw a reduced set of features based on a custom
query, there are other ways to handle that.  For the polygon layer directly
accessed from MYSQL without an OVF file, you can just put a SELECT statement
in your DATA line instead of simply listing a table.

eg.
DATA "SELECT * from polytable WHERE <some condition>"

For the above OVF case you can make the SrcSQL statement more complicated as
long as the result set still includes the fields you need.

Good luck,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the mapserver-users mailing list