[mapserver-users] anchor label positions

Donald Kerr donald.kerr at dkerr.co.uk
Thu Sep 12 00:47:07 PDT 2013


I am now using a case statement/switch within the SQL since the data is in a
PostGis table. I am not sure if it is possible to use SQL to return a subset
of data from a Shapefile in Mapserver. If it is then the following may help.
It would be neat if the calculation 'CASE' could be done within the
LABEL/POSITION.

 

# POSITION 

#

# The anchorposition is as follows in the CartographicText table:

#

# 2  5  8

# 1  4  7

# 0  3  6

#

# Corresponding MapServer positions

#

# ul uc ur

# cl cc cr

# ll lc lr

#

# Corresponding OpenLayers positions

#

# lt ct rt

# lm cm rm

# lb cb rb

 

# fontnumber

# 0 - Lutheran (used for non-Roman antiquities)

# 1 - Normal - Medium Roman font

# 2 - Light Roman font (used primarily for building numbers, Roman
antiquities, and some administrative names particularly in 1:10 000 areas)

# 3 - Suppressed text not supplied in Land-Line due to space limitations.

 

# textstyle

# 0 - Normal

# 1 - Italics

 

# Mapserver ANGLE is anticlockwise

# MasterMap orientation is measured in tenths of a degree anticlockwise from
due east (0-3599)

# For clockwise, ANGLE can be changed thus (360-ANGLE)

 

DATA "geom FROM (SELECT toid, featurecode, textstring, height,
orientation/10 AS orientation, ('x'||substring(col,1,2))::text::bit(8)::int
|| ' ' || ('x'||substring(col,3,2))::text::bit(8)::int || ' ' ||
('x'||substring(col,1,2))::text::bit(8)::int AS oscolor, CASE WHEN
fontnumber = 0 AND textstyle = 0 THEN 'BlackCastleMF' WHEN fontnumber = 0
AND textstyle = 1 THEN 'BlackCastleMF' WHEN fontnumber = 1 AND textstyle = 0
THEN 'arial' WHEN fontnumber = 1 AND textstyle = 1 THEN 'arialitalic' WHEN
fontnumber = 2 AND textstyle = 0 THEN 'arial' WHEN fontnumber = 2 AND
textstyle = 1 THEN 'arialitalic' ELSE 'arial' END AS font, CASE WHEN
anchorposition=0 THEN 'ur' WHEN anchorposition=1 THEN 'cr' WHEN
anchorposition=2 THEN 'lr' WHEN anchorposition=3 THEN 'uc' WHEN
anchorposition=4 THEN 'cc' WHEN anchorposition=5 THEN 'lc' WHEN
anchorposition=6 THEN 'ul' WHEN anchorposition=7 THEN 'cl' WHEN
anchorposition=8 THEN 'll' ELSE 'auto' END AS anchorpositiontxt, geom FROM
cartographictext) AS foo USING UNIQUE toid"

 

Regards,

 

Donald

 

 

From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Schylberg Lars
Sent: 12 September 2013 07:53
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] anchor label positions

 

Hello,

I have read the following discussion below but have not found out if
anything has happened since then.

http://lists.osgeo.org/pipermail/mapserver-users/2008-December/059123.html

 
<http://lists.osgeo.org/pipermail/mapserver-users/2010-November/067312.html>
http://lists.osgeo.org/pipermail/mapserver-users/2010-November/067312.html

I have shape files with anchor  point positions:

7 8 9

4 5 6

1 2 3

That corresponds:

ul uc ur 

cl cc cr 

ll lc lr

I wrote my mapfile as shown below.  Is there a more  simple and shorter way
to express this today?

TJUST variable is the POSITION expressed as a integer between 1 and 9 in my
shape files

If there is no way to do this, could I remap the shape file with ogr2ogr to
add an extra column in the table with mapserver positions?

/Lars

LAYER

        NAME 'LAKESNAMES'

          TYPE POINT

        GROUP 'default'

        PROJECTION

            'init=epsg:32633'

        END

        STATUS ON

        SIZEUNITS PIXELS

        DATA 'sve1milj_32633/tx_riks'

        CLASSITEM KKOD

          CLASS

                   NAME "TextLake5"

                   EXPRESSION /87|86/  

                   LABEL

                             EXPRESSION ([TJUST] = 7)

                             SIZE 8

                             FONT 'sc' 

                             TYPE truetype

                             POSITION ul

                        ANGLE [TRIKT]

                             COLOR 0 0 0

                        TEXT '[TEXT]'

                   END

                   LABEL

                             EXPRESSION ([TJUST] = 8)

                             SIZE 8

                             FONT 'sc' 

                             TYPE truetype

                             POSITION uc

                        ANGLE [TRIKT]

                             COLOR 0 0 0

                        TEXT "[TEXT]"

                   END

                   LABEL

                             EXPRESSION ([TJUST] = 9)

                             SIZE 8

                             FONT 'sc' 

                             TYPE truetype

                             POSITION ur

                        ANGLE [TRIKT]

                             COLOR 0 0 0

                        TEXT "[TEXT]"

                   END

                   LABEL

                             EXPRESSION ([TJUST] = 4)

                             SIZE 8

                             FONT 'sc' 

                             TYPE truetype

                             POSITION cl

                        ANGLE [TRIKT]

                             COLOR 0 0 0

                        TEXT "[TEXT]"

                   END

                   LABEL

                             EXPRESSION ([TJUST] = 5)

                             SIZE 8

                             FONT 'sc' 

                             TYPE truetype

                             POSITION cc

                        ANGLE [TRIKT]

                             COLOR 0 0 0

                        TEXT "[TEXT]"

                   END

                   LABEL

                             EXPRESSION ([TJUST] = 6)

 

... and 5 more expressions in the same way.

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130912/063d7038/attachment-0001.html>


More information about the mapserver-users mailing list