[mapserver-users] Mapfile Variables

Stephen Woodbridge woodbri at swoodbridge.com
Tue Jun 19 06:14:08 PDT 2012


On 6/19/2012 2:15 AM, Matt McClelland wrote:
> Hi All
>
> Is is possible create and use variables within a mapfile?
> IE I want to store the colour of a road in one place, then reference
> that colour in the several style tags
>
> EG
> $road_colour_inside = "255 0 0 "
> then later in the style tags be able to do
> color $road_colour_inside
>
> Or something similar.
>
> I am using v6.0

Short answer is no.
What I and others have done as a workaround to this is to use the cpp, 
the C preprocessor.

EG

#define _ROAD_COLOR_INSIDE "255 0 0"

COLOR _ROAD_COLOR_INSIDE


Then run the cpp, If you want to see a great example of this look at:

https://github.com/mapserver/basemaps

-Steve W


More information about the mapserver-users mailing list