[josm-dev] Customizable name formatter

Paul Hartmann phaaurlt at googlemail.com
Wed Jul 20 11:48:40 BST 2011


On 07/19/2011 09:40 PM, Jiri Klement wrote:
> Hi,
> 
> I think it would be useful to make formating of primitives
> configurable (ie modify DefaultNameFormater class). For example we use
> special tagging for hiking routes in Czech Republic and it would be
> nice to have these routes displayed differently in relation list view.
> It's possible to write plugin for it (see #6535), but it seems like
> overkill in this case.
> 
> Idea is to have name templates in tagging preset file that will be
> used to create primitive display name. Templates are inspired by
> mkgmap rules, syntax proposal:
> 
> "House {addr:housename}" - Use string "House " and value of addr:housename tag
> 
> "?{ 'House number {addr:housenumber} at {addr:street}' | 'House number
> {addr:housenumber}'  }" - use first variant if condition is satisfied
> (that is both addr:housenumber and addr:street tags exists), second
> variant otherwise.
> 
> "?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | admin_level
> = 6 'NUTS 3' |  '{admin_level}'}  - as above, but condition is
> explicitly defined using search expression.

Could be useful for labelling objects on the map as well. Like #6122,
but better.

> Name templates can be distributed as part of tagging preset file.
> There is already code that lookup tagging preset for primitive that is
> used to show presets in Properties dialog. Also there is already
> infrastructure for sharing presets. It seems to me like practical
> solution though it's a bit unclean to mix presets and name templates
> together.
> 
> Other possibility is use separated files, then searching for
> appropriate template for primitive would be best done by search/filter
> expression. Or this is not suitable for core at all and it should be
> rather provided via plugin.
> 
> It might useful to make it possible to define custom icon for primitive as well.

We already have the situation, that certain presets are more useful in
combination with a map style that covers the same topic. So on the long
run we could abandon stand-alone presets & styles and have "packages" or
"extensions" instead.

These would contain one or more presets, map styles, name formatters, etc.

Paul



More information about the josm-dev mailing list