Opened 5 years ago

Last modified 18 months ago

#16828 new enhancement

Validator does not catch PT2 relations routing along highway=construction

Reported by: pangoSE Owned by: Biswesh
Priority: normal Milestone:
Component: Plugin pt_assistant Version:
Keywords: road route Cc: Polyglot

Description (last modified by Don-vip)

OSMI catches this see example below:

layer: ptv2_error_ways
rel_id: 3307051
way_id: 32463486
node_id: 0
error: road vehicle route over non-road
ref: 25
name: Buss 25: Stadsparken => Ankaret
route: bus,ptv2_error_,ptv2_error_ways,ptv2_error_nodes

Attachments (1)

16828.PNG (142.4 KB ) - added by Don-vip 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Don-vip, 5 years ago

Type: defectenhancement

by Don-vip, 5 years ago

Attachment: 16828.PNG added

comment:2 by Don-vip, 5 years ago

Description: modified (diff)
Keywords: road route added

comment:3 by Don-vip, 5 years ago

OSMI source code:

RouteError PTv2Checker::is_way_usable(const osmium::Relation& relation, RouteType type, const osmium::Way* way) {
    switch (type) {
    case RouteType::TRAIN:
    case RouteType::TRAM:
    case RouteType::SUBWAY:
        if (!check_valid_railway_track(type, way->tags())) {
            m_writer.write_error_way(relation, 0, "rail-guided route over non-rail", way);
            return RouteError::OVER_NON_RAIL;

    case RouteType::BUS:
        if (!check_valid_road_way(way->tags())) {
            m_writer.write_error_way(relation, 0, "road vehicle route over non-road", way);
            return RouteError::OVER_NON_ROAD;
    case RouteType::TROLLEYBUS:
        if (!check_valid_trolleybus_way(way->tags())) {
            m_writer.write_error_way(relation, 0, "trolley bus without trolley wire", way);
            return RouteError::NO_TROLLEY_WIRE;
    case RouteType::FERRY:
        if (!is_ferry(way->tags(), true)) {
            m_writer.write_error_way(relation, 0, "trolley bus without trolley wire", way);
            return RouteError::NO_FERRY;
        return RouteError::CLEAN;
    return RouteError::CLEAN;

bool PTv2Checker::check_valid_railway_track(RouteType type, const osmium::TagList& member_tags) {
    const char* railway = member_tags.get_value_by_key("railway");
    if (!railway) {
        return is_ferry(member_tags);
    if (type == RouteType::TRAIN || type == RouteType::TRAM) {
        if (!strcmp(railway, "rail") || !strcmp(railway, "light_rail") || !strcmp(railway, "tram") || !strcmp(railway, "subway")
                || !strcmp(railway, "funicular") || !strcmp(railway, "preserved") || !strcmp(railway, "miniature") || !strcmp(railway, "narrow_gauge")) {
            return true;
    if (type == RouteType::SUBWAY) {
            return true;
    return is_ferry(member_tags);

bool PTv2Checker::check_valid_road_way(const osmium::TagList& member_tags) {
    const char* highway = member_tags.get_value_by_key("highway");
    if (!highway) {
        return is_ferry(member_tags);
    return (!strcmp(highway, "motorway") || !strcmp(highway, "motorway_link") || !strcmp(highway, "trunk")
        || !strcmp(highway, "trunk_link") || !strcmp(highway, "primary") || !strcmp(highway, "primary_link")
        || !strcmp(highway, "secondary") || !strcmp(highway, "secondary_link") || !strcmp(highway, "tertiary")
        || !strcmp(highway, "tertiary_link") || !strcmp(highway, "unclassified") || !strcmp(highway, "residential")
        || !strcmp(highway, "service") || !strcmp(highway, "track") || !strcmp(highway, "pedestrian")
        || !strcmp(highway, "living_street"));

bool PTv2Checker::check_valid_trolleybus_way(const osmium::TagList& member_tags) {
    if (member_tags.has_tag("trolley_wire", "yes")) {
        return check_valid_road_way(member_tags);
    //TODO check direction (forward wire but using the way in opposite direction might cause problems ;-)
    if (member_tags.has_tag("trolley_wire:forward", "yes") || member_tags.has_tag("trolley_wire", "forward")) {
        return check_valid_road_way(member_tags);
    return (member_tags.has_tag("trolley_wire:backward", "yes") || member_tags.has_tag("trolley_wire", "backward"))
            && check_valid_road_way(member_tags);

bool PTv2Checker::is_ferry(const osmium::TagList& member_tags, bool permit_untagged_ways /* = false */) {
    const char* route = member_tags.get_value_by_key("route");
    return (route && !strcmp(route, "ferry")) || (permit_untagged_ways && !route);

comment:4 by Don-vip, 5 years ago

It might be already provided by pt_assistant plugin, osmwiki:JOSM/Plugins/PT_Assistant

comment:5 by Don-vip, 5 years ago

Component: Core validatorPlugin pt_assistant
Owner: changed from team to Biswesh

Doesn't work, but it's clearly in plugin scope.

comment:6 by pangoSE, 5 years ago

I had it installed when i reported.
I would like it in the core validator so people are warned on upload after unintentionally breaking PT relations. (there are a LOT of broken PT relations worldwide ATM)

comment:7 by Don-vip, 5 years ago

Cc: Polyglot added

We won't add some PTv2 checks in core while there is an actively developed plugin with many checks dedicated to that. Maybe later the plugin will be included to core, but it must be stabilized/cleaned up first.

If you want to help on this topic, please make contact with Polyglot.

comment:8 by skyper, 18 months ago

I get an informal warning from pt_assistant about using highway=construction. Do not know if it is new or if users missed to enable informal warnings.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Biswesh.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from Biswesh to the specified user.
Next status will be 'needinfo'. The owner will be changed from Biswesh to pangoSE.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from Biswesh to anonymous. Next status will be 'assigned'.

Add Comment

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