Scripts/WME Validator/Custom Checks: Difference between revisions Discussion View history

(Created page with " = WME Validator - Custom Checks = ---- == Custom Checks Examples == Custom check is a powerful tool of WME Validator to highlight very specific map issues, not covered wit...")
 
(Reformat intro)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Scripts/WME_Validator|WME Validator]] is a powerful script that helps editors find and fix issues on the Waze map. Part of its power the the ability to customize checks in the script to highlight very specific map issues, not covered with built-in validations.


== Overview ==


 
To set up a custom check in Validator click Settings->Custom. There are two checks: green and blue. Each check has two fields: template and regular expression (RegExp).
= WME Validator - Custom Checks =
----
== Custom Checks Examples ==
 
Custom check is a powerful tool of WME Validator to highlight very specific map issues, not covered with built-in validations.
 
To set up a custom check in Validator click Settings->custom. There are two checks: green and blue. Each check has two fields: template and regular expression (RegExp).


Hover your mouse over the template field to get a tooltip with available variables. Validator substitutes those variables with segment's data and then tries to match that string over the RegExp. If the expanded template string matches the RegExp - Validator highlights the segment.
Hover your mouse over the template field to get a tooltip with available variables. Validator substitutes those variables with segment's data and then tries to match that string over the RegExp. If the expanded template string matches the RegExp - Validator highlights the segment.
Line 17: Line 12:
Note: empty address fields expand to empty streets, i.e. if you set "None" next to city name, then template "#${city}#" for this segment will be expanded to "##"
Note: empty address fields expand to empty streets, i.e. if you set "None" next to city name, then template "#${city}#" for this segment will be expanded to "##"


Road type: variable ${typeRank} expands to:
Road type: variable ${typeRank} expands to: [updated to BE/NL version 1.1.19]
1 for Runways
 
2 for Railroads
<code>1 street</code><br />
...
<code>2 primary street</code><br />
14 for Major Highways
<code>3 highway</code><br />
15 for Freeways
<code>4 ramp</code><br />
<code>5 walking trail</code><br />
<code>6 major highway</code><br />
<code>7 minor highway</code><br />
<code>8 dirt road</code><br />
<code>10 pedestrian boardwalk</code><br />
<code>14 for Major Highways</code><br />
<code>15 ferry</code><br />
<code>16 stairway</code><br />
<code>17 private road</code><br />
<code>18 railroad</code><br />
<code>19 runway / taxiway</code><br />
<code>20 parking lot</code><br />


Road direction: variable ${direction} expands to:
Road direction: variable ${direction} expands to:
0 for Unknown direction
 
1 for A->B
<code>0 for Unknown direction</code><br />
2 for B->A
<code>1 for A->B</code><br />
3 for Two-way segments
<code>2 for B->A</code><br />
<code>3 for Two-way segments</code><br />


== Regular Expressions (RegExp) ==
== Regular Expressions (RegExp) ==
Line 43: Line 51:


To highlight streets with word North
To highlight streets with word North
<code>
Template: ${street}
Template: ${street}
RegExp: /North/
RegExp: /North/
</code>


To highlight invalid (null) elevations
To highlight invalid (null) elevations
<code>
Template: ${elevation}
Template: ${elevation}
RegExp: /null/
RegExp: /null/
</code>


To highlight segments with no state assigned
To highlight segments with no state assigned
<code>
Template: ${state}
Template: ${state}
RexExp: /^$/
RexExp: /^$/
</code>


To highlight segments with a U-turn
To highlight segments with a U-turn
<code>
Template: ${Uturn}
Template: ${Uturn}
RexExp: /1/
RexExp: /1/
</code>


== Medium Examples ==
== Medium Examples ==


To highlight Ramps with non-ground elevation:
To highlight Ramps with non-ground elevation:
<code>
Template: ${typeRank}:${elevation}
Template: ${typeRank}:${elevation}
RegExp: /12:[^0]/
RegExp: /12:[^0]/
</code>


To highlight Freeways which do not start with letter A
To highlight Freeways which do not start with letter A
<code>
Template: ${typeRank}:${street}
Template: ${typeRank}:${street}
RegExp: /15:[^A]/
RegExp: /15:[^A]/
</code>


To highlight streets named "U-Turn" in LA
To highlight streets named "U-Turn" in LA
<code>
Template: ${state}:${street}
Template: ${state}:${street}
RegExp: /Louisiana:U-Turn/
RegExp: /Louisiana:U-Turn/
</code>


To highlight dead-end U-turns
To highlight dead-end U-turns
<code>
Template: ${deadEnd}:${Uturn}
Template: ${deadEnd}:${Uturn}
RegExp: /1:1/
RegExp: /1:1/
</code>


