NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Is there any way of writing my own custom rules for the JOSM validator, or to change some of the existing rules?

Sometimes, the default rules flag as "warning" lots of "defects" that really aren't problems, because the underlying rule is not specific enough, or is too strict, and sometimes I want new rules so that I can check my own work more strictly.

For example, the default rules flag the ways used for house number interpolation that end near a street corner as "Way end near other way", and while this is strictly true, these ways do not have real physical representation, and are just a helpful construct to aid in address geolocation. Therefore, I do not want them flagged as such, requiring one extra rule in the validation to exclude them. See this question for more information. If I disable the "unconnected ways" option in the preferences page, or change the "validator.UnconnectedWays.node_way_distance" configuration value, the validator will miss the real unconnected ways...

Another example is for the recent change that flags as "warning" the missing voltage of power lines. See here. I do want to disable this rule (annoying!) in my local working copy, but if I disable the "power lines" option in the JOSM validator's preferences page, I would also disable all of the other errors/warnings related to power lines.

asked 18 Nov '13, 20:08

MCPicoli's gravatar image

MCPicoli
2.2k133047
accept rate: 24%


As far as I know there isn't an "easy syntax" to create/modify validator tests (like there is for presets for example). You'll have to patch this code to modify an existing test or add a new one. Your example improvement of ignoring certain ways for the unconnected_ways test shouldn't be hard to do.

Once you've improved a validator test, upstream will certainly be happy to review and merge your patch, so that all users can benefit. Create a josm bug report explaining why the change is needed and attaching your patch. Thanks in advance :)

permanent link

answered 19 Nov '13, 10:03

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
17.3k18152249
accept rate: 19%

If you aren't comfortable with software development workflows (downloading, compiling, comitting...) head over to #osm-dev or #josm to guide you. Have fun :)

(19 Nov '13, 10:07) Vincent de P... ♦

Seems easy enough. I'll give it a try next weekend, work hours allowing.

(19 Nov '13, 11:39) MCPicoli
4

WOW! Was just checking the code Vincent linked (hoping to understand it), and, to my surprise, there already was a patch (by Don-vip) for this case (for the bug report I opened yesterday)! Probably it'll be merged into the next "tested" version. Thanks anyway!

(19 Nov '13, 11:44) MCPicoli

With JOSM’s tag checker it’s now possible to add your own custom validations using MapCSS. For example:

  1. Create a file named example.validator.mapcss containing:

    *["addr:housenumber"][!"addr:state"] {
      throwWarning: tr("Address missing state");
    }
    
  2. Select the file in JOSM → Edit → Preferences → Data validator → Tag checker rules → Add (+).

When you run the validator (typically automatically before upload) you’ll get a warning:

screenshot

permanent link

answered 19 Apr '22, 22:07

Andrew%20Kvalheim's gravatar image

Andrew Kvalheim
41115
accept rate: 0%

Hello,

would anyone be able to create a .mapcss file for validator to reveal the address (as a duplication) placed on the building as a node? (if any address tag already exists in the building)

permanent link

answered 19 Feb, 07:01

Klerik7's gravatar image

Klerik7
71336
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×622
×39
×22
×13

question asked: 18 Nov '13, 20:08

question was seen: 4,851 times

last updated: 19 Feb, 07:01

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum