How can I check my route contains toll or not

Hello !
I’m trying to enable toll in encoded_values and check into PathMerger but it’s not work


Please help me ! Thank you

Please try to better explain what you are achieving.

E.g. why not use the toll path detail?

@karussell I found the reason why toll path detail not work in my case.
OSMTollParser only read toll tags. But barrier=toll_booth also is toll. I improve OSMTollParser.java to include my case.

public class OSMTollParser implements TagParser {

private static final List<String> HGV_TAGS = List.of("toll:hgv", "toll:N2", "toll:N3");
private final EnumEncodedValue<Toll> tollEnc;

public OSMTollParser(EnumEncodedValue<Toll> tollEnc) {
    this.tollEnc = tollEnc;
}

@Override
public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay readerWay, IntsRef relationFlags) {
    Toll toll;
    List<Object> nodeTags = readerWay.getTag("node_tags", Collections.emptyList());
    boolean hasToll = nodeTags
            .parallelStream()
            .anyMatch(nodeTag -> nodeTag != null && nodeTag.toString().contains("barrier=toll_booth"));
    if (readerWay.hasTag("toll", "yes") || hasToll) {
        toll = Toll.ALL;
    } else if (readerWay.hasTag(HGV_TAGS, "yes")) {
        toll = Toll.HGV;
    } else if (readerWay.hasTag("toll", "no")) {
        toll = Toll.NO;
    } else {
        toll = Toll.MISSING;
    }

    CountryRule countryRule = readerWay.getTag("country_rule", null);
    if (countryRule != null)
        toll = countryRule.getToll(readerWay, toll);
    tollEnc.setEnum(false, edgeId, edgeIntAccess, toll);
}

}

Can you share a link to the route where you were missing the toll information? The way you handle the toll_booth node tag would only affect single edges that are introduced (?) for nodes with this tag?

yeb. It’s here :smiley:

It looks like the toll booths are mapped as OSM nodes, but the roads that are affected by toll are not. You would need more code to find all the roads between the toll booths. But if all you need is checking if a route crosses a toll node your approach should suffice.