Modify

Opened 9 years ago

Closed 9 years ago

#12053 closed enhancement (fixed)

Enhancement [PATCH] Add validation for mountain bike specific tags

Reported by: stefan-a-bauer@… Owned by: team
Priority: normal Milestone:
Component: Core validator Version:
Keywords: Cc: Klumbumbus

Description

When tagging the uphill difficulty of a mountain bike trail (i.e., a path), the OSM wiki defines that also the incline tag has to be present.

This patch adds a validator which checks that rule:

https://github.com/stefan-a-bauer/josm/commit/642af3430cf644eb6a3c1302931a045f92870bc5
https://github.com/stefan-a-bauer/josm/commit/642af3430cf644eb6a3c1302931a045f92870bc5.patch

Attachments (0)

Change History (6)

comment:1 by naoliv, 9 years ago

Can't it be done with MapCSS?

way["mtb:scale:uphill"][!incline] {
    throwWarning: tr("missing {0} tag in way", "{1.key}");
}

You could also create more MTB-specific rules and include them in https://josm.openstreetmap.de/wiki/Rules, if you want.

For example, you could also test for some wrong things:

way["mtb:scale:uphill"][highway][highway !~ /path|track/] {
    throwWarning: tr("{0} should be used only with highway=path or highway=track", "{0.key}");
}

way["mtb:scale"]["mtb:scale" !~ /^[0-6]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''6''", "{0.key}");
}

way["mtb:scale:uphill"]["mtb:scale:uphill" !~ /^[0-5]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''5''", "{0.key}");
}

way["mtb:scale:imba"]["mtb:scale:imba" !~ /^[0-4]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''4''", "{0.key}");
}

comment:2 by naoliv, 9 years ago

Can't it be done with MapCSS?

way["mtb:scale:uphill"][!incline] {
    throwWarning: tr("missing {0} tag in way", "{1.key}");
}

You could also create more MTB-specific rules and include them in https://josm.openstreetmap.de/wiki/Rules, if you want.

For example, you could also test for some wrong things:

way["mtb:scale:uphill"][highway][highway !~ /path|track/] {
    throwWarning: tr("{0} should be used only with highway=path or highway=track", "{0.key}");
}

way["mtb:scale"]["mtb:scale" !~ /^[0-6]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''6''", "{0.key}");
}

way["mtb:scale:uphill"]["mtb:scale:uphill" !~ /^[0-5]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''5''", "{0.key}");
}

way["mtb:scale:imba"]["mtb:scale:imba" !~ /^[0-4]{1}$/] {
    throwWarning: tr("{0} must be a value between ''0'' and ''4''", "{0.key}");
}
Version 0, edited 9 years ago by naoliv (next)

comment:3 by stefan-a-bauer@…, 9 years ago

Thanks for the pointer. I was thinking that such a check should be easily described in declarative style, but somehow MapCSS escaped my notice.

I will send a second proposal based on your example (which is a little too strict IMHO) soon.

comment:4 by Klumbumbus, 9 years ago

Cc: Klumbumbus added

comment:5 by stefan-a-bauer@…, 9 years ago

OK, here's my next proposal based on MapCSS:

https://github.com/stefan-a-bauer/josm-validators/blob/master/mtb.validator.mapcss

I applied only slight adaptions to naoliv's example. Integration into JOSM via the wiki works. With respect to this, the issue could be closed IMO.

BTW: How to provide translations for a validator which is integrated this way?

in reply to:  5 comment:6 by stoecker, 9 years ago

Resolution: fixed
Status: newclosed

BTW: How to provide translations for a validator which is integrated this way?

Add the appropriate xx.lang files. And then wait for #11392.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.