Opened 17 years ago
#2039 new defect
SetRGB doesn't accept -1 as value
Reported by: | Owned by: | mapserverbugs | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapScript-PHP | Version: | 4.10 |
Severity: | minor | Keywords: | |
Cc: |
Description
In order to make a polygon with transparent fill, we have always specified a fill color of -1, e.g.: LAYER TYPE POLYGON CLASS STYLE OUTLINECOLOR 0 0 255 COLOR -1 -1 -1 END END END Trying to replicate this effect in PHP-Mapscript has proven impossible, as SetRGB ignores the color -1 and instead skips generating the COLOR line at all. Examples: // set color to blue fill, transparent fill $style->outlinecolor->setRGB(0,0,255); $style->color->setRGB(-1,-1,-1); # generated Mapfile block STYLE OUTLINECOLOR 0 0 255 END Perhaps this was intentional, but it causes problems in polygon layers. If the COLOR keyword is missing, polygon layers are drawn as polylines. In our case, we always have the SIZE keyword set in order to specify the spacing in the polygon's fill symbol (e.g. the tightness of the grid fill) and having it render as a polyline gave very different (and ugly!) results. My workaround was to, in my PHP code, omit the symbol and size if the color was -1, but it still seems that having the -1,-1,-1 saved to the mapfile would still be useful, at least as a placeholder. I've tracked this down to mapfile.c, line 504, in the writeColor() function. It calls MS_VALID_COLOR to decide whether to write the color to the new mapfile. MS_VALID_COLOR is set in map.h line 526 as being "R,G,andB are not -1"
Note:
See TracTickets
for help on using tickets.