centering label inside a square

Steve Lime steve.lime at DNR.STATE.MN.US
Mon Mar 27 10:21:34 EST 2006


You might try using the label "OFFSET x y" parameter to tweak things
just a bit. Font metrics and placement are not always an exact science...

Steve 

>>> Dejan Gambin <dejan.gambin at PULA.HR> 03/26/06 6:53 AM >>>
Hi,

I am trying to label a higway using a square and a highway number inside it.
I am using:

SYMBOL
  NAME "square"
  TYPE VECTOR
  POINTS
    0 0
    0 0.6
    1 0.6
    1 0
    0 0
  END
  FILLED TRUE
END 

and the following layer definition:

LAYER
  NAME "highway"
  TYPE ANNOTATION
  DATA "highways"
  LABELITEM 'highway_number'
  CLASS
    EXPRESSION (length ("[highway_number]") eq 2) #this way I change the
square symbol depending of the higway number "width" (this is an example for
a square that holds higways with two numbers)
    STYLE
      SYMBOL 'square'
      SIZE 10
      COLOR 0 0 200
      OUTLINECOLOR 0 0 0
    END
    LABEL
      COLOR 255 255 255
      TYPE truetype
      FONT "arial"
      SIZE 8
      POSITION cc
    END
    TEMPLATE void
  END  # Class
# next class would have
END  # Layer

Everything seems OK except that label text is not centered in the square. I
have tried changing the symbol definition, size parameters, etc. but I don't
get it correct...

Any suggestions?

thanks, dejan



More information about the mapserver-users mailing list