Problems translating map file layers to mapscript
Sean Gillies
sgillies at FRII.COM
Tue Oct 18 11:49:31 PDT 2005
Comments inline ...
On Oct 18, 2005, at 11:21 AM, Damon Butler wrote:
>> # Should I have to set these? Can they be made tranparent?
>
> Yes. And Yes.
>
>> #c.label.backgroundcolor = mapscript.colorObj(255, 255, 255)
>> #c.label.outlinecolor = mapscript.colorObj(255, 255, 255)
>
> They can be made transparent by supplying negative numbers for the R,
> G,
> and B values.
>
> c.label.backgroundcolor = mapscript.colorObj(-1, -1, -1)
> c.label.outlinecolor = mapscript.colorObj(-1, -1, -1)
>
Never done must this be! Proper usage is
c.label.backgroundcolor.setRGB(-1, -1, -1)
c.label.outlinecolor.setRGB(-1, -1, -1)
Otherwise the previously defined colors will be dereferenced improperly
and never cleaned up by Python's garbage collector. Anyhow, these
attributes begin with default values (-1, -1, -1), so no need to alter
them if you want the no-background default.
> But I'm afraid that I don't have any insights into your other queries
> (repeated below).
>
> --Damon
>
>> 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,
>>
No, the defaults are fine with mapscript. If you have turned on auto
label scaling, then you will need to set minsize and maxsize.
Otherwise, class.label.size controls all.
>> --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.
David, define all this boilerplate in a mapfile, and then modify that
configuration with mapscript:
m = mapscript.mapObj('template.map')
l = m.getLayer(0)
l.status = mapscript.MS_ON
l.name = 'activated layer'
...
cheers,
Sean
--
Sean Gillies
sgillies at frii dot com
http://zcologia.com
More information about the MapServer-users
mailing list