@@ -0,0 +1,2786 @@
+/*%0A *  Licensed to GraphHopper GmbH under one or more contributor%0A *  license agreements. See the NOTICE file distributed with this work for%0A *  additional information regarding copyright ownership.%0A *%0A *  GraphHopper GmbH licenses this file to you under the Apache License,%0A *  Version 2.0 (the %22License%22); you may not use this file except in%0A *  compliance with the License. You may obtain a copy of the License at%0A *%0A *       http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A%0Apackage com.graphhopper.routing.util;%0A%0Aimport com.graphhopper.reader.ReaderWay;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;%0A%0Aclass FerrySpeedCalculatorTest %7B%0A%0A    @Test%0A    void testSpeed() %7B%0A        double speedFactor = 2;%0A        double maxSpeed = 55;%0A        double longSpeed = 30;%0A        double shortSpeed = 20;%0A        double unknownSpeed = 5;%0A        FerrySpeedCalculator c = new FerrySpeedCalculator(speedFactor, maxSpeed, longSpeed, shortSpeed, unknownSpeed);%0A%0A        // no distance -%3E speed only depends on duration (distinguish between missing/short/long duration)%0A        checkSpeed(c, null, null, unknownSpeed);%0A        checkSpeed(c, %220%22, null, unknownSpeed);%0A        checkSpeed(c, %221800%22, null, shortSpeed);%0A        checkSpeed(c, %227200%22, null, longSpeed);%0A        // no duration -%3E speed depends on distance%0A        checkSpeed(c, null, 100.0, speedFactor / 2);%0A        checkSpeed(c, %220%22, 100.0, speedFactor / 2);%0A        checkSpeed(c, null, 1000.0, unknownSpeed);%0A        checkSpeed(c, %220%22, 1000.0, unknownSpeed);%0A%0A        // valid%0A        checkSpeed(c, %223600%22, 30000.0, Math.round(30 / 1.4));%0A        checkSpeed(c, %227200%22, 30000.0, Math.round(15 / 1.4));%0A        // above max (capped to max)%0A        checkSpeed(c, %223600%22, 90000.0, maxSpeed);%0A        // below smallest storable non-zero value%0A        checkSpeed(c, %227200%22, 1000.0, speedFactor / 2);%0A%0A        // suspicious slow speed (still depends on distance)%0A        checkSpeed(c, %22180000%22, 100.0, speedFactor / 2);%0A        checkSpeed(c, %221800000%22, 1000.0, unknownSpeed);%0A    %7D%0A%0A    private void checkSpeed(FerrySpeedCalculator calc, String duration, Double distance, double expected) %7B%0A        ReaderWay way = new ReaderWay(0L);%0A        if (duration != null)%0A            way.setTag(%22duration:seconds%22, duration);%0A        if (distance != null)%0A            way.setTag(%22estimated_distance%22, distance);%0A        assertEquals(expected, calc.getSpeed(way));%0A    %7D%0A%0A%7D

Add FerrySpeedCalculatorTest