To highlight the opposite: missing dead-end U-turns
To highlight the opposite: missing dead-end U-turns
<code>
Template: ${deadEnd}:${Uturn}
Template: ${deadEnd}:${Uturn}
RegExp: /1:0/
RegExp: /1:0/
</code>


New! To highlight Freeways or Major Highways in format 'Axx', 'Ixx' etc
New! To highlight Freeways or Major Highways in format 'Axx', 'Ixx' etc
<code>
Template: ${typeRank}:${street}
Template: ${typeRank}:${street}
RegExp: /^(15|14):[a-z][0-9]/i
RegExp: /^(15|14):[a-z][0-9]/i
</code>


New! To search for segments shorter than 17m:
New! To search for segments shorter than 17m:
<code>
Template: ${length}
Template: ${length}
RegExp: /^([0-9]|1[0-6])$/
RegExp: /^([0-9]|1[0-6])$/
</code>


New! To mark dead-ends without U-turn:
New! To mark dead-ends without U-turn:
<code>
Template: A${deadEndA}:${UturnA}:B${deadEndB}:${UturnB}
Template: A${deadEndA}:${UturnA}:B${deadEndB}:${UturnB}
RegExp: /A1:0|B1:0/
RegExp: /A1:0|B1:0/
</code>


New! To highlight more than 100m long unnamed drivable streets:
New! To highlight more than 100m long unnamed drivable streets:
<code>
Template: ${drivable}:${street}:${length}
Template: ${drivable}:${street}:${length}
RegExp: /1::...+/
RegExp: /1::...+/
</code>


== Advanced Examples ==
== Advanced Examples ==


To highlight street name which ends in Cntr, or Exd etc (any case variant)
To highlight street name which ends in Cntr, or Exd etc (any case variant)
<code>
Template: ${street}
Template: ${street}
RegExp: / (Cntr|Exd|La|Plc|Rvr|Tnpk|Wy)$/i
RegExp: / (Cntr|Exd|La|Plc|Rvr|Tnpk|Wy)$/i
</code>


To highlight segments that have an alt street specified but no city
To highlight segments that have an alt street specified but no city
<code>
Template: @@${altCity[0]}##${altStreet[0]}@@${altCity[1]}##${altStreet[1]}
Template: @@${altCity[0]}##${altStreet[0]}@@${altCity[1]}##${altStreet[1]}
RegExp: /@@##[^@]/
RegExp: /@@##[^@]/


</code>
To highlight invalid abbreviations for Australian roads
To highlight invalid abbreviations for Australian roads
<code>
Template: ${street}
Template: ${street}
RegExp: !/ (Ave|Blvd|Cl|Cres|Cct|Ct|Dr|Way|Line|Ln|Mtwy|Pde|Pl|Rd|St)$|^$/
RegExp: !/ (Ave|Blvd|Cl|Cres|Cct|Ct|Dr|Way|Line|Ln|Mtwy|Pde|Pl|Rd|St)$|^$/


</code>
To highlight lowercase street names for US (except S, N, W, E and to)
To highlight lowercase street names for US (except S, N, W, E and to)
<code>
Template: ${street}
Template: ${street}
RegExp: /^(?!(to) [^a-z])((S|N|W|E) )?[a-z]/
RegExp: /^(?!(to) [^a-z])((S|N|W|E) )?[a-z]/
</code>


New! To highlight Freeways with no cardinal direction (NSEW)
New! To highlight Freeways with no cardinal direction (NSEW)
<code>
Template: ${type}:${street}
Template: ${type}:${street}
RegExp: !/^[^3]| [NSEW]$/
RegExp: !/^[^3]| [NSEW]$/
</code>


New! City name abbreviation 'snt' should be lowercase and at the very beginning
New! City name abbreviation 'snt' should be lowercase and at the very beginning
<code>
Template: ${city}
Template: ${city}
RegExp: /(^|[ (])(?!^snt )[Ss][Nn][Tt]([ )]|$)/
RegExp: /(^|[ (])(?!^snt )[Ss][Nn][Tt]([ )]|$)/
</code>


