David,
On Oct 18, 2005, at 2:18 PM, David Niergarth wrote:
Hi Sean,
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.
When I set class.label.size = 8, I get one-pixel-tall labels. When I
set
both class.label.minsize and class.label.maxsize to 8, I the labels I
expect (but I have to set both max and min values). Is this perhaps
because I'm building the whole layer from scratch in mapscript and
there
are no initial values for those attributes? (This is similar to Damon's
response.)
We've been using ipython (a huge help) and the API docs to figure out
how to create our custom layers.
I suspect that you might be doing something like this:
class.label = mapscript.labelObj()
right? This could be your problem.
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.
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
4
>>> c.label.maxsize
256
those are the normal defaults, and will give you working labels. Now,
the problematic usage:
>>> l = mapscript.labelObj()
>>> l.minsize
0
>>> l.maxsize
0
>>>
this label is going to fail.
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.
cheers,
Sean
--
Sean Gillies
sgillies at frii dot com
http://zcologia.com