You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91Lines changed: 91 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,6 +386,97 @@ For example,
386
386
}
387
387
```
388
388
389
+
##### `relation`
390
+
391
+
For relations, this object describes which roles are allowed, which tags are required for each role, and other constraints related to relation roles.
392
+
393
+
*`relation.id` – a string. This is the “permanent relation type ID”, it must match the value of [permanent relation type ID<sup><code>P41</code></sup>](https://osm.wiki/Property:P41) in the OSM wiki’s wikibase system.
394
+
*`relation.allowDuplicateMembers` – a boolean. Set to `true` if the same OSM feature is allowed to appear multiple times in the relation's members.
395
+
*`relation.optionalTags` – an object, only useful for specifying placeholders which are referenced in `members.*.matchTags`. See example below.
396
+
*`relation.members` – an array of objects, which lists every relation role that is permitted as a member (see below).
397
+
398
+
A full example looks like this:
399
+
400
+
```jsonc
401
+
// type/restriction/no_u_turn.json
402
+
{
403
+
"relation": {
404
+
"id":"restriction", // the value of https://osm.wiki/Property:P41 from the matching
405
+
// item, in this case https://wiki.openstreetmap.org/wiki/Item:Q16054. Note that multiple
406
+
// relation entries may have the same `id` value.
407
+
"allowDuplicateMembers":true,
408
+
"members": [
409
+
{
410
+
"role":"from", // The relation role. An empty string is allowed.
411
+
"roleLabel":"From", // The label for the role, in the default language. An empty string is allowed.
412
+
"geometry": ["line"], // If not specified, any geometry is allowed.
413
+
"matchTags": [
414
+
// Describes which tags the member must have, if it has this role.
415
+
// `*` can be used as a tag value.
416
+
// If multiple array items are specified, only 1 needs to match.
417
+
// If this property is not specified, then any tags are allowed
418
+
{ "highway":"*" },
419
+
],
420
+
"min":1, // The minimum number of times that this role must appear in the relation.
421
+
"max":1, // The maximum number of times that this role must appear in the relation.
422
+
},
423
+
{
424
+
"role":"via",
425
+
"roleLabel":"Via",
426
+
"geometry": ["vertex", "line"],
427
+
"min":1,
428
+
},
429
+
{
430
+
"role":"to",
431
+
"roleLabel":"To",
432
+
"geometry": ["line"],
433
+
"matchTags": [{ "highway":"*" }],
434
+
"min":1,
435
+
"max":1,
436
+
},
437
+
],
438
+
},
439
+
}
440
+
```
441
+
442
+
It is possible for the `matchTags` constraints to reference tags from the relation.
443
+
444
+
For example, if a relation with [`type=route`](https://osm.wiki/Tag:type=route) + [`route=XXXX`](https://osm.wiki/Key:route) has a member with a role of `stop`, then that member must have a tag of `XXXX=yes`<sup>[[1]](https://osm.wiki/Relation:route#Members)</sup>. This can be expressed using the following syntax:
445
+
446
+
```jsonc
447
+
// type/route.json
448
+
{
449
+
"relation": {
450
+
"optionalTags": {
451
+
"route":"$1", // 👈 the tag value can be referenced below using $1
452
+
},
453
+
"members": [
454
+
{
455
+
"role":"stop",
456
+
"roleLabel":"Stop Position",
457
+
"geometry": ["point", "vertex"],
458
+
"matchTags": [
459
+
{
460
+
"public_transport":"stop_position",
461
+
"$1":"yes", // 👈 the member must have $1=yes. $1 is determined
462
+
// by the value of route=* on the relation.
463
+
},
464
+
],
465
+
},
466
+
],
467
+
},
468
+
}
469
+
```
470
+
471
+
##### `relationCrossReference`
472
+
473
+
To avoid repeating the [`relation` object](#relation) in several presets, you can use `relationCrossReference` to reference another preset.
474
+
475
+
For example:
476
+
```js
477
+
"relationCrossReference":"{type/route}"
478
+
```
479
+
389
480
### Fields
390
481
391
482
Fields are reusable form elements that can be associated with presets.
Copy file name to clipboardExpand all lines: schemas/preset.json
+84-1Lines changed: 84 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -135,8 +135,91 @@
135
135
},
136
136
"minProperties": 1,
137
137
"additionalProperties": false
138
+
},
139
+
"relation": {
140
+
"$ref": "#/$defs/RelationSchema"
141
+
},
142
+
"relationCrossReference": {
143
+
"description": "A preset can reference the relation schema from another preset, instead of defining the same schema again.",
144
+
"type": "string",
145
+
"pattern": "^\\{.+\\}$"
138
146
}
139
147
},
140
148
"additionalProperties": false,
141
-
"required": ["name", "geometry", "tags"]
149
+
"required": ["name", "geometry", "tags"],
150
+
"$defs": {
151
+
"RelationSchema": {
152
+
"type": "object",
153
+
"properties": {
154
+
"optionalTags": {
155
+
"type": "object",
156
+
"description": "Only useful for specifying placeholders which are referenced in members.*.matchTags",
157
+
"examples": [{ "route": "$1" }],
158
+
"additionalProperties": {
159
+
"type": "string"
160
+
},
161
+
"minProperties": 1
162
+
},
163
+
"id": {
164
+
"type": "string",
165
+
"description": "The “permanent relation type ID”, this should match the value of https://osm.wiki/Property:P41 in the OSM wiki’s wikibase system."
166
+
},
167
+
"allowDuplicateMembers": {
168
+
"type": "boolean",
169
+
"description": "Set to `true` if the same OSM feature is allowed to appear multiple times in the relation's members."
170
+
},
171
+
"members": {
172
+
"type": "array",
173
+
"items": {
174
+
"type": "object",
175
+
"properties": {
176
+
"role": {
177
+
"type": "string",
178
+
"description": "The relation role. An empty string is allowed."
179
+
},
180
+
"roleLabel": {
181
+
"type": "string",
182
+
"description": "The label for the role, in the default language. An empty string is allowed."
183
+
},
184
+
"geometry": {
185
+
"type": "array",
186
+
"uniqueItems": true,
187
+
"items": {
188
+
"$ref": "field.json#/$defs/Geometry"
189
+
},
190
+
"description": "If not specified, any geometry is allowed"
191
+
},
192
+
"matchTags": {
193
+
"type": "array",
194
+
"items": {
195
+
"type": "object",
196
+
"additionalProperties": {
197
+
"type": "string"
198
+
},
199
+
"minProperties": 1
200
+
},
201
+
"examples": [
202
+
[{ "a": 1, "b": 2 }],
203
+
[{ "a": 1 }, { "b": 2 }]
204
+
],
205
+
"description": "`*` can be used as a tag value. If multiple array items are specified, only 1 needs to match. If not specified, then any tags are allowed"
206
+
},
207
+
"min": {
208
+
"type": "integer",
209
+
"description": "If unspecified, there is no minimum"
210
+
},
211
+
"max": {
212
+
"type": "integer",
213
+
"description": "If unspecified, there is no maximum"
0 commit comments