@Override
    public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way, IntsRef relationFlags) {
        if (isFerry(way)) {
            double ferrySpeed = minmax(getSpeed(way), ferrySpeedEnc);
            ferrySpeedEnc.setDecimal(false, edgeId, edgeIntAccess, ferrySpeed);
        }
    }
@Test
    public void testSpeed() {
        ReaderWay way = new ReaderWay(1);
        way.setTag("route", "ferry");
        way.setTag("edge_distance", 30000.0);
        way.setTag("speed_from_duration", 30 / 0.5);

        EdgeIntAccess edgeIntAccess = new ArrayEdgeIntAccess(1);
        int edgeId = 0;
        calc.handleWayTags(edgeId, edgeIntAccess, way, IntsRef.EMPTY);
        assertEquals(44, ferrySpeedEnc.getDecimal(false, edgeId, edgeIntAccess));

        way = new ReaderWay(1);
        way.setTag("route", "shuttle_train");
        way.setTag("motorcar", "yes");
        way.setTag("bicycle", "no");
        // Provide the duration value in seconds:
        way.setTag("way_distance", 50000.0);
        way.setTag("speed_from_duration", 50 / (35.0 / 60));
        edgeIntAccess = new ArrayEdgeIntAccess(1);
        // calculate speed from tags: speed_from_duration * 1.4 (+ rounded using the speed factor)
        calc.handleWayTags(edgeId, edgeIntAccess, way, IntsRef.EMPTY);
        assertEquals(62, ferrySpeedEnc.getDecimal(false, edgeId, edgeIntAccess));

        // test for very short and slow 0.5km/h still realistic ferry
        way = new ReaderWay(1);
        way.setTag("route", "ferry");
        way.setTag("motorcar", "yes");
        way.setTag("way_distance", 100.0);
        way.setTag("speed_from_duration", 0.1 / (12.0 / 60));

        // we can't store 0.5km/h, but we expect the lowest possible speed
        edgeIntAccess = new ArrayEdgeIntAccess(1);
        calc.handleWayTags(edgeId, edgeIntAccess, way, IntsRef.EMPTY);
        assertEquals(2, ferrySpeedEnc.getDecimal(false, edgeId, edgeIntAccess));

        edgeIntAccess = new ArrayEdgeIntAccess(1);
        ferrySpeedEnc.setDecimal(false, edgeId, edgeIntAccess, 2.5);
        assertEquals(2, ferrySpeedEnc.getDecimal(false, edgeId, edgeIntAccess), 1e-1);

        // test for missing duration
        way = new ReaderWay(1);
        way.setTag("route", "ferry");
        way.setTag("motorcar", "yes");
        way.setTag("edge_distance", 100.0);
        calc.handleWayTags(edgeId, edgeIntAccess, way, IntsRef.EMPTY);
        // we use the unknown speed
        assertEquals(2, ferrySpeedEnc.getDecimal(false, edgeId, edgeIntAccess));
    }