[mapserver-users] Mapfile Variables

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Tue Jun 19 09:30:19 PDT 2012


Hi,

My shortish answer is that have a try with INCLUDE. If you had

STYLE
            WIDTH 10
            OUTLINEWIDTH 1
            OUTLINECOLOR "#24277A"
END
STYLE
            WIDTH 10
            COLOR "#4F719D"
END

try changing it to 

STYLE
            WIDTH 10
            OUTLINEWIDTH 1
            INCLUDE "\styles\my_motorway_outline_color.txt"
END
STYLE
            WIDTH 10
            INCLUDE "\styles\my_motorway_line_color.txt"
END

Next create and save the corresponding files "my_motorway_outline_color.txt" and "my_motorway_line_color" as 

OUTLINECOLOR "#24277A"
and
COLOR "#4F719D"

I have never tried that but it should work.

-Jukka Rahkonen-

Stephen Woodbridge wrote:

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
_______________________________________________
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