wiki:De:TaggingPresets

Version 32 (modified by stoecker, 12 months ago) ( diff )

Typo

XML-Anteil unvollständig übersetzt

Wenn Sie die Installationsschritte für Voreinstellungen lernen wollen, sehen Sie sich die source:trunk/resources/images/dialogs/propertiesdialog.svg Objektvorlagen-Übersicht (en) in den source:trunk/resources/images/preference.svg Einstellungen an
Wenn Sie Objektvorlagen verwenden wollen oder eine vollständige Referenz der Vorlagen benötigen, siehe Objektvorlagen

Objektvorlagen

JOSM unterstützt verteilte Objektvorlagen. Dies ist eine XML-Konfigurationsdatei, die eine grafische Benutzeroberfläche für die Eingabe von Merkmalen (oder Eigenschaften, Anmerkungen, manchmal auch Kartenmerkmale genannt) beschreibt.

Die Voreinstellungen können an beliebiger Stelle im Web oder im lokalen Dateisystem des Benutzers abgelegt werden. JOSM kann für die Verwendung benutzerdefinierter lokaler oder entfernter Voreinstellungen konfiguriert werden.

Eine neue Objektvorlage erstellen

Die Beschreibung einer Objektvorlage geschieht in einem einfachen XML Format. Details siehe unten.

Siehe defaultpresets.xml als Beispiel, welches die meisten der unten aufgelisteten Möglichkeiten abdeckt.

Beispiel:

<?xml version="1.0" encoding="UTF-8"?>
<presets xmlns="http://josm.openstreetmap.de/tagging-preset-1.0">
  <item name="Oneway highway" type="way">
    <label text="Inserting a unidirectional highway" />

    <combo key="highway" text="Type" values="trunk,motorway" />
    <text key="name" text="Name (e.g. Angel Road)" />
    <text key="ref" text="Ref (e.g. A406)" />

    <!-- Dies ist eine Vorlage für richtungsgebundene Fahrbahnen,
         sodass "oneway" standardmaäßig "yes" ist -->
    <check key="oneway" text="Oneway" default="on" />

    <!-- Immer Asphlat als Oberfläche kennzeichnen -->
    <key key="surface" value="asphalt" />
  </item>
</presets>

De:TaggingPresets-preset.xml, De:TaggingPresets.zip


XML Format Beschreibung

