[mapserver-dev] Default values for bindings?

Brent Fraser bfraser at geoanalytic.com
Mon Apr 23 15:49:57 EDT 2012


Interesting.  I ran into a similar problem just the other day.  All of 
the values I wanted substituted were null, but the missing [label_font] 
value was the only one that caused an error message.  Personally I think 
mapserver should have just used the first one in the font file as a 
default (generate error or skip the feature? if no font file etc)...

     CLASS
         STYLE # Polygon Fill
             SYMBOL       [polyfill_symbol]
             COLOR        [polyfill_fillcolor]
             ANGLE        [polyfill_angle]
             SIZE         [polyfill_hatchgap]  # e.g Hatching gap
             WIDTH         1 # [polyfill_hatchthick]  # Hatching line 
thickness (column binding doesn't seem to work)
#            OPACITY      50 # [attribute]  # warning: there is no 
OPACITY for LABEL so don't bother.
         END
         STYLE # Polygon Outline
             SYMBOL       [geom_symbol]
             OUTLINECOLOR [geom_outcolor]
             SIZE         [geom_width]    # for "simple" (?) symbols
             WIDTH        [geom_width]    # for complex symbols
         END # Style
         TEXT             ([gid])
         LABEL
             TYPE         TRUETYPE
             FONT         [label_font]
             ANTIALIAS    TRUE
             COLOR        [label_fillcolor]
             OUTLINECOLOR [label_outcolor]
             BUFFER       1
             POSITION     cc        # [ul|uc|ur|cl|cc|cr|ll|lc|lr|auto]
             PARTIALS     TRUE
             SIZE         [label_height]
         END  # LABEL

     END # class


Best Regards,
Brent Fraser


On 4/23/2012 12:04 PM, Lime, Steve D (DNR) wrote:
> 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.
>
> Steve
>
> -----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]'
> etc.
>
> 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:
>
> (coalesce('[col]','default')
>
> 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
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>



More information about the mapserver-dev mailing list