@Override
    public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay readerWay, IntsRef relationFlags) {
        RoadEnvironment roadEnvironment = OTHER;
        if (FerrySpeedCalculator.isFerry(readerWay))
            roadEnvironment = FERRY;
        else if (readerWay.hasTag("bridge") && !readerWay.hasTag("bridge", "no"))
            roadEnvironment = BRIDGE;
        else if (readerWay.hasTag("tunnel") && !readerWay.hasTag("tunnel", "no"))
            roadEnvironment = TUNNEL;
        else if (readerWay.hasTag("ford") || readerWay.hasTag("highway", "ford"))
            roadEnvironment = FORD;
        else {
            List<Map<String, Object>> nodeTags = readerWay.getTag("node_tags", Collections.emptyList());
            // a barrier edge has the restriction in both nodes and the tags are the same
            if (readerWay.hasTag("gh:barrier_edge") && nodeTags.get(0).containsKey("ford"))
                roadEnvironment = FORD;
            else if (readerWay.hasTag("highway"))
                roadEnvironment = ROAD;
        }

        if (roadEnvironment != OTHER)
            roadEnvEnc.setEnum(false, edgeId, edgeIntAccess, roadEnvironment);
    }
@Test
    void ferry() {
        EnumEncodedValue<RoadEnvironment> roadEnvironmentEnc = RoadEnvironment.create();
        roadEnvironmentEnc.init(new EncodedValue.InitializerConfig());
        OSMRoadEnvironmentParser parser = new OSMRoadEnvironmentParser(roadEnvironmentEnc);
        EdgeIntAccess edgeIntAccess = new ArrayEdgeIntAccess(1);
        int edgeId = 0;
        ReaderWay way = new ReaderWay(0);
        way.setTag("route", "shuttle_train");
        parser.handleWayTags(edgeId, edgeIntAccess, way, new IntsRef(2));
        RoadEnvironment roadEnvironment = roadEnvironmentEnc.getEnum(false, edgeId, edgeIntAccess);
        assertEquals(RoadEnvironment.FERRY, roadEnvironment);

        way = new ReaderWay(1);
        way.setTag("highway", "footway");
        way.setTag("route", "ferry");
        parser.handleWayTags(edgeId, edgeIntAccess = new ArrayEdgeIntAccess(1), way, new IntsRef(2));
        roadEnvironment = roadEnvironmentEnc.getEnum(false, edgeId, edgeIntAccess);
        assertEquals(RoadEnvironment.FERRY, roadEnvironment);
    }