Das vollständige XSD-Schema ist im URI-Namensraum (http://josm.openstreetmap.de/tagging-preset-1.0) sowie im Quellverzeichnis verfügbar.

Merkmale

Anfang des Dokuments

<presets>
Muss das Hauptmerkmal der Datei sein. Unterstützt folgende Attribute
  • xmlns="http://josm.openstreetmap.de/tagging-preset-1.0"
  • author - Der Name des Autors der Vorlage
  • version - die Versionsnummer der Datei. Für die automatische Versionsanpassung von Vorlagen, die in diesem Wiki verwaltet werden, müssen Sie zwei interne Variablen verwenden: [[revision]] (die letzte Versionsnummer der Wikiseite) und [[date]] (das Datum der letzten Bearbeitung), z.B. version="1.[[revision]]_[[date]]".
  • description (i18n) - Beschreibung, was die Datei enthält
  • shortdescription (i18n) - sehr kurze Übersichtsbeschreibung, z.B. der "Name" der Vorlage
  • link (i18n) - Webseite für weitere Details (optional)
  • icon - Bild für die gesamte Vorlage
  • baselanguage - wenn die Basissprache nicht Englisch ist, geben Sie diese hier an (die Verwendung von nicht englischen Vorlagen-Texten wird die automatische Übersetzung verhindern, sobald sie implementiert ist (#11392))

(i18n) bedeutet, dass die Werte auch lokalisiert werden können (z. B. de.description).


Kommentare

<!-- Dies ist ein Beispielkommentar -->
Das Dokument kann eingebettete Kommentare enthalten.


Erstellung von Vorlagengruppen

<group>
Wird verwendet, um Elemente in Untermenüs zu gruppieren. name="" ist erforderlich, icon="" ist ein optionales Attribut.
<item>
Jedes Element ist ein Anmerkungssatz, aus dem ausgewählt werden kann. name="" ist erforderlich, type="" und preset_name_label="" werden empfohlen, icon="", name_template="" und match_expression="" sind optionale Attribute.
<separator />
Einen Zeilentrenner in das Menü einfügen.


Gestaltung des Vorlagenfensters

<label />
Beschriftungen sind statische Texte für die Anzeige. text="" ist ein erforderliches Attribut, icon="" und icon_size="" sind optional.
<space />
Etwas Freiraum (z.B. eine Leerzeile) einfügen.
<optional>
Dient zur Gruppierung einiger optionaler Elemente eines Eintrags. Das Attribut text="" ist optional. Wird es ohne text="" verwendet, entspricht dies <space /><label text="Optionale Merkmale:" /><space />
<item_separator />
Eine horizontale Trennlinie zwischen den Einträgen einfügen.
<link />
Einen Weblink für diese Funktion oder für etwas anderes Nützliches angeben. Entweder ist das Attribut wiki="" (das auf eine OSM-Wiki-Seite verweist, z.B. "Tag:leisure=park") oder das Attribut href="" (vollständige URL) sind erforderlich. Wenn das Attribut wiki="" verwendet wird, verweist der Link auf die Wikiseite der Sprache, auf die JOSM eingestellt ist. Existiert diese nicht, wird die englische Seite angezeigt. Wenn wiki="" verwendet wird, darf die OSM-Wiki-Seite nicht URL-kodiert sein, z.B. darf sie nicht "Tag:leisure%3Dpark" heißen, sondern muss stattdessen "Tag:leisure=park" lauten.
<checkgroup>
Um Ankreuzfelder zu gruppieren. Das Attribut columns="" ist erforderlich.
<roles>
Dies wird zum Gruppieren von <role/> benötigt und fügt die Überschrift („Verfügbare Rollen Rolle Anzahl Elemente“) zu der Tabelle hinzu, die durch mehrere Angaben von <role/> erzeugt wird.
<role />
Zur Angabe möglicher Rollen von Mitgliedern in Relationen. Das Attribut key="" ist erforderlich, text="", requisite="", count="", type="", member_expression="" und regexp="" sind optional.
<preset_link />
To specify possible roles of members in relations. The key="" attribute is required, text="", requisite="", count="", type="", member_expression="" and regexp="" are optional.
<preset_link />
Fügt einen Link zu einer anderen Vorlage mit einer Beschriftung darüber hinzu. Das Attribut preset_name="" ist erforderlich, text="" zum Überschreiben der Beschriftung (Standard ist „Bearbeite auch ...“) und text_context="" sind optional. Eine Folge von <preset_link /> ohne text="" oder einem identischen text="" werden unter einer Beschriftung gruppiert.
Achtung bei Vorlagen mit identischem name="", da es nicht vorhersehbar ist, zu welcher Vorlage der Link führt, siehe #12716.
Das gleiche Merkmale in beiden Vorlagen zu haben, funktioniert nicht, siehe #18992.
Die Verwendung von <preset_link /> in Vorlagen, die über den Relationseditor (en) geöffnet werden, führt zu Fehlern, siehe #20044.


Ein festes Merkmalspaar festlegen

<key />
Mit diesem Element wird ein Merkmal immer auf einen bestimmten Wert gesetzt. key="" ist erforderlich und wenn value="" vorhanden ist, wird das Merkmal gesetzt. Wenn das Attribut value="" weggelassen wird, wird das Merkmal entfernt. Das Attribut match="" ist optional.


Attribute entry and selection dialog boxes

<text />
A text edit field to enter any arbitrary string from the user. key="" is mandatory, text="", default="", use_last_as_default="", auto_increment="", length="", alternative_autocomplete_keys="", match="", icon="" and icon_size="" (both since r17605) are optional.
<combo />
Displays a multiple choice combo box. key="" and values="" are mandatory, text="", default="", editable="", delimiter="", values_from="", display_values="", short_descriptions="", use_last_as_default="", values_searchable="", length="", values_no_i18n="", values_sort="", match="", icon="" and icon_size="" (both since r17605) are optional.
If editable="" is true (default), combo boxes can be edited as if they were text fields (additional to the drop down menu). Non editable combo boxes can only contain one of the specified values.
If the key is colour or colour:* or *:colour, a color preview and color picker is added on the right (see #8352).
<multiselect />
Displays a list from which zero or more items can be chosen. key="" and values="" are mandatory, and text="", default="", delimiter="", values_from="", rows="", display_values="", short_descriptions="", use_last_as_default="", values_searchable="", values_no_i18n="", values_sort="", match="", icon="" and icon_size="" (both since r17605) are optional. The selected values will be concatenated with the specified delimiter (default: semicolon, ;) and written to the tag value. If a tag value has already been set when the preset dialog is opened, the <multiselect /> will attempt to mark the appropriate items in the list as select. If the tag value cannot be represented by a combination of choices in the list, then the list will be disabled so that the user cannot accidentally overwrite a custom value. In contrast to the <combo /> element, the <multiselect /> expects the list of values, descriptions etc. to use the specified delimiter, i.e. by default you will have to use a semicolon. You can specify delimiter="," but then a comma will also be used in the tag value.
<list_entry />
Used in <combo> and <multiselect>. More information see short_descriptions="", below. The attributes are value="", display_value="", short_description="", icon="" and icon_size="".
<check />
A checkbox which the user can select, deselect or set as unset. The key="" attribute is mandatory. text="", default="", match="", value_on="" , value_off="", disable_off="", icon="" and icon_size="" (both since r15437) are optional.


Templates

<chunk>
To define a template of elements for later (repeated) use. The id="" attribute is mandatory.
<reference>
To include an earlier defined template. The ref="" attribute is mandatory.


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 work with this tagging preset. Can be "node", "way", "closedway", "multipolygon", "relation" or any comma separated combination of them. Note that "multipolygon" is not included in "relation", so if the preset should apply for multipolygons and other relation types, you need to specify both: "multipolygon,relation". Also used in the <role> tag to specify which object types are allowed for a specific relation member.
icon="iconname"
A name or link to an icon. The image will be used as icon to display in the selection list and when adding the preset to the toolbar. Icons can also be used in <item>, <label />, plus all attribute entry and selection dialog boxes (since r17605, before it was only <list_entry /> and <check />). It is placed in front of <text /> The icon should be quadratic in size. See Icon handling how icons can be specified.
icon_size="a number"
The maximal size of an icon in px. If no value is given, default is 16 for <label /> and the default icon size for <list_entry /> (in <combo> and <multiselect>).
key="some_key"
This specifies the property key that will be modified by the item. In case of <role> it is the role name used in a relation.
text="Any text"
The description, that will be displayed before the gui element, (in case of <check /> after the gui element and the optional icon). Also used for <label> and <optional>.
text_context="context"
Translation context for text attribute to separate equals words with different meaning (not required for in-file translations).
default="default_value"
An explicitly declared default value for the item. This value is only applied through a preset when the object the preset is applied to has zero keys. If no value for default is specified, no value is set to the key. Used in <check />, <text />, <combo /> and <multiselect />. For <check /> only the values "on" and "off" are valid.
values="entry1,entry2,entry3"
A list of entries (for the <combo /> box and <multiselect />). The list has to be separated by commas (for the combo box) or by the specified delimiter (for the multiselect). If a value contains the delimiter, the delimiter may be escaped with a backslash. If a value contains a backslash, it must also be escaped with a backslash.
values_from="JAVA code"
To use instead of values="" if the list of values has to be obtained with a Java method of this form: public static String[] getValues(); The value must be: "full.package.name.ClassName#methodName".
values_no_i18n="true|false"
Disables internationalisation for values to avoid mistakes, see #11696. Default is "false". Used in <combo /> and <multiselect />. (Useful e.g. for keys opening hours or brand.) Not needed with keys with only numbers as values like layer or level which are already excluded from translation.
values_sort="true|false"
Values of <combo /> and <multiselect /> are sorted alphabetic in every language. With this attribute you can disable the alphabetic sorting if the values should keep the given order, see #5509 and #11926. (In the JOSM internal preset this is used e.g. for the keys tracktype, direction, network, smoothness, visibility or trail_visibility.) Default is "true".
Users can globally disable sorting with the preference key taggingpreset.sortvalues.
values_context="context"
Translation context for values attribute to separate equals words with different meaning (not required for in-file translations).
display_values="Entry1,Entry2,Entry3"
A list of entries that is displayed to the user. Must be the same number and order of entries as values="" and editable="" must be "false" or not specified. For the delimiter character and escaping, see the remarks at values="". Used in <combo /> and <multiselect />.
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 of a checked <check /> (default is "yes").
value_off="foobar"
Specify the false value to be entered in the <key> tag of a unchecked <check /> (default is "no").
disable_off="true"
Whether the off value of a <check /> is disabled in the dialog, i.e., only unset or "yes" are provided.
editable="false"
The combo box is read only, which means that the user can only select an item in the list. Default is "true", which means, the user can add other values as text. (Feature was not working properly for a long time but should work again since r18221, see #6157.)
use_last_as_default="true|false|force"
For <combo />, <multiselect /> or <text /> fields the last used value is used as default. Using "force" enforces this behavior also for already tagged objects. Default is "false".
rows="count"
Specify the number of rows to display in <multiselect /> entry (if not set, it is auto determined by java or the look and feel and results in e.g. 8).
name_template="template", name_template_filter="search expression"
Custom name formatter for osm primitives matching this preset. See name template details below.
match="none|key|key!|keyvalue|keyvalue!"
Allows to change the matching process, i.e., determining whether the tags of an OSM object fit into this preset. If a preset fits then it is linked in the Tags/Membership dialog (en).
  • none: neutral, i.e., do not consider this item for matching
  • key: positive if key matches, neutral otherwise
  • key!: positive if key matches, negative otherwise
  • keyvalue: positive if key and value matches, neutral otherwise
  • keyvalue!: positive if key and value matches, negative otherwise
Note: For a match, at least one positive and no negative is required. Default is "keyvalue!" for <key> and "none" for <text />, <combo />, <multiselect /> and <check />.
match_expression="search expression"
additional criteria for matching primitives, specified in JOSM search (en) syntax. (since r17662)
Quotes (") need to be written as &quot;.
For instance, a preset with match_expression="foo=bar" requires OSM objects to have the tag foo=bar. You may want to use the match_expression="" to exclude certain OSM objects, e.g. when a more specific preset is present.
id="unique_identifier"
the unique identifier for this <chunk>
ref="unique_identifier"
the unique identifier of the (already defined) template to include
columns="a number"
the number of columns of grouped <check />
requisite="optional|required"
If a relation member is optional or required. Default is "optional".
count="a number"
How often can a role occur (if not given unlimited number is assumed)
member_expression="search expression"
an expression, in JOSM search (en) syntax, for objects of this role
Quotes (") need to be written as &quot;.
regexp="true"
set to "true" if the key of a role is a regular expression.
This allows variable roles e.g. <role key="level_-?\d+" text="Building level" regexp="true" requisite="optional" type="relation" /> allows the roles level_0, level_1,...
preset_name="exact_name"
The exact name of the preset to link to.
preset_name_label="false|true"
Whether to insert "[preset name]" label in dialog (defaults to "false" for backward-compatibility on external presets).
length="a number"
The length of a <text /> or <combo /> box (number of characters allowed).
alternative_autocomplete_keys="some_key(s)"
A comma separated list of alternative keys to use for auto completion of <text>.
auto_increment="-2,-1,+1,+2"
May contain a comma separated list of integer increments or decrements, e.g. "-2,-1,+1,+2". A button will be shown next to the <text /> field for each value, allowing the user to select auto-increment with the given stepping. Auto-increment only happens if the user selects it. There is also a button to deselect auto-increment. Default is no auto-increment. Mutually exclusive with use_last_as_default="".
delimiter="special character"
The character that separates values. In case of <combo /> the default is comma (,). In case of <multiselect /> the default is semicolon (;) and this will also be used to separate selected values in the tag. More information see <multiselect />, above.
short_descriptions="Entry1,Entry2,Entry3"
A delimiter-separated list of texts to be displayed below each display_value="". (Only if it is not possible to describe the entry in 2-3 words.) Instead of a comma separated list using values="", display_values="" and short_descriptions="", the following form is also supported:
<list_entry value="" display_value="" short_description="" icon="" icon_size="" />
values_searchable="true|false"
Whether to search in values="" and display_values="", respectively, value="" and display_value="" of <combo /> or <multiselect /> searching for presets.
value_template="template"
A template to generate the value automatically based on other tag values of the object. The same syntax as in name_template="" is used, see below. (since r17639)
For instance, "Bus {ref}: {from} → {to}" can be used to generate the name of a bus route relation.
Note: There are some minor problems with this attribute, see #20851 and #20861.


name_template and value_template details

Name templates can be used to define custom formatting for OSM primitives or GPX waypoints (for example in the Relations or Selection panels).

<?xml version="1.0" encoding="UTF-8"?>
<presets>
        <item name="Public transportation" type="relation"
                name_template="Bus({operator} {ref} ?{'{from} - {via} - {to}' | '{from} - {to}' | '{from}' | '{to}'})"
                name_template_filter="type=route route=bus">
        </item>
</presets>

Samples

Template Tags Result
House number {addr:housenumber} addr:housenumber=10 House number 10
?{ 'House number {addr:housenumber} at {addr:street}' | 'House number {addr:housenumber}' } addr:housenumber=10 House number 10
addr:housenumber=10 addr:street=Abbey road House number 10 at Abbey road
?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | admin_level = 6 'NUTS 3' | 'Admin level {admin_level}'} admin_level=4 NUTS 2
admin_level=5 Admin level 5
{admin_level} - {name} !{parent() type=boundary '?{'(part of {admin_level} - {name})' | ''}'} admin_level=6 name=Vysocina, member of relation admin_level=4 name=Jihovychod 6 - Vysocina (part of 4 - Jihovychod)
admin_level=2 name=Czech republic (no parents) 2 - Czech republic


Syntax
  • {tag} - insert the value of the tag.
  • ?{condition1 'value1' | condition2 'value2' | 'value3'} - use value1 if condition1 is satisfied, else use value2 if condition2 is satisfied, finally use value3 if no condition is satisfied. Condition can be either explicit - in JOSM search (en) syntax - or implicit: The value is used when all tags referenced inside exist.
  • !{search_expression 'template'} - search_expression is evaluated and first matching primitive is used as context for template. Useful for example to get tags of parent relation.
  • \ - use a backslash to escape special characters '{', '}', '?', '!'. E.g. What is this\? It is a {type}\!.


Available values

For formatting of OSM primitives, the value of any tag can be used. Use the tag {special:everything} to display all available tags, eg. on your gpx waypoints.

You can also use these virtual tags:

  • {special:everything} prints all available values, available for formatting of both primitives and waypoints.
  • {special:id} prints the ID of the osm primitive.
  • {special:localName} prints the localized name, that is the value of name:lang for your language if it is available, or the value of name if it is not.


Deprecated Attributes

The following attributes are deprecated and no longer supported by JOSM:

delete_if_empty="true"
was removed in r5155. You can simply remove this attribute if still used in your preset.
required="true"
replaced by match="" since r5155


Übersetzung

Um Übersetzungen zu unterstützen, können alle textlichen Elemente (name="", text="" and display_values="") auch übersetzt werden. (Z.B. "de.name" würde den deutschen Namen darstellen, wenn die deutsche Sprache in JOSM ausgewählt ist.) Im XML-Code der Objektvorlage muss der englische Begriff an erster Stelle stehen, bevor mögliche Übersetzungen hinzugefügt werden können.

Interne Vorlagen

Die Übersetzung für die interne Voreinstellung erfolgt auf Launchpad.

In der internen Vorlage werden alle name="", text="" und display_values="" über den oben genannten Dienst übersetzt, solange keine spezifische Übersetzung in der XML-Datei angegeben wurde. Wenn keine display_values="" angegeben werden, dann wird values="" als display_values="" behandelt und stattdessen übersetzt.

Wenn ein und dasselbe englische Wort in verschiedenen Kontexten unterschiedliche Übersetzungen hat, muss der spezifische Übersetzungskontext angegeben werden. Zu diesem Zweck wird name_context="", text_context="" oder values_context="" verwendet. Der Kontext sollte eine aussagekräftige Kurzbeschreibung sein, um den Übersetzern zu helfen.

Benutzung von Symbolen

Siehe Stile.

Ähnliche Seiten

Note: See TracWiki for help on using the wiki.