1

I need to create simple square symbol composed of 4 internal squares.

SYMBOL
    NAME 'SQUARE_TL'
    TYPE vector
    FILLED true
    POINTS
        0 0
        0 0.5
        0.5 0.5
        0.5 0
        0 0
    END
END

SYMBOL
    NAME 'SQUARE_BL'
    TYPE vector
    FILLED true
    POINTS
        0 0.5
        0 1
        0.5 1
        0.5 0.5
        0 0.5
    END
END

SYMBOL
    NAME 'SQUARE_BR'
    TYPE vector
    FILLED true
    POINTS
        0.5 0.5
        0.5 1
        1 1
        1 0.5
        0.5 0.5
    END
END

SYMBOL
    NAME 'SQUARE_TR'
    TYPE vector
    FILLED true
    POINTS
        0.5 0
        0.5 0.5
        1 0.5
        1 0
        0.5 0
     END
END


LAYER
    NAME "test1"
    TYPE POINT
    STATUS off
    CLASS
        NAME "test1"
        EXPRESSION ([test_value]>0)  # if > 0 shows 4 sections square
        STYLE
            SYMBOL "SQUARE_TL"
            COLOR 0 255 0
            SIZE 14
        END
        STYLE
            SYMBOL "SQUARE_BL"
            COLOR 255 0 0
            SIZE 14
        END
        STYLE
            SYMBOL "SQUARE_BR"
            COLOR 100 100 100
            SIZE 14
        END
        STYLE
            SYMBOL "SQUARE_TR"
            COLOR 0 0 255
            SIZE 14
        END
    END
    **
*

TopLeft (TL) is green

BottomLeft (BL) is red

BottomRight (BR) is grey

TopRight (TR) is blue

But when I implement a CLASS LAYER STYLE with all of them I get this strange shifted/wrong square:

enter image description here

If I implement only top-left and bottom-right

    CLASS
        NAME "test1"
        EXPRESSION ([test1]>0)  # if > 0 shows 4 sections square
        STYLE
            SYMBOL "SQUARE_TL"
            COLOR 0 255 0
            SIZE 14
        END
        STYLE
            SYMBOL "SQUARE_BR"
            COLOR 100 100 100
            SIZE 14
        END
    END

I get

enter image description here

Ideas?

1

If you mean to have 1-4 adjacent color boxes at bottom-left, top-left, bottom-right, and top-right positions then I would do it by having one square symbol with points

 POINTS
    0 0
    0 1
    1 1
    1 0
    0 0
 END

Then I would make four copies of the symbol with different ANCHORPOINTs as documented in http://www.mapserver.org/mapfile/symbol.html.

The final mapfile with the four styles and one inline feature as data:

SYMBOL
    NAME 'SQUARE_TL'
    TYPE vector
    FILLED true
 POINTS
    0 0
    0 1
    1 1
    1 0
    0 0
 END
 ANCHORPOINT 1 1
 END

SYMBOL
    NAME 'SQUARE_BL'
    TYPE vector
    FILLED true
 POINTS
    0 0
    0 1
    1 1
    1 0
    0 0
 END
 ANCHORPOINT 1 0
 END

SYMBOL
    NAME 'SQUARE_TR'
    TYPE vector
    FILLED true
 POINTS
    0 0
    0 1
    1 1
    1 0
    0 0
 END
 ANCHORPOINT 0 1 
 END

SYMBOL
    NAME 'SQUARE_BR'
    TYPE vector
    FILLED true
 POINTS
    0 0
    0 1
    1 1
    1 0
    0 0
 END
 ANCHORPOINT 0 0
 END 


LAYER
    NAME "test1"
    TYPE POINT
    STATUS on
    FEATURE
        POINTS
        10 10
        END
   END
    CLASS
        NAME "test1"
        STYLE
            SYMBOL "SQUARE_TL"
            COLOR 0 255 0  #green
            SIZE 14
        END
           STYLE
            SYMBOL "SQUARE_BL" 
            COLOR 255 0 0 #red
            SIZE 14
        END   
          STYLE
        SYMBOL "SQUARE_TR"
        COLOR 0 0 255 #blue
        SIZE 14
        END    
          STYLE
        SYMBOL "SQUARE_BR"
        COLOR 100 100 100 #grey
        SIZE 14
        END    
    END
    END

The result looks like this (data point highlighted only for showing how the four boxes are places, yellow point does not come from MapServer).

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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