Problems translating map file layers to mapscript
dn at HDDESIGN.COM
Tue Oct 18 22:30:04 EDT 2005
> I suspect that you might be doing something like this:
> class.label = mapscript.labelObj()
> right? This could be your problem.
Yes, that's exactly it.
> Instances of mapscript.classObj are **complete**. There is no need to
> create new attributes for them. A new instance of classObj already has a
> properly initialized labelObj as a "label" attribute. New instances of
> labelObj (as above) won't be properly initialized. That's just the way
> MapServer/mapscript is. Underneath the Python wrapper is a lot of C code
> which still presumes that we're parsing a mapfile.
Ok, I see now how it works now.
> Here's an example session:
> Python 2.3 (#1, Sep 13 2003, 00:49:11)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import mapscript
> >>> c = mapscript.classObj()
> >>> c.label.minsize
> >>> c.label.maxsize
> those are the normal defaults, and will give you working labels. Now,
> the problematic usage:
> >>> l = mapscript.labelObj()
> >>> l.minsize
> >>> l.maxsize
> this label is going to fail.
You have x-ray vision, I see! ;)
> Rule of thumb: whenever an object has another object attribute with a
> single value (such as the label attribute of a classObj), that attribute
> will be created and initialize by the parent's constructor.
Thanks for your help,
More information about the mapserver-users