Sigh... How do I make an OGR connection with mysql ?

Phillip Neal pneal at MBL.EDU
Sat Jul 1 10:00:24 EDT 2006


Dear Mapserver people,

I am trying to serve some data by WFS. I want to get the data  
directly out of a mysql database
table.

I have read the wiki , etc and searched around on the web for some  
answers but nothing
seems to help. Here is my  layer:

LAYER
     NAME "sites"
         METADATA
         "wfs_title"    "sites" ## REQUIRED
         "gml_include_items" "all"  ## Optional (serves all  
attributes for layer)

         END
     STATUS ON
     TYPE POINT
         DUMP TRUE
     CONNECTIONTYPE OGR
     CONNECTION "/var/www/docs/sites.ovf"
     DATA "sites"
     CLASS
        STYLE
             COLOR 0 0 0
        END #style
    END #class
END   #layer

Here is my ovf file:

<OGRVRTDataSource>
     <OGRVRTLayer name="sites">
          
<SrcDataSource>MYSQL:mydb,user=myuser,password=mypasswd,port=3306,tables
=sites</SrcDataSource>
         <SrcSQL>SELECT *  FROM sites</SrcSQL>
         <GeometryType>wkbPoint</GeometryType>
         <GeometryField encoding="PointFromColumns" x="latitude"  
y="longitude"/>
     </OGRVRTLayer>
</OGRVRTDataSource>

Here is my output (view sourced)

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
    xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
    xmlns:wfs="http://www.opengis.net/wfs"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengis.net/wfs http:// 
schemas.opengeospatial.net/wfs/1.0.0/WFS-basic.xsd
                        http://mapserver.gis.umn.edu/mapserver http:// 
somewhere/cgi-bin/mapserv-4.8.3? 
SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENA 
ME=sites&amp;OUTPUTFORMAT=XMLSCHEMA">
    <gml:boundedBy>
       <gml:null>missing</gml:null>
    </gml:boundedBy>
</wfs:FeatureCollection>

OGRINFO says everything is ok:

 >$ ./ogrinfo sites.ovf
ERROR 4: Update access not supported for VRT datasources.
Had to open data source read-only.
INFO: Open of `sites.ovf'
using driver `VRT' successful.
1: sites (Point)

and

 >$ ./ogrinfo sites.ovf -al
ERROR 4: Update access not supported for VRT datasources.
Had to open data source read-only.
INFO: Open of `sites.ovf'
using driver `VRT' successful.

Layer name: sites
Geometry: Point
Feature Count: 8
Extent: (45.916000, -129.985000) - (60.900000, -25.000000)
Layer SRS WKT:
(unknown)
id: Integer (20.0)
sample_id: String (255.0)
latitude: Real (22.0)
longitude: Real (22.0)
depth: Real (22.0)
temp: Real (22.0)
cell_conc: Real (22.0)
description: String (255.0)
notes: String (0.0)
date_collected: DateTime (0.0)
OGRFeature(sites):2
   id (Integer) = 2
   sample_id (String) = 53
   latitude (Real) =                     58
   longitude (Real) =                    -29
   depth (Real) =                   1400
   temp (Real) =                      4
   cell_conc (Real) =                  64000
   description (String) = (Labrador Sea Water), Eastern Atlantic Basin
   notes (String) = The water masses were identified based on the  
Sal, Temp characteristics.
   date_collected (DateTime) = 2002/09/16  0:00:00
   POINT (58.299999999999997 -29.132999999999999 0)


and a curl result returns:
  curl http://somewhere/cgi-bin/mapserv-4.8.3?map=/var/www/docs/ 
sites_wfs.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=getfeature&TYPENAME=site 
s
[1] 18085
[2] 18086
[3] 18087
[4] 18088
$ <HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<!-- MapServer version 4.8.3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG  
OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ  
SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT  
SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=THREADS INPUT=OGR  
INPUT=GDAL INPUT=SHAPEFILE -->
<BODY BGCOLOR="#FFFFFF">
mapserv(): Web application error. No template provided. <br>
</BODY></HTML>
[1]   Done                    curl http://somewhere/cgi-bin/ 
mapserv-4.8.3?map=/var/www/docs/sites_wfs.map
[2]   Done                    SERVICE=WFS
[3]-  Done                    VERSION=1.0.0
[4]+  Done                    REQUEST=getfeature

What am I doing wrong ?

Best regards,

Phil Neal



Phillip Neal
pneal at mbl.edu

"An ocean without its unnamed monsters would be like a completely  
dreamless sleep."

John Steinbeck - 'The Log from the Sea of Cortez'



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060701/92973178/attachment.html


More information about the mapserver-users mailing list