[mapserver-users] OGR shapefile w/MySQL Join

Steve Lime Steve.Lime at dnr.state.mn.us
Thu Sep 3 06:16:42 PDT 2009


This isn't an instance where a JOIN block is particularly useful. I need the
MySQL attributes for map making and JOINs are only used with query
results. Plus the MySQL join driver assumes integer keys and I have strings.
Hence my hope to do the join in OGR before the data even hit MapServer.

Anywho, I use the CSV join driver all the time. Looking at your example
the syntax for specifying the CSV column looks wrong. The CSV driver
assumes there are no column names in the first row. Might be a nice
addition in the future but for now you just use a column reference
(1..n). The documentation at:

  http://mapserver.org/mapfile/join.html

for CSV is flat out wrong (too much cut and paste). I'll have a go at fixing
that. Join element should look like:

  JOIN
    NAME "test"
    TABLE "../data/lookup.csv"
    FROM "ID"
    TO "1"
    TYPE ONE-TO-ONE
  END

The column names can be left in place in the actual file, that row just won't
match anything.

Steve

>>> Greg Luker <gluker at scu.edu.au> 09/03/09 1:17 AM >>>
Hi mapservers,

At 12:47 AM 3/09/2009, Steve Lime wrote:
>Hi all: Anyone have a sample configuration for creating an OGR layer 
>joined to a MySQL table? The
>MySQL table has no spatial component. I believe it's possible but 
>haven't stumbled upon a concrete
>example showing how. Figured better just to ask... Thanks.

I'd be really interested to see how you get this to work, Steve. I 
cannot get the JOIN command to work, even on a simple csv file.

Here's what I have tried:
         LAYER
                 NAME "squares"
                 TYPE POLYGON
                 STATUS ON
                 DATA "squares"
                 CLASS
                         ...
                 END
                 TOLERANCE 20
                 TEMPLATE "testm_template.html"
                 HEADER "testm_header.html"
                 FOOTER "testm_footer.html"
                 JOIN
                         NAME "jointest"
                         TABLE "testm.csv"
                         FROM "IDENT"
                         TO "id"
                 END
         END #of layer

testm.csv is in the same directory as the mapfile. The shapefile 
(squares) shows up fine, but querying it gives this message:

Status: 302 Found Uri: http://.../errors/errors.html Location: 
http://.../errors/errors.html Content-type: text/html

and this debug message:

[Thu Sep  3 15:37:43 2009].493754 msDBFJoinConnect(): Unable to 
access file. (testm.csv)

Commenting out the JOIN lines gives correct expected results, so I 
assume everything else is in the right place (including template 
files). I've tried a few variations of "testm.csv" - like 
"'testm.csv'" and "/full/pathname/to/testm.csv" but still no luck. I 
tried JOINing a shape to an OGR MySQL table, but that didn't work, 
which is why I dropped back to testing with a simple csv JOIN.

Any ideas?

Thanks,
Greg.


Greg Luker
GIS Lab Manager, Southern Cross University
Lismore, AUSTRALIA.
gluker at scu.edu.au
phone 61 2 66203026



_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list