0

My layer Point (OGR geojson) has several classes:

CLASS
    NAME "Station1"
    EXPRESSION ([extrude]=0)        
    STYLE
        COLOR 0 0 250
        OUTLINECOLOR 255 255 255
        SYMBOL 'circle'
        SIZE 6
    END
        LABEL
        SIZE TINY
        COLOR 0 0 0
        OUTLINECOLOR 255 255 255
        POSITION AUTO
    END
END
CLASS
    NAME "Station2"
    EXPRESSION ([extrude]=1)        
    STYLE
        COLOR 250 0 0
        OUTLINECOLOR 255 255 255
        SYMBOL 'circle'
        SIZE 10
    END
        LABEL
        SIZE TINY
        COLOR 255 0 0
        OUTLINECOLOR 255 255 255
        POSITION AUTO
    END
END    
CLASS
    NAME "Station3"
    EXPRESSION ([extrude]=2)        
    STYLE
        COLOR 128 0 128 #purple
        OUTLINECOLOR 255 255 255
        SYMBOL 'circle'
        SIZE 14
    END
        LABEL
        SIZE TINY
        COLOR 128 0 128
        OUTLINECOLOR 255 255 255
        POSITION AUTO
    END
END

If N points are overlaying I need to have a specific order. Station3 on top of Station2 on top of Station 1. Inverting the order nothing has changed. Ideas?

2 Answers 2

1

you can use PRIORITY in LABEL:

For LABEL (http://mapserver.org/es/mapfile/label.html):

PRIORITY [integer]|[item_name]|[attribute]

The priority parameter takes an integer value between 1 (lowest) and 10 (highest). The default value is 1. It is also possible to bind the priority to an attribute (item_name) using square brackets around the [item_name]. e.g. “PRIORITY [someattribute]”

Labels are stored in the label cache and rendered in order of priority, with the highest priority levels rendered first. Specifying an out of range PRIORITY value inside a map file will result in a parsing error. An out of range value set via MapScript or coming from a shape attribute will be clamped to the min/max values at rendering time. There is no expected impact on performance for using label priorities.

[Attribute] was introduced in version 5.6.

Nuevo en la versión 5.0.

another idea is to change the order of your classes, ie. put first Station3, then Station2 and so forth.

Hope this helps,

0

The only "right" way to achieve a correct alignment of the object on the map is sorting at the level of data acquisition!

Unfortunately MapServer cannot draw objects according to the order of the classes.

As a temporary solution (not very optimal), move the objects to another layer and merge them into one using:

GROUP [name] in Layer object

Name of a group that this layer belongs to. The group name can then be reference as a regular layer name in the template files, allowing to do things like turning on and off a group of layers at once.

If a group name is present in the LAYERS parameter of a CGI request, all the layers of the group are returned (the STATUS of the LAYERs has no effect).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.