New! To highlight segments if primary street name and one of the alt. names are the same
New! To highlight segments if primary street name and one of the alt. names are the same
<code>
Template: #${street}#${altStreet[#]}#
Template: #${street}#${altStreet[#]}#
RegExp: /(#.+)(?=#).*\1#/
RegExp: /(#.+)(?=#).*\1#/
 
</code>
 
 
 
 
 




[[Category:Waze Map Editor]]
[[Category:Waze Map Editor]]
[[Category:Script Subpage]]

Latest revision as of 21:28, 3 May 2017

WME Validator is a powerful script that helps editors find and fix issues on the Waze map. Part of its power the the ability to customize checks in the script to highlight very specific map issues, not covered with built-in validations.

Overview

To set up a custom check in Validator click Settings->Custom. There are two checks: green and blue. Each check has two fields: template and regular expression (RegExp).

Hover your mouse over the template field to get a tooltip with available variables. Validator substitutes those variables with segment's data and then tries to match that string over the RegExp. If the expanded template string matches the RegExp - Validator highlights the segment.

Template Variables

Most of the variables are self-explanatory. Note: empty address fields expand to empty streets, i.e. if you set "None" next to city name, then template "#${city}#" for this segment will be expanded to "##"

Road type: variable ${typeRank} expands to: [updated to BE/NL version 1.1.19]

1 street
2 primary street
3 highway
4 ramp
5 walking trail
6 major highway
7 minor highway
8 dirt road
10 pedestrian boardwalk
14 for Major Highways
15 ferry
16 stairway
17 private road
18 railroad
19 runway / taxiway
20 parking lot

Road direction: variable ${direction} expands to:

0 for Unknown direction
1 for A->B
2 for B->A
3 for Two-way segments

Regular Expressions (RegExp)

Regular expressions are patterns used to match character combinations in your expanded template. See the detailed description of regular expressions on MDN: link

Validator provides the following two extensions for regular expressions: Debug RegExp. To debug your RegExp add letter D at the very beginning: D/^[a-z]/ Validator will print debug information to the JavaScript console (Ctrl+Shift+J), so you can see how template variables expand for the segments on the map.

Negate RegExp. Sometimes it's much easier to create a RegExp for a normal condition and then just negate the result. To do so, add an exclamation mark at the very beginning: !/ (St|Ave)$/

Easy Examples

To highlight streets with word North

Template: ${street}

RegExp: /North/

To highlight invalid (null) elevations

Template: ${elevation}

RegExp: /null/

To highlight segments with no state assigned

Template: ${state}

RexExp: /^$/

To highlight segments with a U-turn

Template: ${Uturn}

RexExp: /1/

Medium Examples

To highlight Ramps with non-ground elevation:

Template: ${typeRank}:${elevation}

RegExp: /12:[^0]/

To highlight Freeways which do not start with letter A

Template: ${typeRank}:${street}

RegExp: /15:[^A]/

To highlight streets named "U-Turn" in LA

Template: ${state}:${street}

RegExp: /Louisiana:U-Turn/

To highlight dead-end U-turns

Template: ${deadEnd}:${Uturn}

RegExp: /1:1/

To highlight the opposite: missing dead-end U-turns

Template: ${deadEnd}:${Uturn}

RegExp: /1:0/

New! To highlight Freeways or Major Highways in format 'Axx', 'Ixx' etc

Template: ${typeRank}:${street}

RegExp: /^(15|14):[a-z][0-9]/i

New! To search for segments shorter than 17m:

Template: ${length}

RegExp: /^([0-9]|1[0-6])$/

New! To mark dead-ends without U-turn:

Template: A${deadEndA}:${UturnA}:B${deadEndB}:${UturnB}

RegExp: /A1:0|B1:0/


New! To highlight more than 100m long unnamed drivable streets:

Template: ${drivable}:${street}:${length}

RegExp: /1::...+/

Advanced Examples

To highlight street name which ends in Cntr, or Exd etc (any case variant)

Template: ${street}

RegExp: / (Cntr|Exd|La|Plc|Rvr|Tnpk|Wy)$/i

To highlight segments that have an alt street specified but no city

Template: @@${altCity[0]}##${altStreet[0]}@@${altCity[1]}##${altStreet[1]}

RegExp: /@@##[^@]/

To highlight invalid abbreviations for Australian roads

Template: ${street}

RegExp: !/ (Ave|Blvd|Cl|Cres|Cct|Ct|Dr|Way|Line|Ln|Mtwy|Pde|Pl|Rd|St)$|^$/

To highlight lowercase street names for US (except S, N, W, E and to)

Template: ${street}

RegExp: /^(?!(to) [^a-z])((S|N|W|E) )?[a-z]/

New! To highlight Freeways with no cardinal direction (NSEW)

Template: ${type}:${street}

RegExp: !/^[^3]| [NSEW]$/

New! City name abbreviation 'snt' should be lowercase and at the very beginning

Template: ${city}

RegExp: /(^|[ (])(?!^snt )[Ss][Nn][Tt]([ )]|$)/

New! To highlight segments if primary street name and one of the alt. names are the same

Template: #${street}#${altStreet[#]}#

RegExp: /(#.+)(?=#).*\1#/