-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaprules.docs.js
587 lines (577 loc) · 19.7 KB
/
maprules.docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/**
* @api {get} /config/:id Get MapRules config
* @apiName GetConfig
* @apiGroup Config
*
* @apiParam {String} id MapRules configuration id
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl http://localhost:3000/config/f343b37a-a2f5-4ee7-bcfd-2710af86c6ba
*
* @apiSuccessExample {json} Success-Response
* {
"name": "Public Health Campaign",
"presets": [
{
"fields": [
{
"keyCondition": 1,
"key": "opening_hours",
"label": "Hours of Operation",
"placeholder": "24/7",
"values": [
{
"valCondition": 2,
"values": [ "24/7", "sunrise_sunset" ]
}
]
},
{
"keyCondition": 1,
"key": "height",
"values": [
{
"valCondition": 5,
"values": ["0"]
}
]
},
{
"keyCondition": 1,
"key": "name",
"values": []
}
],
"geometry": ["node", "area"],
"name": "Water Tap",
"primary": [
{
"key": "amenity",
"val": "drinking_water"
},
{
"key": "man_made",
"val": "water_tap"
}
]
}
],
"disabledFeatures": [
{
"key": "amenity",
"val": ["school", "clinic"]
}
]
* }
* @apiErrorExample {json} Error-Response: id not in the database
* {
* "statusCode":404,
* "error":"Not Found",
* "message":"Not Found"
* }
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {
* "statusCode":400,
* "error":"Bad Request",
* "message":"Invalid request params input"
* }
*
*/
/**
* @api {post} /config Post MapRules config
* @apiName PostConfig
* @apiGroup Config
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl -H "Content-Type: application/json" -X POST -d '{"name":"Public Health Campaign","presets":[{"fields":[{"keyCondition":"1","key":"opening_hours","label":"Hours of Operation","placeholder":"24/7","values":[{"valCondition":2,"values":["24/7","sunrise_sunset"]}]},{"keyCondition":1,"key":"height","values":[{"valCondition":5,"values":["0"]}]},{"keyCondition":1,"key":"name","values":[]}],"geometry":["node","area"],"name":"Water Tap","primary":[{"key":"amenity","val":"drinking_water"},{"key":"man_made","val":"water_tap"}]}],"disabledFeatures":[{"key":"amenity","val":["school","clinic"]}]}'
*
* @apiSuccessExample {json} Success-Response
* {"upload":"successful","id":"a1035b4b-2580-4dfa-bf42-9ffb94d1690d"}
*
* @apiErrorExample {json} Error-Response: payload does not match MapRules config schema
* {"statusCode":400,"error":"Bad Request","message":'child "presets" fails because ["presets" at position 0 fails because [child "fields" fails because ["fields" at position 1 fails because [child "keyCondition" fails because ["keyCondition" less than or equal to 6]]]]]'}
*/
/**
* @api {put} /config/:id Put updated MapRules config
* @apiName PuttConfig
* @apiGroup Config
*
* @apiParam {String} id MapRules configuration id
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl -H "Content-Type: application/json" -X PUT -d 'Content-Type: application/json" -X POST -d '{"project":"Public Health Campaign","presets":[{"fields":[{"keyCondition":1,"key":"opening_hours","label":"Hours of Operation","placeholder":"24/7, sunrise to sunset...","values":{"suggested":[{"val":"24/7","name":"always open"},{"val":"sunrise to sunset"}]}},{"keyCondition":1,"key":"height","values":{"numeric":{"greaterThan":2}}},{"keyCondition":1,"key":"name","values":{}}],"geometry":["node"],"name":"Water Tap","primary":[{"key":"amenity","val":"drinking_water"},{"key":"man_made","val":"water_tap"}]}],"disabledFeatures":[{"key":"amenity","val":"school"}]}' http://localhost:3000/config/a1035b4b-2580-4dfa-bf42-9ffb94d1690d
*
* @apiSuccessExample {json} Success-Response
* {"update":"successful"}
*
* @apiErrorExample {json} Error-Response: payload does not match MapRules config schema
* {"statusCode":400,"error":"Bad Request","message":'child "project" fails because ["project" is required]'}
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {"statusCode":400,"error":"Bad Request","message":'child "id" fails because ["id" must be a valid GUID]'}
*
*/
/**
* @api {get} /config/:id/rules/JOSM Get MapCSS rules for a given MapRules config
* @apiName GetJOSMRules
* @apiGroup JOSM
*
* @apiParam {String} id MapRules configuration id
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl http://localhost:3000/config/72d5df88-c53a-458b-8247-8e691feb0d04/rules/JOSM
*
* @apiSuccessExample {text} Success-Response
*
* node[amenity=drinking_water][man_made=water_tap][!opening_hours]{
throwError: "'Water Tap' preset must include opening_hours";
}
node[amenity=drinking_water][man_made=water_tap][opening_hours][opening_hours!~/^24\/7$|^sunrise_sunset$/]{
throwError: "opening_hours may be '24/7','sunrise_sunset'";
}
node[amenity=drinking_water][man_made=water_tap][!height]{
throwError: "'Water Tap' preset must include height";
}
node[amenity=drinking_water][man_made=water_tap][height][height > 0]{
throwError: "height must be greater than 0";
}
node[amenity=drinking_water][man_made=water_tap][!name]{
throwError: "'Water Tap' preset must include name";
}
way[amenity=drinking_water][man_made=water_tap][!opening_hours]:closed{
throwError: "'Water Tap' preset must include opening_hours";
}
way[amenity=drinking_water][man_made=water_tap][opening_hours][opening_hours!~/^24\/7$|^sunrise_sunset$/]:closed{
throwError: "opening_hours may be '24/7','sunrise_sunset'";
}
way[amenity=drinking_water][man_made=water_tap][!height]:closed{
throwError: "'Water Tap' preset must include height";
}
way[amenity=drinking_water][man_made=water_tap][height][height > 0]:closed{
throwError: "height must be greater than 0";
}
way[amenity=drinking_water][man_made=water_tap][!name]:closed{
throwError: "'Water Tap' preset must include name";
}
node[amenity][amenity=~/^school$|^clinic$/]{
throwError: "amenity cannot be coupled with 'school','clinic'";
}
way[amenity][amenity=~/^school$|^clinic$/]{
throwError: "amenity cannot be coupled with 'school','clinic'";
* }
*
* @apiErrorExample {json} Error-Response: id not in the database
* {"statusCode":404,"error":"Not Found","message":"Not Found"}
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {"statusCode":400,"error":"Bad Request","message":"Invalid request params input"}
*
*/
/**
* @api {get} /config/:id/presets/JOSM Get JOSM preset xml for given MapRules config
* @apiName GetJOSMPresets
* @apiGroup JOSM
*
* @apiParam {String} id MapRules configuration id
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl http://localhost:3000/config/72d5df88-c53a-458b-8247-8e691feb0d04/presets/JOSM
*
* @apiSuccessExample {xml} Success-Response
*
* <preset>
<group name="Public Health Campaign" icon="images/dialogs/edit.png">
<item name="Health Clinic" type="closedway,node" icon="images/layer/osmdata_small.png">
<key key="amenity" value="clinic"/>
<key key="area" value="yes"/>
</item>
<item name="Market" type="closedway" icon="images/layer/osmdata_small.png">
<key key="amenity" value="marketplace"/>
<key key="area" value="yes"/>
<combo key="source" text="source" values_searchable="true">
<list_entry value="bing" display_value="Bing"/>
<list_entry value="dg" display_value="Dg"/>
</combo>
<combo key="opening_hours" text="Opening Hours" values_searchable="true">
<list_entry value="24/7" display_value="24/7"/>
<list_entry value="sunrise to sunset" display_value="Sunrise to Sunset"/>
</combo>
<text key="building" text="Building"/>
<text key="height" text="Height"/>
</item>
<item name="Water Tap" type="node" icon="images/layer/osmdata_small.png">
<key key="amenity" value="drinking_water"/>
<key key="man_made" value="water_tap"/>
</item>
</group>
* </preset>
*
* @apiErrorExample {json} Error-Response: id not in the database
* {"statusCode":404,"error":"Not Found","message":"Not Found"}
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {"statusCode":400,"error":"Bad Request","message":"Invalid request params input"}
*
*/
/**
* @api {post} /mapcss Convert MapCSS Validation Rule to JSON
* @apiName MapCssToJson
* @apiGroup mapcss
*
* @apiVersion 0.0.2
*
* @apiExample {curl} Example Usage
* curl -H "Content-Type: text/html" -X POST -d 'node[healthcare=yes][!name]{ throwError: \"'healthcare' preset must include name\"; } way[healthcare=yes][!name]:closed{ throwError: \"'healthcare' preset must include name\"; }'
*
* @apiSuccessExample {json} Success-Response
* [{\"geometry\":\"node\",\"equals\":{\"healthcare\":\"yes\"},\"absence\":\"name\",\"error\":\"'healthcare' preset must include name\"},{\"geometry\":\"closedway\",\"equals\":{\"healthcare\":\"yes\"},\"absence\":\"name\",\"error\":\"'healthcare' preset must include name\"}]
*
*/
/**
* @api {get} /config/:id/rules/iD Get json equivalent MapCSS rules for a given MapRules config
* @apiName GetiDRules
* @apiGroup iD
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl http://localhost:3000/config/72d5df88-c53a-458b-8247-8e691feb0d04/rules/iD
*
* @apiSuccessExample {json} Success-Response
*
* [
{
geometry: "node",
equals: {
man_made: "water_tap"
},
absence: "opening_hours",
error: "'Water Tap' preset must include opening_hours"
},
{
geometry: "node",
equals: {
man_made: "water_tap"
},
presence: "opening_hours",
negativeRegex: {
opening_hours: [
"^24\/7$",
"^sunrise_sunset$"
]
},
error: opening_hours may be '24/7','sunrise_sunset'"
},
{
geometry: "node",
equals: {
man_made: "water_tap"
},
absence: "height",
error: "'Water Tap' preset must include height"
},
{
geometry: "node",
equals: {
man_made: "water_tap"
},
presence: "height",
greaterThan: {
height: 0
},
error: "height must be greater than 0"
},
{
geometry: "node",
equals: {
man_made: "water_tap"
},
absence: "name",
error: "'Water Tap' preset must include name"
},
{
geometry: "closedway",
equals: {
man_made: "water_tap"
},
absence: "opening_hours",
error: "'Water Tap' preset must include opening_hours"
},
{
geometry: "closedway",
equals: {
man_made: "water_tap"
},
presence: "opening_hours",
negativeRegex: {
opening_hours: [
"^24\/7$",
"^sunrise_sunset$"
]
},
error: "opening_hours may be '24/7','sunrise_sunset'"
},
{
geometry: "closedway",
equals: {
man_made: "water_tap"
},
absence: "height",
error: "'Water Tap' preset must include height"
},
{
geometry: "closedway",
equals: {
man_made: "water_tap"
},
presence: "height",
greaterThan: {
height: 0
},
error: height must be greater than 0"
},
{
geometry: "closedway",
equals: {
man_made: "water_tap"
},
absence: "name",
error: 'Water Tap' preset must include name"
},
{
geometry: "node",
presence: "amenity",
positiveRegex: {
amenity: [
"^school$",
"^clinic$"
]
},
error: "amenity cannot be coupled with 'school','clinic'"
},
{
geometry: "way",
presence: "amenity",
positiveRegex: {
amenity: [
"^school$",
"^clinic$"
]
},
error: "amenity cannot be coupled with 'school','clinic'"
}
* ]
*
* @apiErrorExample {json} Error-Response: id not in the database
* {"statusCode":404,"error":"Not Found","message":"Not Found"}
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {"statusCode":400,"error":"Bad Request","message":"Invalid request params input"}
*
*/
/**
* @api {get} /config/:id/presets/iD Get iD Presets for a given MapRules Config
* @apiName GetiDPresets
* @apiGroup iD
*
* @apiVersion 0.0.1
*
* @apiExample {curl} Example Usage
* curl http://localhost:3000/config/72d5df88-c53a-458b-8247-8e691feb0d04/presets/iD
*
* {
categories: {
category-point: {
icon: "maki-natural",
geometry: "point",
name: "MapRules point Features",
members: [
"b116289d-912c-47ce-a89d-77ced4494df5"
]
},
category-area: {
icon: "maki-natural",
geometry: "area",
name: "MapRules area Features",
members: [
"b116289d-912c-47ce-a89d-77ced4494df5"
]
}
},
presets: {
b116289d-912c-47ce-a89d-77ced4494df5: {
geometry: [
"point",
"area"
],
tags: {
amenity: "drinking_water",
man_made: "water_tap"
},
icon: "maki-natural",
name: "Water Tap",
fields: [
"83ed0731-cb9e-408b-82b0-d37adab90289",
"bd9b78fd-4338-49aa-81ce-cc2f2060f3ea",
"e5a6e023-9638-4e80-8be9-a707d892fc39"
]
},
point: {
fields: [
"name"
],
geometry: [
"point"
],
tags: { },
name: "Point",
matchScore: 0.1
},
line: {
fields: [
"name"
],
geometry: [
"line"
],
tags: { },
name: "Line",
matchScore: 0.1
},
area: {
fields: [
"name"
],
geometry: [
"area"
],
tags: {
area: "yes"
},
name: "Area",
matchScore: 0.1
},
relation: {
icon: "iD-relation",
fields: [
"name",
"relation"
],
geometry: [
"relation"
],
tags: { },
name: "Relation"
}
},
fields: {
83ed0731-cb9e-408b-82b0-d37adab90289: {
key: "opening_hours",
label: "Hours Of Operation",
overrideLabel: "Hours Of Operation",
placeholder: "24/7",
strings: {
options: {
24/7: "24/7",
Sunrise Sunset: "sunrise_sunset"
}
},
type: "combo"
},
bd9b78fd-4338-49aa-81ce-cc2f2060f3ea: {
key: "height",
label: "Height",
overrideLabel: "Height",
placeholder: "...",
maxValue: 0,
type: "number"
},
e5a6e023-9638-4e80-8be9-a707d892fc39: {
key: "name",
label: "Name",
overrideLabel: "Name",
placeholder: "...",
type: "text"
},
name: {
key: "name",
type: "localized",
label: "Name",
universal: true,
placeholder: "Common name (if any)"
},
relation: {
key: "type",
type: "combo",
label: "Type"
},
comment: {
key: "comment",
type: "textarea",
label: "Changeset Comment",
placeholder: "Brief description of your contributions (required)"
},
source: {
key: "source",
type: "semiCombo",
icon: "source",
universal: true,
label: "Sources",
snake_case: false,
caseSensitive: true,
options: [
"survey",
"local knowledge",
"gps",
"aerial imagery",
"streetlevel imagery"
]
},
hashtags: {
key: "hashtags",
type: "semiCombo",
label: "Suggested Hashtags",
placeholder: "#example"
}
},
defaults: {
point: [
"b116289d-912c-47ce-a89d-77ced4494df5"
],
area: [
"b116289d-912c-47ce-a89d-77ced4494df5"
]
}
* }
*
* @apiErrorExample {json} Error-Response: id not in the database
* {"statusCode":404,"error":"Not Found","message":"Not Found"}
*
*
* @apiErrorExample {json} Error-Response: id parameter does not match uuid v4 schema
* {"statusCode":400,"error":"Bad Request","message":"Invalid request params input"}
*
*/
/**
* @api {docs} /spec MapRules configuration specification
* @apiName DocsSpec
* @apiGroup Docs
* @apiVersion 0.1.0
*/
/**
* @api {docs} /rules MapRules validation rule scenarios
* @apiName DocsRules
* @apiGroup Docs
* @apiVersion 0.1.0
*/