wiki:TaggingPresets

Version 30 (modified by anonymous, 14 years ago) ( diff )

--

Tagging Presets

JOSM supports distributed tagging presets. This is a XML config file that describes a GUI for entering tags (or properties, annotations, sometimes called map features). The XML files can be placed anywhere in the web or at the users local file system. Presets can be added by the users at a central page Presets.

Setup

Every user can choose to add any url (or filename) into his preferences. An example URL is included in JOSM SVN.

No image "josm-preferences1.png" attached to TaggingPresets

After the sources are specified (and after a restart), the tagging presets can be selected from the main menu.

Example

Here is an example of how it looks like:

And this is the code that created the example :

<presets xmlns="http://josm.openstreetmap.de/tagging-preset-1.0">
  <item name="Highway">
    <label text="Inserting a highway in UK" />

    <text key="name" text="Highway (e.g. M3)" />
    <combo key="highway" text="Type" values="major,minor" delete_if_empty="true" />

    <!-- Highways are usually oneway -->
    <check key="oneway" text="Oneway" default="on" />

    <!-- Always setting class=highway -->
    <key key="class" value="highway" />
  </item>
</presets>

XML Format description

The tagging preset description is in a very simple XML format.

Tags

The document prolog:

<presets>
Has to be the main tag of the file. Supports following attributes
  • xmlns="http://josm.openstreetmap.de/tagging-preset-1.0"
  • author - the name of the author
  • version - a version of the file
  • description (i18n) - description what the file contains
  • shortdescription (i18n) - short overview description
  • link (i18n) - web link to further details

Comments:

<!-- this is an example comment -->
The document can contain embedded comments.

Menu creation:

<group>
Used to group items in sub menus. name is required, icon is optional attribute.
<item>
Every item is one annotation set to select from. name is required, icon is optional attribute.
<separator>
Insert a line separator into the menu.

Create instructions for the user:

<label>
Labels are static texts for display. text is a required attribute.
<optional>
Used to group some optional elements of an item. Equivalent to <label text="Optional Attributes:"/>
<space>
Add some space in the preset display.
<link>
Specify web link for this feature. href is required.

Attribute entry and selection dialog boxes:

<text>
A text edit field to enter any arbitrary string from the user. key is mandatory, text and default is optional
<combo>
Displays a multiple choice combo box. key and values are mandatory and text, default and readonly is optional. If readonly is not set, combo boxes can be edited as if they were text fields (additional to the drop down menu). Readonly combo boxes can only contain one of the specified values.
<check>
A checkbox which the user can only select or deselect. The key attribute is mandatory. text and default is optional.

Set a key value pair:

<key>
This tag will always set a key to a specific value. key is required and if value is present, the key will be set. If value attribute is ommited, the key is removed.

Attributes

The attributes of the tags have the following meaning:

name="a_name"
Specify a name for an item. This name will be used in the GUI to display the tagging preset.
name_context="context"
Translation context for name attribute to separate equals words with different meaning (not required for in-file translations).
type="data_type"
When specified, only objects of the given type will be changed at all by this tagging preset. Can be "node", "relation", "way", "closedway" or any comma separated combination of them.
icon="iconname"
A name of an icon that is within any classpath in the subdirectory of /images/symbols. You can load plugin-jar's to provide those images as well. The image will be used as icon to display in the selection list and when adding the preset to the toolbar. The icon should be quadratic in size.
key="some_key"
This specifies the property key that will be modified by the item.
text="Any text"
The description, that will be displayed before (after in case of <check>) the gui element.
text_context="context"
Translation context for text attribute to separate equals words with different meaning (not required for in-file translations).
default="default_value"
The default value for the item. If not specified, the current value of the key is chosen as default (if applicable).
delete_if_empty="true"
If the text (or combo) box is left empty, the key is removed instead inserting an key with empty value. Default is "false".
values="entry1,entry2,entry3"
A comma separated list of entries (for the combo box). It is not possible to specify an entry that contain a comma.
values_context="context"
Translation context for name attribute to separate equals words with different meaning (not required for in-file translations).
display_values="Entry1,Entry2,Entry3"
A comma separated list of entries that is displayed to the user. Must be the same number of entries as values and readonly must be true or not specified.
value="foobar"
Specify a value to be entered in the <key> tag.
value_on="foobar"
Specify the true value to be entered in the <key> tag (default is "yes").
value_off="foobar"
Specify the false value to be entered in the <key> tag (default is "no").
focus="true"
The item gets the focus when the dialog is activated. Does only work for text fields like <text> and <combo>.
readonly="true"
The combo box is readonly, which means, the user can only select an item in the list.
use_last_as_default="true"
For combo boxes or text fields the last value is used as default.

To support translations, all textual elements may be used in translated form. E.g. "de.name" would represent the name in case German language support is loaded.

Icon handling

There are 3 different ways to source icons:

  • Icons distributed with JOSM can be entered directly with the path (relative to JOSM's internal image directory). Hunt through this page for the names of existing icons.
  • New icons can be directly referenced using a http-link. These are downloaded and cached internally.
  • Since JOSM version 2289 Zip-Files are supported.
    • The zip file must contain at least one file with extension xml.
    • Icon names and path are relative to the topmost zip directory.
    • If there are multiple XML files, a file with "preset" in the name is preferred (to allow packaging styles and presets in one archive).

Relation presets

As of 14 Sept 2010 (version 3514) the use of presets for the type relation is perhaps a little unwieldy. This is how you apply a relation preset once you have created it:

  • use the "Create a new relation" button to start a new relation.
  • enter the "name" of the relation as a key/value pair. Close the edit window with the "OK" button. This skeletal relation will now act as a target for the preset to be applied.
  • highlite the new skeletal relation in the relation list by clicking on it. It will be found at the top of the realtion list.
  • click on the "select the relation objects" button, noting there are zero objects in the relation so far.
  • now apply your relation preset. All the other fields in the relation will be applied. It is now ready for use.

Existing relations can be altered by selecting all objects in the relation and then applying the preset. Only the relation is altered - the key/value pairs in the ways and nodes are not touched.

Attachments (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.