[MapServer-dev] Variables in mapfiles

Rahkonen Jukka jukka.rahkonen at maanmittauslaitos.fi
Thu Nov 9 15:08:13 PST 2023


When I was reading the old bug reports in the OSGeo code sprint this 20 years old one https://github.com/MapServer/MapServer/issues/408 from year 2003 did not feel rotten at all. And the last comment https://github.com/MapServer/MapServer/issues/408#issuecomment-1065080140 has received 5 thumbs up within 1 year which shows great user activity by our standards.

I think that environmental variables may be too strong tool for this purpose. For example, are those who write mapfiles allowed to set env variables in managed environments? Maybe something similar to SYMBOLSET and INCLUDE would be easier to use.
As an example, I found a pretty good bug report that includes a mapfile and data, but for testing the mapfile on my Windows machine I need to make a few edits.

CONFIG "PROJ_LIB" "/usr/local/share/proj"
                          I am on Windows and my proj is in some other place
WMS_ONLINERESOURCE http://odroid1:5001/
wms_service_onlineresource http://odroid1:5001/
                          I don't understand the difference between those two, but anyway I run Mapserver at http://localhost:8060/...
DATA "./bug-report.xml"
                          I prefer to keep data in different place than mapfiles
DATA "./data-in-31287"
                          Same for this shapefile data

What if we could write non-fixed paths and other items into the mapfile like

CONFIG "PROJ_LIB" "%proj_lib%"
WMS_ONLINERESOURCE "%onlineresource_test%"
wms_service_onlineresource "%onlineresource_test%"
DATA "%datapath_test%/bug-report.xml"
DATA "%datapath_test%/data-in-31287"
MAPVARIABLES "map_variables.txt"
END # mapfile

The contents of "map_variables.txt"

//Some magic
proj_lib                                      [value]
onlineresource_test                [value]
onlineresource_qa                  [value]
onlineresourse_production   [value]
datapath_test                           [value]
datapath_qa                             [value]
datapath_production             [value]
symbolset_topomap               [value]
symbolset_citymap                 [value]

A difference to INCLUDE is that while the whole include file is slipped inside the mapfile the variable file could be a dictionary. That would allow forwarding the mapfile from test to qa to production easily. And when the IP address of test servers change an edit in one place would be enough. It would still be possible to use separate "map_variables_testing.txt" for testing if it feels better.

I admit that there are alternative scenarios via INCLUDE or config file or environmental variables.

-Jukka Rahkonen-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20231109/d95e5ecf/attachment.htm>

More information about the MapServer-dev mailing list