Ticket #22822: runway.validator.mapcss

File runway.validator.mapcss, 6.1 KB (added by gaben, 3 years ago)

result

Line 
1/* See JOSM #22822 - runway heading validator by gaben */
2
3/* raising error only if {first designator >= the second designator} */
4way[aeroway=runway][ref =~ /^([0-9]{1,3}[LCRWSGHU]? ?[-,;\/\\] ?[0-9]{1,3}[LCRWSGHU]?)$/][eval(to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 1)) >= to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 2)))] {
5 group: tr("runway reference");
6 set runwayDesignatorOrderIssue;
7 /* throwError: tr("designators should be in increasing order"); add this line to pass tests... I think it's a bug */
8 assertMatch: "way aeroway=runway ref=02-01";
9 assertMatch: "way aeroway=runway ref=\"2- 1\"";
10 assertMatch: "way aeroway=runway ref=\"2 - 1\"";
11 assertMatch: "way aeroway=runway ref=36/18";
12 /* assertMatch: "way aeroway=runway ref=\"36\18\""; not working yet :( */
13 assertMatch: "way aeroway=runway ref=36W-17W";
14 assertMatch: "way aeroway=runway ref=01/01";
15 assertNoMatch: "way aeroway=runway ref=17W-36W";
16 assertNoMatch: "way aeroway=runway ref=01- 02";
17 assertNoMatch: "way aeroway=runway ref=03H/12H";
18 assertNoMatch: "way aeroway=runway ref=01-19";
19 assertNoMatch: "way aeroway=runway ref=3/21";
20 assertNoMatch: "way aeroway=runway ref=09L/27R";
21}
22
23/* raising error only if {second designator - first designator != 18} [global version] */
24way[aeroway=runway][ref =~ /^([0-9]{1,2}[LCRWSGHU]? ?[-,;\/\\] ?[0-9]{1,2}[LCRWSGHU]?)$/][eval(to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 2)) - to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 1)) != 18)]!.runwayDesignatorOrderIssue {
25 group: tr("runway reference");
26 set global180RuleIssue;
27 throwError: tr("numbers don''t follow the 180 degree rule (global version)");
28 assertMatch: "way aeroway=runway ref=\"01 -02R\"";
29 assertMatch: "way aeroway=runway ref=17W-36W";
30 assertMatch: "way aeroway=runway ref=\"01/ 01\"";
31 assertMatch: "way aeroway=runway ref=03H/12H";
32 assertNoMatch: "way aeroway=runway ref=01-19";
33 assertNoMatch: "way aeroway=runway ref=\"3 / 21\"";
34 assertNoMatch: "way aeroway=runway ref=09L/27R";
35}
36
37/* raising error only if {second designator - first designator != 180} [American version] */
38way[aeroway=runway][ref =~ /^([0-9]{1,3}[LCRWSGHU]? ?[-,;\/\\] ?[0-9]{3}[LCRWSGHU]?)$/][eval(to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 2)) - to_int(get(regexp_match("^([0-9]+)[LCRWSGHU]? ?[-,;\\/] ?([0-9]+)[LCRWSGHU]?$", tag("ref")), 1)) != 180)]!.runwayDesignatorOrderIssue {
39 group: tr("runway reference");
40 set american180RuleIssue;
41 throwError: tr("numbers don''t follow the 180 degree rule (American version)");
42 assertMatch: "way aeroway=runway ref=170W-360W";
43 assertMatch: "way aeroway=runway ref=\"10/ 100\"";
44 assertMatch: "way aeroway=runway ref=30H/120H";
45 assertNoMatch: "way aeroway=runway ref=10-190";
46 assertNoMatch: "way aeroway=runway ref=\"30 / 210\"";
47 assertNoMatch: "way aeroway=runway ref=09L/27R";
48}
49
50/* offer heading separator fix */
51way[aeroway=runway][ref =~ /^([0-9]{1,3}[LCRWSGHU]? [-,;\/\\][0-9]{1,3}[LCRWSGHU]?)$/]!.runwayDesignatorOrderIssue!.global180RuleIssue!.american180RuleIssue,
52way[aeroway=runway][ref =~ /^([0-9]{1,3}[LCRWSGHU]?[-,;\/\\] [0-9]{1,3}[LCRWSGHU]?)$/]!.runwayDesignatorOrderIssue!.global180RuleIssue!.american180RuleIssue,
53way[aeroway=runway][ref =~ /^([0-9]{1,3}[LCRWSGHU]? [-,;\/\\] [0-9]{1,3}[LCRWSGHU]?)$/]!.runwayDesignatorOrderIssue!.global180RuleIssue!.american180RuleIssue {
54 group: tr("runway reference");
55 assertMatch: "way aeroway=runway ref=\"09L /27R\"";
56 assertMatch: "way aeroway=runway ref=\"09L/ 27R\"";
57 assertNoMatch: "way aeroway=runway ref=09L/27R";
58 throwWarning: tr("values can be value can be prettified, separator");
59 fixAdd: concat("ref=", eval(get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) > get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2)) ? get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2) : get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) , "/",
60 eval(get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) > get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2)) ? get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) : get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2));
61}
62
63/* offer heading order fix */
64way[aeroway=runway].runwayDesignatorOrderIssue!.global180RuleIssue!.american180RuleIssue {
65 group: tr("runway reference");
66 throwError: tr("designators should be in increasing order");
67 fixAdd: concat("ref=", eval(get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) > get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2)) ? get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2) : get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) , "/",
68 eval(get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) > get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2)) ? get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1) : get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2));
69}
70
71/* offer heading leading zero fix (except USA, Mexico) */
72way[aeroway=runway][outside("US,MX")][ref =~ /^([0-9]{1}[LCRWSGHU]? ?[-,;\/\\] ?[0-9]{1,3}[LCRWSGHU]?)$/]!.runwayDesignatorOrderIssue!.global180RuleIssue!.american180RuleIssue {
73 group: tr("runway reference");
74 assertMatch: "way aeroway=runway ref=9L/27R";
75 assertNoMatch: "way aeroway=runway ref=09L/27R";
76 throwWarning: tr("values can be value can be prettified, leading zero");
77 fixAdd: concat("ref=0", get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 1), "/", get(regexp_match("^([0-9]+[LCRWSGHU]?) ?[-,;\\/] ?([0-9]+[LCRWSGHU]?)$", tag("ref")), 2));
78}