[mapserver-dev] Default values for bindings?

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Mon Apr 23 14:04:38 EDT 2012

Doesn't seem like a very strong use case for this IMHO. You'd need to also know when to apply a default, null isn't necessarily a
reasonable choice for all data sources.


-----Original Message-----
From: mapserver-dev-bounces at lists.osgeo.org [mailto:mapserver-dev-bounces at lists.osgeo.org] On Behalf Of Stephen Woodbridge
Sent: Sunday, April 22, 2012 3:14 PM
To: mapserver-dev
Subject: [mapserver-dev] Default values for bindings?

Hi Devs,

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:

TEXT '[col]'
ANGLE '[col]'
SYMBOL '[col]'
SIZE '[col]'
WIDTH '[col]'

It seems to me that there are two desirable options that we might want to support:

* 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.

-Steve W
mapserver-dev mailing list
mapserver-dev at lists.osgeo.org

More information about the mapserver-dev mailing list