2

I'm trying MapServer's run-time substitution to dynamically set my Mapfile's CLASS EXPRESSION values.

The expressions take the form of:

CLASS
    EXPRESSION (([my_attr_col] >= num_1) && ([my_attr_col] < num_2))
    ...
END

When manually setting the expression values (not using run-time substitution) it works. (And only seems to do so when I use no quotes at all.)

When trying to pass the expression in dynamically with run-time substitution, then I add a VALIDATION block:

VALIDATION
    'my_attr'    '^[\s\S]*$'
END

and I modify the CLASS EXPRESSIONs along these lines:

CLASS
    EXPRESSION '%my_attr%'
    ...
END

and I then append and send the information via the query URL.

However, I get this error:

msEvalExpression(): General error message. Cannot evaluate expression, no item index defined.

I've tried many permutations of quotes and regex filtering but I can't seem to figure out what would be accepted by MapServer.

4
  • 1
    Have you already tried to validate with '.*'? And how does your request look &my_attr=.... Does it contain "&&" like in your example of the hand written mapfile expression?
    – user30184
    Commented May 2, 2016 at 6:59
  • Hi, yes, I'm presently trying with '.*' The request looks like this: http://url_address/cgi-bin/mapserv.fcgi?my_attr=((%5Bmy_attr_col%5D%20%3E=%20num_1)%20&&%20(%5Bmy_attr_col%5D%20%3C%20num_2))&etc...
    – songololo
    Commented May 2, 2016 at 15:20
  • 1
    I would test with much more simple variable first. Like EXPRESSION ([my_attr_col] >%test%) and then having &test=1 in the request. When you get it to work you know that the variable gets transferred into EXPRESSION and the rest is making odd characters to pass the GET request, URL-encoding, and validation.
    – user30184
    Commented May 2, 2016 at 16:04
  • Yeah that works much better. I've removed anything 'non-ordinary' from the URL query and now it works fine.
    – songololo
    Commented May 2, 2016 at 16:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.