Skip to content

Commit 47c1063

Browse files
authored
Allow to specify alternative keys for text, number, tel, email and url fields. (#98)
1 parent 9c3d880 commit 47c1063

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,23 @@ A string specifying how iD uses the field. Must be one of the following values.
481481

482482
##### `key`/`keys`
483483

484-
The `key` property names the OSM key that the field will edit.
485-
Compound fields like `address` expect an array of keys in the `keys` property.
484+
The `key` property names the OSM tag key that the field will edit. Some fields, like the `address` field, operate on more than one tag: These expect an array of keys in the `keys` property. The following table lists which field types accept which properties:
485+
486+
field type | `key` | `keys` | description | example
487+
---------- | ----- | ------ | ----------- | -------
488+
`text`, `number`, `email`, `url`, `tel` | :heavy_check_mark: | optional | Optionally, these fields can match multiple tag `keys` of an OSM object: which is useful to support OSM tags which have more than one established tag key like `phone` and `contact:phone`.[^1] | `"key": "phone", "keys": ["phone", "contact:phone"]`
489+
`address` | :heavy_check_mark: | :heavy_check_mark: | `keys` must contains all possible subtags to be used in the address field and `key` must contain the tag key prefix (e.g. `addr`). | `"key": "addr", "keys": ["addr:city", "addr:street", …]`
490+
`wikipedia`, `wikidata` | :heavy_check_mark: | :heavy_check_mark: | As the values of these two fields should be updated in sync by the editor, the `keys` should always contain both the respective wikipedia and wikidata keys. | `"key": "flag:wikidata", "keys": ["flag:wikidata", "flag:wikipedia"]`
491+
`directionalCombo` | :heavy_check_mark: | :heavy_check_mark: | For directional fields, the `key` is the tag to use when the OSM feature has the same attributes in both directions, while the `keys` are the two tags for the individual directions. | `"key": "cycleway", "keys": ["cycleway:right", "cycleway:left"]`
492+
`access` | :x: | :heavy_check_mark: | `keys` lists all access tags to consider in the field. | `"keys": ["access", "foot", "bicycle", …]`
493+
`localized` | :heavy_check_mark: | :x: | `key` specified the main tag, which will also be used as the tag key prefix for localized versions of the tag (i.e. the `name` field will also display contents of the tags `name:*`). | `"key": "name"`
494+
`multiCombo` | :heavy_check_mark: | :x: | This field allows to toggle multiple `yes/no` subtags which share a common tag prefix specified in the field's `key`. | `"key": "recycling:"`
495+
`manyCombo` | :x: | :heavy_check_mark: | Similar to the `multiCombo` field, but here the `keys` property contains the full list of OSM tag keys which the options of the field should correspond to. | `"keys": ["hiking", "bicycle", …]`
496+
`structureRadio` | :x: | :heavy_check_mark: | Like the `radio` field, but operates on multiple tags: Selecting an option will remove the tag for the previously active option. | `"keys": ["bridge", "tunnel", …]`
497+
`restrictions` | :x: | :x: | A special field which does not operate on tags, therefore does not need `key` or `keys`. |
498+
all other fields | :heavy_check_mark: | :x: | A regular field which only operates on a single tag. | `"key": "oneway"`
499+
500+
[^1]: The intended behaviour of a field with alternative `keys` is the following: If an OSM feature does not yet have a tag of the given `keys`, the supplied `key` will be used; if a feature has a single tag which matches a key from the `keys`, it should be used by the field; if a feature has multiple tags matching a key from the `keys` alternatives, the field should update them simultaneously and display a _multiple/conflicting values_ message if necessary.
486501

487502
##### `universal`
488503

schemas/field.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,14 @@
282282
},
283283
"additionalProperties": false,
284284
"anyOf": [
285-
{ "$id": "field-type-without-key", "properties": { "type": { "enum": ["restrictions"] } } },
285+
{ "$id": "field-type-without-key-nor-keys", "properties": { "type": { "enum": ["restrictions"] } }, "allOf": [
286+
{ "not": { "required": ["key"] }},
287+
{ "not": { "required": ["keys"] }}
288+
]},
289+
{ "$id": "field-type-with-key-optional-keys", "properties": { "type": { "enum": ["email", "url", "tel", "text", "number"] } }, "required": ["key"] },
286290
{ "$id": "field-type-with-key-and-keys", "properties": { "type": { "enum": ["address", "wikipedia", "wikidata", "directionalCombo"] } }, "required": ["key", "keys"] },
287291
{ "$id": "field-type-with-key-or-keys", "allOf": [
288-
{ "not": { "properties": { "type": { "enum": ["address", "wikipedia", "wikipedia", "wikidata", "directionalCombo", "restrictions"] } } } },
292+
{ "not": { "properties": { "type": { "enum": ["restriction", "email", "url", "tel", "text", "number", "address", "wikipedia", "wikidata", "directionalCombo"] } } } },
289293
{ "oneOf": [
290294
{ "required": ["key"] },
291295
{ "required": ["keys"] }

0 commit comments

Comments
 (0)