I'm using Mapserver to display a raster in browser using a WMS request from OpenLayers. At the moment I have just one raster, and used the following method of styling it:
MAP
###########
NAME "ny_pop"
UNITS meters
SIZE 256 256
STATUS OFF
DEBUG ON
IMAGECOLOR 128 128 255
CONFIG "MS_ERRORFILE" "ms.log"
###########
PROJECTION
"init=epsg:900913"
END
###########
OUTPUTFORMAT
NAME "png"
DRIVER AGG/PNG
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
FORMATOPTION "GAMMA=0.75"
END
###########
WEB
METADATA
"wms_title" "WMS population layer"
"wms_onlineresource" "http://mysite.com/mapserv.cgi?map=population.map&"
"wms_enable_request" "GetMap GetFeatureInfo GetCapabilities"
END
END
###########
LAYER
NAME "new_york_pop"
DATA /home/mysite/webapps/htdocs/data/ny_pop_den.tif
STATUS OFF
TYPE RASTER
METADATA
"wms_title" "WMS NY Raster"
"wms_srs" "EPSG:900913"
END
CLASSITEM "[pixel]"
# class using simple string comparison, equivelent to ([pixel] = 0)
CLASS
EXPRESSION "0"
STYLE
COLOR 0 0 0
END
END
# class using an EXPRESSION using only [pixel].
CLASS
EXPRESSION ([pixel] > 0 AND [pixel] < 5000)
STYLE
COLOR 215 25 28
END
END
CLASS
EXPRESSION ([pixel] >= 5000 AND [pixel] < 10000)
STYLE
COLOR 253 174 97
END
END
END
I want to include several more rasters layers in this mapfile. Is there a way that I can apply the style to multiple layers by creating a style object and applying it to each layer? I'm not sure if this is the correct terminology as I could not spot how to do this on the mapserver site.
I thought about generating this using php, or copy/pasting this layer structure. If I go the copy/paste route the mapfile would become extremely long and hard to read.