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)
Change History (26)
by , 3 years ago
Attachment: | track_gauge.patch added |
---|
comment:1 by , 3 years ago
Component: | Core validator → Internal preset |
---|
comment:2 by , 3 years ago
comment:3 by , 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
Did you plan any validation?
comment:4 by , 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 , 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?
follow-up: 7 comment:6 by , 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.
comment:7 by , 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"; }
comment:8 by , 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 , 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 , 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.
follow-up: 12 comment:11 by , 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.
follow-up: 14 comment:12 by , 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 , 3 years ago
Attachment: | josm_21866_numeric_v2.patch added |
---|
version 2: fix typo in article and add type=route for relations
comment:14 by , 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.
by , 3 years ago
Attachment: | josm_21866_track_gauge_with_validator.patch added |
---|
comment:15 by , 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
follow-up: 17 comment:16 by , 3 years ago
Hm, I'm getting the "unusual gauge value on narrow gauge railway"
warning twice, but not with the original version.
comment:17 by , 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 , 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 , 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.
comment:20 by , 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.
And there are much more (see https://de.wikipedia.org/wiki/Liste_der_Spurweiten), but I think the patch covers the mostly used values.