mapscript.labelObj

class mapscript.labelObj

The LABEL object

Overview

The labelObj has the following relationships:

../../../_images/labelObj_classObj.png ../../../_images/labelObj_legendObj.png ../../../_images/labelObj_scalebarObj.png

Attributes

align

int See ALIGN

angle

double See ANGLE

anglemode

enum MS_POSITIONS_ENUM One of AUTO AUTO2, or FOLLOW - see ANGLE

autominfeaturesize

int MS_TRUE or MS_FALSE

buffer

int Space to reserve around a label (padding) - see BUFFER

color

colorObj Foreground color - see COLOR

encoding

char Supported encoding format to be used for labels - see ENCODING

font

char Name of TrueType font see FONT

force

int Indicates if labels must be drawn - see FORCE

maxlength

int See MAXLENGTH

maxoverlapangle

double See MAXOVERLAPANGLE

maxscaledenom

double See MAXSCALEDENOM

maxsize

int Maximum height in pixels for scaled labels.

mindistance

int Minimum distance in pixels between duplicate labels - see MINDISTANCE

minfeaturesize

int Minimum feature size (in pixels) to label, features of this size or greater will be labeled - see MINFEATURESIZE

minscaledenom

double See MINSCALEDENOM

minsize

int Minimum height in pixels - see MINSIZE

numstyles

int The number of styles associated with the label

offsetx

int Horizontal offset of label - see OFFSET

offsety

int Vertical offset of label - see OFFSET

outlinecolor

colorObj Color of one point outline - see OUTLINECOLOR

outlinewidth

int See OUTLINEWIDTH

partials

int Indicates if labels can run off the edge of an image, either MS_TRUE or MS_FALSE (default) - see PARTIALS

position

int See POSTION

priority

int Priority level 1 to MS_MAX_LABEL_PRIORITY, default=1 - see PRIORITY

refcount

int immutable TODO Add documentation

repeatdistance

int See REPEATDISTANCE

shadowcolor

colorObj See SHADOWCOLOR

shadowsizex

int See SHADOWSIZE

shadowsizey

int See SHADOWSIZE

size

int Annotation height in pixels - see SIZE

sizeunits

int Supersedes class's sizeunits, defaults to MS_INHERIT.

space_size_10

double Cached size of a single space character used for label text alignment of rfc40

thisown

The membership flag

wrap

char See WRAP

Methods

__init__()[исходный код]

Create a new labelObj. A labelObj is associated with a classObj a scalebarObj or a legendObj. An instance of labelObj can exist outside of a classObj container and be explicitly inserted into the classObj:

>>> new_label = new labelObj()
>>> the_class.addLabel(new_label)
convertToString() char[исходный код]

Output the labelObj object as a Mapfile string. Provides the inverse option for labelObj.updateFromString().

getBinding(binding: int) char const[исходный код]

Get the attribute binding for a specified label property. Returns NULL if there is no binding for this property.

getExpressionBinding(binding: int) char const[исходный код]
getExpressionString() char[исходный код]
getStyle(i: int) styleObj[исходный код]

Return a reference to the styleObj at index i in the styles array.

getTextString() char[исходный код]
insertStyle(style: styleObj, index: int = -1) int[исходный код]

Insert a copy of style into the styles array at index index. Default is -1, or the end of the array. Returns the index at which the style was inserted.

moveStyleDown(index: int) int[исходный код]

Swap the styleObj at index with the styleObj index + 1.

moveStyleUp(index: int) int[исходный код]

Swap the styleObj at index with the styleObj index - 1.

removeBinding(binding: int) int[исходный код]

Remove the attribute binding for a specified label property.

removeExpressionBinding(binding: int) int[исходный код]

Remove an expression binding for a specified label property.

removeStyle(index: int) styleObj[исходный код]

Remove the styleObj at index from the styles array and return a copy.

setBinding(binding: int, item: char const) int[исходный код]

Set the attribute binding for a specified label property. Binding constants look like this: MS_LABEL_BINDING_[attribute name]:

>>> new_label.setBinding(MS_LABEL_BINDING_COLOR, "FIELD_NAME_COLOR")
setExpression(expression: char) int[исходный код]

Set the label expression property

setExpressionBinding(binding: int, text: char const) int[исходный код]

Set the expression binding for a specified label property. Binding constants look like this: MS_LABEL_BINDING_[attribute name] Expressions are automatically wrapped in brackets, so do not need to be added to the input string

>>> new_label.setExpressionBinding(MS_LABEL_BINDING_PRIORITY, "[priority] * 2")
setText(text: char) int[исходный код]

Set the label text.

updateFromString(snippet: char) int[исходный код]

Update a labelObj from a string snippet. Returns MS_SUCCESS or MS_FAILURE