[mapserver-users] LABEL - POSITION and FONT Calculations

Donald Kerr donald.kerr at dkerr.co.uk
Mon Dec 29 06:13:39 PST 2008


I have a problem that has me stumped.

I am trying to place text on a map as a LABEL which I can successfully do
with the following code:

LAYER CONNECTIONTYPE postgis
	NAME "CartographicText"
	CONNECTION "user=postgres dbname=MasterMap host=localhost"
	DATA "geom FROM (SELECT toid, featurecode, textstring,
orientation/10 AS orientation, fontnumber, anchorposition, textstyle, geom
FROM cartographictext) AS foo USING UNIQUE toid" 

	METADATA
		"IMAGEFORMAT" "AGGA"
	END

	STATUS DEFAULT
  
	MINSCALEDENOM 1
	MAXSCALEDENOM 1300
	SYMBOLSCALEDENOM 1250

	TYPE ANNOTATION

	LABELITEM textstring

	CLASS
		# Road Name Or Classification
		EXPRESSION ([featurecode] = 10169)
		LABEL
			TYPE truetype
			FONT arial
			SIZE 10
			MAXSIZE 30
			MINSIZE 0
			COLOR  0 0 0
			ANTIALIAS TRUE
			ANGLE [orientation]
		END # LABEL
	END # CLASS

	CLASS
		# Building or Structure Text
		EXPRESSION ([featurecode] = 10026)
		LABEL
			TYPE truetype
			FONT arial
			SIZE 7
			MAXSIZE 21
			MINSIZE 0
			COLOR  0 0 0
			ANTIALIAS TRUE
			ANGLE [orientation]
		END # LABEL
	END # CLASS

END # LAYER

I want to add POSITION based on [anchorposition] from the database.

The database grid for anchorposition is as follows:

2  5  8
1  4  7
0  3  6

Whereas MapServer is as follows

ul uc ur
cl cc cr
ll lc lr

Which is probably:

0  1  2
3  4  5
6  7  8

The question is: Is it possible to take the values from the database and
convert them for use within the LABEL e.g. 2 = ul = "POSITION ul" or 5 = uc
= "POSITION uc"?

I would also like to be able to change the Font based on [fontnumber] from
the database e.g. 0 = Arial = "FONT arial" or 1 = Times = "FONT times"

Are these things possible?

Many thanks.

Regards,

Donald Kerr




More information about the MapServer-users mailing list