I am using MapServer's RunTime Substitution. They are a great feature.

In my case, I have layer setup pointing at a PostGIS table. This layer is exposed via WMS. I allow an optional query string variable in GetMap Requests (handled via Runtime Substitution) that ultimately is used in the Data SQL Query

    "health"  "[a-zA-Z0-9,_]*$"
    "default_health" "'Good','Fair','Poor','Unknown'"

DATA "geom FROM (select * from foo where health IN (%health%)) as q using unique id using srid=4326"

In the above example, if no health variable is passed in via Runtime Substitution - I have a default that just builds an IN clause that encompasses all possible health values. And this works. My problem is I have other layers setup like this. But these layers have many, many possible values. So I end up having these monstrous IN clauses.

I am hoping someone can suggest a way that if a variable is not passed in via Runtime Substitution - I totally omit the where clause in my DATA line. Is there some way to do a conditional IF in the MAPFILE?

Your Answer

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

Browse other questions tagged or ask your own question.