Modify

Opened 3 years ago

Closed 3 years ago

#21866 closed enhancement (fixed)

[patch] Update railway gauge values

Reported by: gaben Owned by: team
Priority: normal Milestone: 22.02
Component: Internal preset Version:
Keywords: railway gauge Cc:

Description

I updated the railway gauge values from Wikipedia https://en.wikipedia.org/wiki/Track_gauge.

Also, the narrow track has its own gauge values, as the values from other presets won't fit the narrow track requirement.

Attachments (4)

track_gauge.patch (1.6 KB ) - added by gaben 3 years ago.
josm_21866_numeric.patch (2.6 KB ) - added by skyper 3 years ago.
validator rules using local classes
josm_21866_numeric_v2.patch (2.6 KB ) - added by skyper 3 years ago.
version 2: fix typo in article and add type=route for relations
josm_21866_track_gauge_with_validator.patch (4.3 KB ) - added by gaben 3 years ago.

Download all attachments as: .zip

Change History (26)

by gaben, 3 years ago

Attachment: track_gauge.patch added

comment:1 by skyper, 3 years ago

Component: Core validatorInternal preset

comment:2 by mdk, 3 years ago

And there are much more (see https://de.wikipedia.org/wiki/Liste_der_Spurweiten), but I think the patch covers the mostly used values.

comment:3 by skyper, 3 years ago

Most common values are listed here: https://de.wikipedia.org/wiki/Spurweite_(Bahn)
Interesting, everything below 1435 mm is considered a narrow gauge but we probably have to take a closer look at the actual use within the OSM data.

@Gabe
Do you plan any validation?

Last edited 3 years ago by skyper (previous) (diff)

comment:4 by gaben, 3 years ago

Yes, I'm planning some range restrictions, but only for narrow gauge railways. Also open to suggestions, I haven't thought much about it yet.

comment:5 by gaben, 3 years ago

Something like this

/* #21866  */
*[/railway$/=~/^narrow_gauge$/][gauge][gauge<89],
*[/railway$/=~/^narrow_gauge$/][gauge][gauge>1434] {
  group: tr("suspicious tag combination");
  throwWarning:  tr("unusual gauge value on narrow gauge railway");
  assertNoMatch: "way railway=narrow_gauge gauge=88";
  assertMatch:   "way railway=narrow_gauge gauge=89";
  assertMatch:   "way railway=narrow_gauge gauge=1434";
  assertNoMatch: "way railway=narrow_gauge gauge=1435";
}

@skyper what dou you think?

comment:6 by skyper, 3 years ago

Nice. Why do you use a regex for railway? Can we use placeholders? Do we need [gauge]?

/* #21866  */
*[railway=narrow_gauge][gauge<89],
*[railway=narrow_gauge][gauge>1434] {
  group: tr("suspicious tag combination");
  throwWarning:  tr("unusual {2} value on {1} {0}, should be between 89 and 1434 mm", "{0.key}", "{0.value}", "{1.key}");
  assertNoMatch: "way railway=narrow_gauge gauge=88";
  assertMatch:   "way railway=narrow_gauge gauge=89";
  assertMatch:   "way railway=narrow_gauge gauge=1434";
  assertNoMatch: "way railway=narrow_gauge gauge=1435";
}

I find some multiple values with taginfo (e.g. 127;184;260), so we probably have to split at the semicolon and check each value of the list.
Additionally some values are in feet and inches (e.g. 0'10.25";0'7.25" or 56' 1/2") which should be excluded or at least show a different warning.
Looks like it is not that simple but manageable.

Last edited 3 years ago by skyper (previous) (diff)

in reply to:  6 comment:7 by gaben, 3 years ago

Why do you use a regex for railway? Can we use placeholders?

To include lifecycle prefixed objects in the test because gauge applies to them as well. It seems placeholders are possible only if we drop regex.

I intentionally left out multi values as *it doesn't worth the hassle IMO. Same for non-metric units as OSM defaults to metric and the Key:gauge mentions millimetres only.

*But here you go, a new version with multi value support:

/* #21866  */
*[/railway$/=~/^narrow_gauge$/][gauge!~/^((14(?:3[0-4]|[4-9])|(?:14[0-2]|(?:1[0-3]|9)[0-9])[0-9]?|143|(?:[2-7][0-9]|1[5-9])[0-9]|8(?:[0-8][0-9]|9[0-9]?));?)+$/] {
  group: tr("suspicious tag combination");
  throwWarning:  tr("unusual gauge value on narrow gauge railway");
  assertMatch:   "way railway=narrow_gauge gauge=88";
  assertNoMatch: "way railway=narrow_gauge gauge=89";
  assertNoMatch: "way railway=narrow_gauge gauge=1434";
  assertMatch:   "way railway=narrow_gauge gauge=1435";
  assertMatch:   "way railway=narrow_gauge gauge=1435;1500";
  assertMatch:   "way railway=narrow_gauge gauge=60;600";
}
Last edited 3 years ago by gaben (previous) (diff)

comment:8 by skyper, 3 years ago

I think you little misunderstood my intention. I feared false positives.
Almost perfect.
I just noticed, that there is already a rule for gauge=* in numeric.mapcss which could/should be used as local class to get rid of the false positives, like non-metric values.

The assert(No)Match seem to be mixed up. JOSM seems to have problem with them though as I do not get warnings on the console

Personally I thought about something like below but it does not work. I have no clue what I do wrong.

way[/railway$/=~/^narrow_gauge$/][get(sort_list(uniq_list(trim_list(split(";", tag("gauge"))))), 0)<89],
way[/railway$/=~/^narrow_gauge$/][get(sort_list(uniq_list(trim_list(split(";", tag("gauge"))))), count(uniq_list(trim_list(split(";", tag("gauge"))))-1))>1434] {
  throwWarning:  tr("wrong {0} value on {1}", "{1.key}", "narrow gauge railway");
  group: tr("suspicious tag combination");
  assertNoMatch: "way railway=narrow_gauge gauge=88'";
  assertMatch: "way railway=narrow_gauge gauge=88";
  assertNoMatch:   "way railway=narrow_gauge gauge=89";
  assertNoMatch:   "way railway=narrow_gauge gauge=1434";
  assertMatch: "way railway=narrow_gauge gauge=1435";
  assertMatch: "way railway=narrow_gauge gauge=1435;1500";
  assertMatch:   "way railway=narrow_gauge gauge=60;600";
}

comment:9 by gaben, 3 years ago

Thanks! Updated assertions in my last comment.

Yeah, I forgot the non-metric units handled in the numeric tests, that's another reason I left them out.

Please give examples on false positives.

comment:10 by skyper, 3 years ago

Oh, I missed the object type selector. Is way enough or do you want to catch the route=railway and route=tracks relations?

The wiki was changed 1½ years ago, demanding on millimeters only. The translated pages still mention other values.
With false positives I mean values in feet and inches or narrow which is regarded as ok by the existing rule.

comment:11 by gaben, 3 years ago

JOSM seems to have problem with them though as I do not get warnings on the console

Just enable the validator.check_assert_local_rules setting in the advanced preferences.

I want to catch *, it doesn't harm.

If an object is tagged with railway=narrow_gauge + gauge=narrow and the validator complains with unusual gauge value on narrow gauge railway message, that's OK for me. The problem is the grouping because this time it isn't a suspicious tag combination, just an unusual value.

by skyper, 3 years ago

Attachment: josm_21866_numeric.patch added

validator rules using local classes

in reply to:  11 ; comment:12 by skyper, 3 years ago

Here is my proposal for validator: josm_21866_numeric.patch

  • using classes to get rid of duplicates and incorrect warnings
  • add a new warning for imprecise values
  • only check ways and relations

I prefer to only run tests on certain objects instead of all. Nodes with railway=narrow_gauge are suspicious but better placed in a separate warning. The relations could even be restricted to type=route, I guess.

Replying to gaben:

JOSM seems to have problem with them though as I do not get warnings on the console

Just enable the validator.check_assert_local_rules setting in the advanced preferences.

Thanks, I was using the wrong profile. Now, it is working.

by skyper, 3 years ago

Attachment: josm_21866_numeric_v2.patch added

version 2: fix typo in article and add type=route for relations

comment:13 by skyper, 3 years ago

version 2 fixes a typo and adds type=route for relations.

in reply to:  12 comment:14 by gaben, 3 years ago

Replying to skyper:

Nodes with railway=narrow_gauge are suspicious

Oopsie, you are right. I was thinking the whole time about switches with gauge, don't know why.

comment:15 by gaben, 3 years ago

Original patch with gauge validator with the help of @skyper: josm_21866_track_gauge_with_validator.patch

Changes in validator rule:

  • add comment for warned range
  • exclude gauge from narrow {gauge} as it's an expression, cannot be translated separately
  • reordered rules following node, way, relation order
  • reworded the millimetre suggestion message
Last edited 3 years ago by gaben (previous) (diff)

comment:16 by gaben, 3 years ago

Hm, I'm getting the "unusual gauge value on narrow gauge railway" warning twice, but not with the original version.

Last edited 3 years ago by gaben (previous) (diff)

in reply to:  16 comment:17 by skyper, 3 years ago

Replying to gaben:

Hm, I'm getting the "unusual gauge value on narrow gauge railway" warning twice, but not with the original version.

What kind of values produces two warnings? I have tested with some values and everything seems to be alright.

gauge=1000;1400
gauge=1600
gauge=2''11'
gauge=70;1600
gauge=narrow

comment:18 by gaben, 3 years ago

Now three times, what's going on.

Please tag a new way and see if it works as intended. It may be just my environments...

railway=narrow_gauge
gauge=60

comment:19 by skyper, 3 years ago

I only get one warning like all my examples above. By chance, do you have several local files with identical/similar rules active? Quick info, by hovering over the warning, should give you a hint about the origin of each warning.

Last edited 3 years ago by skyper (previous) (diff)

comment:20 by gaben, 3 years ago

Thanks and sorry for the noise. Yes, there was a copy in the combinations validator file. The popup hint is very useful.

I have 10 different changelist in my IDE, and it's getting harder to maintain.

comment:21 by skyper, 3 years ago

Milestone: 22.02

Nice, ready for commit!

comment:22 by stoecker, 3 years ago

Resolution: fixed
Status: newclosed

In 18385/josm:

fix #21866 - railway gauge improvements - patch by gaben

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.