[Mapserver-dev] COLOR_MATCH_THRESHOLD
Frank Warmerdam
warmerdam at pobox.com
Fri Feb 28 15:57:21 EST 2003
Folks,
I can't recall who brought up the issue of vectors being drawn in gray
when a grayscale image is drawn first (because it sucked up the colors).
Well, we discussed adding a mechanism to force raster layers to use less
colors here, and I have now implemented such a mechanism. Currently it is
implemented as the COLOR_MATCH_THESHOLD processing directive, such as shown
here:
LAYER
NAME grey
TYPE raster
PROCESSING "COLOR_MATCH_THRESHOLD=3"
STATUS default
DATA data/grey.tif
END
When looking for a matching color for a color entry in a raster layer, the
logic now is to compare the "distance" from the desired color to this
threshold. The details are in msAddColorGD() in mapraster.c but the gist
of it is that you should set the threshold to "3" to be allow a color 1 off
in each of red, green and blue to match.
The default threshold is zero, meaning an exact match is required if possible,
and if not a new color will be allocated. As before it will fall back to
using the nearest color if the colormap is full.
If we like this option we might want to promote it to having a proper keyword
in the mapfile, and ensure it works for the other raster layer types.
Currently it only works for GDAL rendered raster layers.
In fact, such a mechanism might be desirable for other color allocation such
as that occuring due to colors loaded from vector files using the OGR "AUTO
styling". However, that is a bigger effort than I am interested in pursuing
at this time.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the mapserver-dev
mailing list