3

I am trying to port my code from MapServer 5 (Oracle) to MapServer 7 (PostgreSQL), but I am encountering a issue when trying to apply arithmetic expressions in the style class. So previously in MapServer 5 I would have something like:

DATA "geom from (select pk, geom, size from sizes_of_thing) USING srid 3788 version 11g"
CLASS
    MAXSCALEDENOM 5001
    STYLE
        COLOR [size*2]

Which worked perfectly fine: But if I convert it to MapServer 7 and PostgreSQL like:

DATA "geom from (select pk, geom, size from sizes_of_thing sot) USING unique pk USING srid=3788"
CLASS
    STYLE
        COLOR [size*2]

Throws an error such as:

msPostGISLayerWhichShapes(): Error (ERROR:  column "size*2" does not exist

By any chance are these expressions not supported anymore in MapServer 7/PostGIS or am I doing something wrong?

What I have tried so far is to write something like

SIZE [size]*2
SIZE ([size]*2)

create an expression like:

EXPRESSION ("size2" "[size]*2")

And use it in something like:

SIZE [size2]

create a validation variable such as:

VALIDATION
"size2" '[size]*2'

and then

SIZE [size2]

But seems like none of them work.

1 Answer 1

2

It is documented https://www.mapserver.org/mapfile/style.html that mathematical expressions are not supported for angle:

If you have an attribute that specifies angles in a clockwise direction (compass direction), you have to adjust the angle attribute values before they reach MapServer (360-ANGLE), as it is not possible to use a mathematical expression for ANGLE.

Maybe the same applies to other style items as well.

In that document page the only place where expression is mentioned is in GEOMTRANSFORM [bbox|centroid|end|labelcenter|labelpnt|labelpoly|start|vertices|<expression>]

Also in https://www.mapserver.org/mapfile/expressions.html

As of version 6.0, expressions are used in four places:

  • In LAYER FILTER to specify the features of the dataset that are to be included in the layer.

  • In CLASS EXPRESSION to specify to which features of the dataset the CLASS applies to.

  • In CLASS TEXT to specify text for labeling features.

  • In STYLE GEOMTRANSFORM.

It seems that current MapServer version does not support your use case for expressions. You may write mail to mapserver-users mailing list and ask for confirmation.

1
  • I am afraid that may be the case. I just posted a question in the mailing list and will update the ticket with the result. But many thanks for the help!
    – Andi Domi
    Jun 16 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.