Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'd like to symbolise a point dataset with a square (or circle) using two colours. This is useful for displaying values collected on both sides of a road (for example).

split symbols

I created two symbols, a left side and right side of the square as shown below:

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

Then in my LAYER I can create a CLASS using the two different STYLES:

CLASS
    STYLE
        SYMBOL "SQUARE_L"
        COLOR [LEFT_CLR]
        SIZE 10
    END
    STYLE
        SYMBOL "SQUARE_R"
        COLOR [RIGHT_CLR]
        SIZE 10
    END
 END

However the features do not display correctly - they are not aligned correctly and are not of equal size (due to an overlap?). I thought I had resolved it by setting a "bounding box" in the symbol to make sure they were equal size:

SYMBOL
    NAME 'SQUARE_L'
    TYPE vector
    FILLED true
    POINTS
        0 0
        0 1
        0.5 1
        0.5 0
        0 0
        -99 -99 # increase bounding box so shape is correct size
        0 0
        1 0
        1 1
        0 1
        0 0
    END
END 

However I then noticed that the sides of the square were displayed with the wrong values. The MapServer symbol collection at http://github.com/mapserver/mapserver/wiki/SymbologyExchangeVector has some nice examples but none of which describe how to do this. Any ideas on how to achieve this in MapServer?

share|improve this question
add comment

1 Answer 1

The solution came from the MapServer users list. It is to have a full underlying square, and a half square on top.

http://lists.osgeo.org/pipermail/mapserver-users/2012-October/073443.html

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

  CLASS
     STYLE
         SYMBOL "SQUARE_FULL"
         COLOR [LEFT_CLR]
         SIZE 10
     END
     STYLE
         SYMBOL "SQUARE_R"
         COLOR [RIGHT_CLR]
         SIZE 10
     END
  END

Also pointed out was that in MapServer 6.2 there is a new ANCHORPOINT class which looks ideal for these situations.

One of the issues was that when viewing the layer in OpenLayers, using tiles, the symbols were being clipped as shown below. This can be resolved by using the gutter parameter in OpenLayers.

messed up squares

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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