Hi,

I had the same issue, but as an added complication the number of classes could change dynamically based on users adding and editing data. I solved this by intercepting any web requests to this particular layer and using MapScript to build the classes on-the-fly, then passing the Layer object to generate the image.

    for c in classes:
        clsObj = mapscript.fromstring(c)
        layer.classes.append(clsObj)

...


    req = mapscript.OWSRequest()

    req.loadParamsFromURL(querystring)

    try:
        dispatch_status = mymap.OWSDispatch(req)

#strip all the headers from the output as we add these through wsgi server

        content_type = mapscript.msIO_stripStdoutBufferContentType()
        mapscript.msIO_stripStdoutBufferContentHeaders()

        resp = mapscript.msIO_getStdoutBufferBytes()
    except Exception as ex:
        logging.error(ex)
        logging.error(querystring)
        resp, content_type = str(ex), "text/plain"

    return resp, content_type

If you have static, or rarely changing data, then it would be simpler to just use a script to build the classes once and save them as an INCLUDE to your MAP file. Python and Jinja2 (a templating library for Python) are handy for this.

Seth

On 30/03/2016 19:00, Lime, Steve D (MNIT) wrote:
Won't work. Bobb is trying to use feature-level properties at the 
legend/layer-level. Can't be done... Steve

________________________________________
From: mapserver-users [mapserver-users-boun...@lists.osgeo.org] on behalf of 
steve.tout...@inspq.qc.ca [steve.tout...@inspq.qc.ca]
Sent: Wednesday, March 30, 2016 10:32 AM
To: Basques, Bob (CI-StPaul)
Cc: mapserver-users@lists.osgeo.org; mapserver-users
Subject: [mapserver-users] RE  Mapfile, EXPRESSION for CLASS >> NAME

Perhaps you can use CLASS TITLE instead of NAME



"Basques, Bob (CI-StPaul)" <bob.basq...@ci.stpaul.mn.us>@lists.osgeo.org
Envoyé par : "mapserver-users" <mapserver-users-boun...@lists.osgeo.org>

2016-03-25 16:44


A
         "mapserver-users@lists.osgeo.org" <mapserver-users@lists.osgeo.org>
cc

Objet
         [mapserver-users] Mapfile, EXPRESSION for CLASS >> NAME









All,

I think I’m trying to be too clever . . .

I have this MAPFILE chunk:

CLASS
COLOR 0 255 0
OUTLINECOLOR 0 0 0
       SIZE 10
       SYMBOL 'circle'
NAME '[FOLDERTYPE]'
TEXT '[FOLDERTYPE]'
       LABEL
         FORCE TRUE
         COLOR 255 255 0
         OUTLINECOLOR 0 0 0
         POSITION ur
TYPE TRUETYPE
FONT 'arial-bold'
SIZE 11
       END
     END


and I’m trying to use an Expression for the Label in the Legend graphic.  The 
FOLDERTYPE and is the two later code for map labels, while the FOLDERDESC is 
the long pretty name for the Legend.



Question, is it possible??  Ideas??  Before you say a separate class for each 
one, there are 120 FOLDERTYPEs in all, that would be a big, and hard to 
maintain Mapfile.

thanks

bobb



_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to