Decode values in CGI query mode

Steve Lime steve.lime at DNR.STATE.MN.US
Mon Dec 13 11:31:50 PST 2004


Not in the mapfile, but you can do this using a MapServer join object.
You could set up an external database (MySQL, DBF and comma seperated
value files are supported) to hold the code and the long name. You
access the joined column then in your template.

So, if you have a file that looks like:

0,Long name for code 0
1,Long name for code 1
...

You could define something like this in your mapfile:

   JOIN
      NAME "longname"
      CONNECTIONTYPE CSV
      TABLE "lookup.txt"
      FROM "CODE"
      TO "1" # refers to column 1
    END

and in your query template perhaps something like:

[CODE]: [longname_2]

where [CODE] is from the dbf file and [longname_2] refers to the second
column in the longname join. Csv joins don't have column names hence the
column references. Hope this helps.

Steve

>>> Daniele Margotti <margottid at COMUNE.LUGO.RA.IT> 12/13/2004 3:44:30
AM >>>
Hi list,
I use CGI MapServer for browsing and querying shapefile-based maps.

This is the version:
<!-- MapServer version 4.2.3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
OUTPUT=WBMP OUTPUT=PDF SUPPORTS=FREETYPE INPUT=EPPL7 INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE -->

In a shapefile I have a numeric field which is a codified value (i.e.:
values 0, 1, 2, ... each corresponding to a very long description of
the
attribute).
I don't want / can't modify the shapefile and/or the .DBF file, and
I'd
like to set this long description ONLY ONE TIME in the mapfile, so
that
when I query the map I don't see the anonymous numeric values but
MapServer decodes and substitutes them with my more exausting long
description.

Is it possible to set these substitutions in the mapfile?

Thank you,
    Daniele



More information about the MapServer-users mailing list