[mapserver-dev] Default values for bindings?
woodbri at swoodbridge.com
Sun Apr 22 16:14:28 EDT 2012
Do we have the ability to set default values for a bound attribute
column? Is this something we should consider, if not?
What is the behavior if a bound attribute is NULL and the value is to be
used for example as:
It seems to me that there are two desirable options that we might want
* set a default value maybe like: '[col:=default]'
In this case, the attribute would take on the value of default is the
bound value was null. An alternative to this syntax would be to add a
SQL function to our expression parser like:
This has the advantage that you could do something like this:
TEXT (coalesce(coalesce('[col_a]', '[col_b]'), 'default'))
While this can be done in SQL, it is not currently possible to do this
with the shapefiles, except possibly using the OGR driver.
* set a default action maybe like: '[col|=skip]'
In this case, of "col" is null the we would skip the current MAPFILE
block we are in. This might mean we need to track skip failures via a
return code to determine if the higher level block also needs to skip.
But using a mix of these two, you could "default" ANGLE to 0.0 for a
LABEL or SYMBOL but "skip" it if the TEXT string or SYMBOL name are
NULL. I think I can achieve this with a CLASS expression that is a NOP
or a FILTER (! (expression)) but it seems to be more intuitive to
control this closer to the use.
My use case for presenting this idea is that I am trying to assign
SYMBOL name and symbol SIZE to Tiger POINTLM data. I have currently
worked around this by modifying the code that adds the attribute columns
to set reasonable defaults. It would have been much easier to only add
values to the records I care about and setting defaults or actions like
above. What made me think about this is the fact that we can set default
values for substitution strings using METADATA.
Anyway some food for thought.
More information about the mapserver-dev