Problems translating map file layers to mapscript
David Niergarth
dn at HDDESIGN.COM
Tue Oct 18 09:20:40 PDT 2005
I have a map file layer with the following class:
CLASS
COLOR 255 0 0
LABEL
FONT "arial"
TYPE TRUETYPE
POSITION CC
SIZE 8
ANTIALIAS TRUE
FORCE TRUE
OFFSET 0 0
COLOR 0 0 255
PARTIALS TRUE
END
END
When I try to add this layer using the mapscript API (rather than
including it in the map file), I get labels with an opaque (black)
background color and outline color. I can change the background color
but I can't figure out how to make it transparent, which is the effect I
effect I get when including the above in the map file. In other words, I
just want to see the type overlayed on top of the map. Can anyone
suggest why this isn't working? Here my Python mapscript translation of
the above:
c = mapscript.classObj(layer)
s = mapscript.styleObj(c)
s.color = mapscript.colorObj(255, 0, 0)
c.label = mapscript.labelObj()
c.label.font = 'arial'
c.label.type = mapscript.MS_TRUETYPE
c.label.position = mapscript.MS_CC
c.label.size = 8
c.label.minsize = 8
c.label.maxsize = 8
c.label.antialias = mapscript.MS_TRUE
c.label.force = mapscript.MS_TRUE
c.label.offsetx = 0
c.label.offsety = 0
c.label.color = mapscript.colorObj(0, 0, 255)
c.label.partials = mapscript.MS_TRUE
# Should I have to set these? Can they be made tranparent?
#c.label.backgroundcolor = mapscript.colorObj(255, 255, 255)
#c.label.outlinecolor = mapscript.colorObj(255, 255, 255)
I'm also having to specify c.label.minsize and c.label.maxsize,
otherwise the labels come out just one or two pixels tall. It's like
there are some defaults that are assumed in the map file but that need
to be made explicit in the mapscript version.
Any insights appreciated,
--David Niergarth
P.S. I wonder if anyone has ever written a code generator that could
translate map file fragments (like a layer) to mapscript API calls? I'm
discovering doing it by hand is pretty tedious.
More information about the MapServer-users
mailing list