[mapserver-dev] mapscript styleObj and colorObj
Seth G
sethg at geographika.co.uk
Sun Dec 22 06:41:04 PST 2019
Hi all,
A general mapscript question I'm hoping someone can provide some information on.
Should any attribute that is a C class be read-only in SWIG, and requires getters/setters to update?
For example the styleObj attributes [1] includes a color property that is of type colorObj. This can be set in MapScript, but I believe this causes undefined behaviour, and any property that is not a basic int/str/float type will need a setter function added in the SWIG interface files.
For example the following Python script runs without crashing, however when output back to a Mapfile contains strange results:
import mapscript
style = mapscript.styleObj()
style.updateFromString("""
STYLE
COLOR 1 2 3
END # STYLE
""")
success = style.color.setRGB(100, 150, 200)
# the following asserts all pass
assert success == mapscript.MS_SUCCESS
assert style.color.red == 100
assert style.color.green == 150
assert style.color.blue == 200
assert style.color.alpha == 255
print(style.convertToString())
Outputs the following:
STYLE
COLOR 200 255 3
END # STYLE
Note the blue value has become red, the alpha green, and I don't know where the 3 comes from.
I'm guessing the setter function for the styleObj color needs to be added?
Seth
[1] https://mapserver.org/mapscript/mapscript.html#styleobj-attributes
--
web:http://geographika.co.uk
twitter: @geographika
More information about the mapserver-dev
mailing list