diff --git a/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java b/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java index 7abb99df35e..d75a4e3d1df 100644 --- a/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java +++ b/core/src/main/java/com/graphhopper/routing/util/parsers/BikeCommonAverageSpeedParser.java @@ -119,8 +119,6 @@ protected BikeCommonAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncoded */ double applyMaxSpeed(ReaderWay way, double speed, boolean bwd) { double maxSpeed = getMaxSpeed(way, bwd); - if (way.getTag("highway", "").equals("living_street")) - return !isValidSpeed(maxSpeed) ? highwaySpeeds.get("living_street") : maxSpeed <= highwaySpeeds.get("cycleway") ? maxSpeed : highwaySpeeds.get("cycleway"); // We strictly obey speed limits, see #600 return isValidSpeed(maxSpeed) && speed > maxSpeed ? maxSpeed : speed; } @@ -140,12 +138,8 @@ public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way } double speed = highwaySpeeds.getOrDefault(highwayValue, PUSHING_SECTION_SPEED); - String surfaceValue = way.getTag("surface"); - String trackTypeValue = way.getTag("tracktype"); boolean pushingRestriction = Arrays.stream(way.getTag("vehicle", "").split(";")).anyMatch(restrictedValues::contains); - if ("steps".equals(highwayValue)) { - // ignore - } else if (way.hasTag("bicycle", "dismount") + if (way.hasTag("bicycle", "dismount") || way.hasTag("railway", "platform") || pushingRestriction && !way.hasTag("bicycle", INTENDED)) { speed = PUSHING_SECTION_SPEED; @@ -156,8 +150,13 @@ public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way else if (way.hasTag("bicycle", "yes")) speed = 12; } + // Increase speed in case maxspeed tag allows it + double maxSpeed = getMaxSpeed(way, false); + if (isValidSpeed(maxSpeed) && (speed < maxSpeed)) + speed = Math.min(maxSpeed, highwaySpeeds.get("tertiary")); - Integer surfaceSpeed = surfaceSpeeds.get(surfaceValue); + Integer surfaceSpeed = surfaceSpeeds.get(way.getTag("surface")); + String trackTypeValue = way.getTag("tracktype"); if (way.hasTag("surface") && surfaceSpeed == null) { speed = PUSHING_SECTION_SPEED; // unknown surface } else if (way.hasTag("service")) { @@ -173,6 +172,8 @@ else if (trackTypeSpeeds.containsKey(trackTypeValue)) Smoothness smoothness = smoothnessEnc.getEnum(false, edgeId, edgeIntAccess); speed = Math.max(MIN_SPEED, smoothnessFactor.get(smoothness) * speed); + if ("steps".equals(highwayValue)) + speed = MIN_SPEED; setSpeed(false, edgeId, edgeIntAccess, applyMaxSpeed(way, speed, false)); if (avgSpeedEnc.isStoreTwoDirections()) setSpeed(true, edgeId, edgeIntAccess, applyMaxSpeed(way, speed, true)); diff --git a/core/src/main/java/com/graphhopper/routing/util/parsers/RacingBikeAverageSpeedParser.java b/core/src/main/java/com/graphhopper/routing/util/parsers/RacingBikeAverageSpeedParser.java index dabc0f82aba..923ffcf63e1 100644 --- a/core/src/main/java/com/graphhopper/routing/util/parsers/RacingBikeAverageSpeedParser.java +++ b/core/src/main/java/com/graphhopper/routing/util/parsers/RacingBikeAverageSpeedParser.java @@ -53,6 +53,8 @@ protected RacingBikeAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncoded setHighwaySpeed("secondary_link", 20); setHighwaySpeed("tertiary", 20); setHighwaySpeed("tertiary_link", 20); + setHighwaySpeed("motorway", 20); + setHighwaySpeed("motorway_link", 20); addPushingSection("path"); diff --git a/core/src/test/java/com/graphhopper/GraphHopperTest.java b/core/src/test/java/com/graphhopper/GraphHopperTest.java index c196e5a57a2..c70dbfdef19 100644 --- a/core/src/test/java/com/graphhopper/GraphHopperTest.java +++ b/core/src/test/java/com/graphhopper/GraphHopperTest.java @@ -455,7 +455,7 @@ public void testAlternativeRoutesBike() { setProfiles(TestProfiles.accessSpeedAndPriority(profile, "bike")); hopper.importOrLoad(); - GHRequest req = new GHRequest(50.028917, 11.496506, 49.982089,11.599224). + GHRequest req = new GHRequest(50.028917, 11.496506, 49.982862, 11.598022). setAlgorithm(ALT_ROUTE).setProfile(profile); req.putHint("alternative_route.max_paths", 3); @@ -464,11 +464,11 @@ public void testAlternativeRoutesBike() { assertEquals(3, rsp.getAll().size()); // via ramsenthal - assertEquals(2636, rsp.getAll().get(0).getTime() / 1000); + assertEquals(2603, rsp.getAll().get(0).getTime() / 1000); + // via eselslohe -> theta; + assertEquals(2694, rsp.getAll().get(1).getTime() / 1000); // via unterwaiz - assertEquals(2985, rsp.getAll().get(1).getTime() / 1000); - // via eselslohe -> theta; BTW: here smaller time as 2nd alternative due to priority influences time order - assertEquals(2783, rsp.getAll().get(2).getTime() / 1000); + assertEquals(2957, rsp.getAll().get(2).getTime() / 1000); } @Test diff --git a/core/src/test/java/com/graphhopper/routing/RoutingAlgorithmWithOSMTest.java b/core/src/test/java/com/graphhopper/routing/RoutingAlgorithmWithOSMTest.java index 38c85a88c65..34148e956a0 100644 --- a/core/src/test/java/com/graphhopper/routing/RoutingAlgorithmWithOSMTest.java +++ b/core/src/test/java/com/graphhopper/routing/RoutingAlgorithmWithOSMTest.java @@ -463,7 +463,7 @@ public void testKremsBikeRelation() { @Test public void testKremsMountainBikeRelation() { List queries = new ArrayList<>(); - queries.add(new Query(48.409523, 15.602394, 48.375466, 15.72916, 12574, 169)); + queries.add(new Query(48.409523, 15.602394, 48.375466, 15.72916, 12493, 159)); queries.add(new Query(48.410061, 15.63951, 48.411386, 15.604899, 3101, 94)); queries.add(new Query(48.412294, 15.62007, 48.398306, 15.609667, 3965, 95)); diff --git a/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java b/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java index 1d2f3fb7aa9..23103310a05 100644 --- a/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java +++ b/core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java @@ -83,6 +83,14 @@ public void testSpeedAndPriority() { assertPriorityAndSpeed(PREFER, 18, way); way.setTag("maxspeed", "10"); assertPriorityAndSpeed(VERY_NICE, 10, way); + way.setTag("maxspeed", "20"); + way.setTag("surface", "sett"); + assertPriorityAndSpeed(PREFER, 10, way); + + way.clearTags(); + way.setTag("highway", "service"); + way.setTag("maxspeed", "20"); + assertPriorityAndSpeed(PREFER, 18, way); // Pushing section: this is fine as we obey the law! way.clearTags(); @@ -249,7 +257,7 @@ public void testSpeedAndPriority() { way.setTag("highway", "steps"); way.setTag("surface", "wood"); assertPriorityAndSpeed(BAD, MIN_SPEED, way); - way.setTag("maxspeed", "20"); + way.setTag("maxspeed", "20"); // senseless but rare combination assertPriorityAndSpeed(BAD, MIN_SPEED, way); way.clearTags(); @@ -580,7 +588,7 @@ public void testMaxSpeed() { way = new ReaderWay(1); way.setTag("highway", "track"); way.setTag("maxspeed", "90"); - assertPriorityAndSpeed(UNCHANGED, 12, way); + assertPriorityAndSpeed(UNCHANGED, 18, way); // here we are limited by the maxspeed way = new ReaderWay(1); diff --git a/core/src/test/java/com/graphhopper/routing/util/parsers/RacingBikeTagParserTest.java b/core/src/test/java/com/graphhopper/routing/util/parsers/RacingBikeTagParserTest.java index a0d19920dd1..514fb552b16 100644 --- a/core/src/test/java/com/graphhopper/routing/util/parsers/RacingBikeTagParserTest.java +++ b/core/src/test/java/com/graphhopper/routing/util/parsers/RacingBikeTagParserTest.java @@ -92,13 +92,13 @@ public void testLivingStreet() { osmWay.setTag("highway", "living_street"); assertPriorityAndSpeed(UNCHANGED, 6, osmWay); osmWay.setTag("maxspeed", "20"); - assertPriorityAndSpeed(PREFER, 18, osmWay); + assertPriorityAndSpeed(VERY_NICE, 20, osmWay); osmWay.setTag("maxspeed", "10"); assertPriorityAndSpeed(VERY_NICE, 10, osmWay); osmWay.clearTags(); osmWay.setTag("highway", "residential"); osmWay.setTag("maxspeed", "30"); - assertPriorityAndSpeed(SLIGHT_AVOID, 18, osmWay); + assertPriorityAndSpeed(SLIGHT_AVOID, 20, osmWay); } @Test @@ -107,9 +107,6 @@ public void testService() { ReaderWay way = new ReaderWay(1); way.setTag("highway", "service"); assertPriorityAndSpeed(SLIGHT_AVOID, 12, way); - - way.setTag("service", "parking_aisle"); - assertPriorityAndSpeed(SLIGHT_AVOID, 6, way); } @Test @@ -291,33 +288,36 @@ public void testPriority_avoidanceOfHighMaxSpeed() { assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, UNCHANGED, 20, osmWay); osmWay.setTag("highway", "motorway"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, BAD, 18, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, BAD, 20, osmWay); osmWay.setTag("tunnel", "yes"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 18, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 20, osmWay); + + osmWay.setTag("surface", "cobblestone"); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 8, osmWay); osmWay.clearTags(); osmWay.setTag("highway", "motorway"); osmWay.setTag("tunnel", "yes"); osmWay.setTag("maxspeed", "80"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 18, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 20, osmWay); osmWay.clearTags(); osmWay.setTag("highway", "motorway"); osmWay.setTag("tunnel", "yes"); osmWay.setTag("maxspeed", "120"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 18, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, REACH_DESTINATION, 20, osmWay); osmWay.clearTags(); osmWay.setTag("highway", "notdefined"); osmWay.setTag("tunnel", "yes"); osmWay.setTag("maxspeed", "120"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, BAD, PUSHING_SECTION_SPEED, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, BAD, 20, osmWay); osmWay.clearTags(); osmWay.setTag("highway", "notdefined"); osmWay.setTag("maxspeed", "50"); - assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, UNCHANGED, PUSHING_SECTION_SPEED, osmWay); + assertPriorityAndSpeed(encodingManager, priorityEnc, speedEnc, parsers, UNCHANGED, 20, osmWay); } private void assertPriorityAndSpeed(EncodingManager encodingManager, DecimalEncodedValue priorityEnc, DecimalEncodedValue speedEnc,