Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow LABEL POSITION, MINSIZE and MAXSIZE to be Set Dynamically #3612

Closed
mapserver-bot opened this Issue Apr 3, 2012 · 6 comments

Comments

Projects
None yet
4 participants

Reporter: DonaldKerr
Date: 2010/11/21 - 21:34
Trac URL: http://trac.osgeo.org/mapserver/ticket/3612
Allow LABEL POSITION, MINSIZE and MAXSIZE to be set dynamically e.g. by determining the position from a database record.

I have the following CLASS definition in a map file. In order to set LABEL POSITIONs dynamically, I have to have 9 similar classes to cover the 9 labelling positions ll,cl,ul, etc., as I cannot set the value directly from the database.


LABELITEM textstring

CLASS
EXPRESSION (([featurecode] = 10020) And ("[anchorpositiontxt]"="ll"))
LABEL
TYPE truetype
FONT [font]
SIZE [height]
MAXSIZE 21
MINSIZE 4
POSITION ll
#COLOR 0 0 0
COLOR [oscolor]
ANTIALIAS TRUE
ANGLE [orientation]
FORCE TRUE
END # LABEL

END # CLASS

With 30 different classes, each being repeated 9 times, it would be much easier if I could set the POSITION dynamically as with the following desired CLASS definition:


LABELITEM textstring

CLASS
EXPRESSION ([featurecode] = 10020)
LABEL
TYPE truetype
FONT [font]
SIZE [height]
MAXSIZE 21
MINSIZE 4
POSITION [anchorpositiontxt]
#COLOR 0 0 0
COLOR [oscolor]
ANTIALIAS TRUE
ANGLE [orientation]
FORCE TRUE
END # LABEL

END # CLASS

Same goes for MINHEIGHT and MAXHEIGHT. If these could be set along the lines of [height]*3 or [height]/3 or even just another database field, it would allow for more dynamic map configuration and less map file hard-coding.

Author: erigus
Date: 2010/11/28 - 21:23
Attribute binding for label position would be very useful for me too. Attaching a patch I've used previously.

Author: sdlime
Date: 2011/03/04 - 06:43
Added label position binding to trunk in 3c9d9b4 (r11063). The minsize/maxsize stuff doesn't seem as valuable. Maybe in a 6.x release when there's a bit more time.

Steve

Author: DonaldKerr
Date: 2011/03/04 - 21:24
Excellent work, thank you. Granted, minsize/maxsize binding may not be as useful but it would certainly benefit my purposes. If it's relatively easy to do the I'd certainly like to see it sooner rather than later. Thanks for your work again which is greatly appreciated.

Donald

@sdlime sdlime was assigned Apr 5, 2012

Owner

tbonfort commented May 24, 2012

de-milestoning from 6.2. @DonaldKerr if you can provide a patch for minsize/maxsize bindings it will probably speed things up

Thomas,

Pretty much everything I require is already in so I can live without MINSIZE and MAXSIZE being set dynamically. I'm currently running with the following which works for me:

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"

LABELITEM textstring

# Building
CLASS
    EXPRESSION ([featurecode] = 10020)
    LABEL
        TYPE truetype
        FONT [font]
        SIZE [height]
        MAXSIZE 21
        MINSIZE 4
        POSITION [anchorpositiontxt]
        COLOR [oscolor]
        ANTIALIAS TRUE
        ANGLE [orientation]
        FORCE TRUE
    END # LABEL
END # CLASS

Label position and color were the biggies for me and they are catered for currently within Mapserver with a bit of help from Postgres SQL as you can see.

My knowledge of C is minimal so a patch from me would be pretty difficult!

Regards,

Donald

@tbonfort tbonfort closed this May 24, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment