hiddewie / OpenRailwayMap-vector

OpenRailwayMap vector tiles
https://openrailwaymap.fly.dev
GNU General Public License v3.0
8 stars 1 forks source link

Displaying track class #103

Open wolfy1339 opened 2 months ago

wolfy1339 commented 2 months ago

This is another (mostly) North American tag for railways

In North America, track classes is a system of classification for track quality. The class of a section of track determines the maximum possible running speed limits.

In Europe, it is the class of axle load and metre load as of the EN15528 directive.

https://wiki.openstreetmap.org/wiki/Key:railway:track_class

In our North American rail tagging, tagging the track class can replace tagging the maxspeed. Since the speeds associated with track classes are not consistent across North America, a 1:1 conversion of track class to max speed needs to be done using lookup tables, which could be done by leveraging lua.

Based on the way's centroid and predefined BBOXes per-country we could map the track class to maxspeed.

I want to make sure that this approach is reasonable and would be okay

wolfy1339 commented 2 months ago

OSM2PGSQL doesn't expose any coordinates in Lua unfortunately, so processing can't happen in the lua import file

hiddewie commented 2 months ago

Since the speeds associated with track classes are not consistent across North America, a 1:1 conversion of track class to max speed needs to be done using lookup tables, which could be done by leveraging lua.

We could define a lookup table in Postgres with country polygons, either statically / hardcoded or from some official source.

That could give all features on the map a country code. Indeed Lua could not process that unfortunately.

One thing that crosses my mind is that there can be cross-border track segments which still use signalling / speed limits of the neighboring country. Those cannot be determined automatically from country polygons.

... we could map the track class to maxspeed.

Reading https://wiki.openstreetmap.org/wiki/Key:railway:track_class#Track_class_in_the_USA_and_Canada, and the wiki page, you would also need railway:traffic_mode tagged on the railway line.

Viewing https://taginfo.geofabrik.de/north-america:us/keys/railway:track_class#combinations and https://taginfo.openstreetmap.org/keys/railway:track_class#combinations shows ~47% have both tags globally, but only 2% in the US.

And for the tracks with mixed traffic mode, do we use the smallest or largest value?

Based on the way's centroid and predefined BBOXes per-country we could map the track class to maxspeed.

Comparing the table for the US and Canada, it seems only class 5 for passenger trains has a different max speed value.

It looks feasible to assume them the same and avoid a lot of complexity.

Also https://taginfo.openstreetmap.org/keys/railway:track_class#map shows almost only track_class mapping in the US, almost nothing in Canada. So using the US max speed value for class 5 rail for passenger trains seems sensible.


So from my point of view:

wolfy1339 commented 2 months ago

One thing that crosses my mind is that there can be cross-border track segments which still use signalling / speed limits of the neighboring country. Those cannot be determined automatically from country polygons.

Of course those segments are exceptions. It would be hard to discern them to the proper country.

Reading https://wiki.openstreetmap.org/wiki/Key:railway:track_class#Track_class_in_the_USA_and_Canada, and the wiki page, you would also need railway:traffic_mode tagged on the railway line.

I agree with that. I have made an edit to the wiki to reflect that

And for the tracks with mixed traffic mode, do we use the smallest or largest value?

As freight traffic is predominant compared to passenger traffic, it could be safe to assume that freight traffic would be what is most likely expected. This would require consultations with the community to be certain.

Of course, both values could be added to the info popup

Comparing the table for the US and Canada, it seems only class 5 for passenger trains has a different max speed value.

It looks feasible to assume them the same and avoid a lot of complexity.

Also https://taginfo.openstreetmap.org/keys/railway:track_class#map shows almost only track_class mapping in the US, almost nothing in Canada. So using the US max speed value for class 5 rail for passenger trains seems sensible.

There are a lot more mappers down in the US compared to Canada. The information isn't always easy to find, nor available to the public.

Assuming the same values up to Class 4 sounds good as to simplify things. I'm not so sure as to how to handle Class 5 for passenger traffic.


Importing country polygons can be useful, but it also seems like a complex solution to automatically determine information. I do see the value, also for filtering the legend in view in the UI to only show the country currently visible on the map.

Given that European usages of the tag are a letter and number combination, it would be safe to assume that any value which is only a number has to be either the US or Canada.

We can also assume that classes 1-4 are the same values. Class 5+ would require more thought

claysmalley commented 2 months ago

In our North American rail tagging, tagging the track class can replace tagging the maxspeed.

This is not entirely the case. Tight curve radii, among other factors, often lower a track segment's speed limit below the maximum dictated by its class.

wolfy1339 commented 2 months ago

Thanks for that precision.

Yes, A tagged maxspeed should definitely always take precedence over the maxspeed defined by the track class