@Override public double getSpeed(long flags) { double speed = super.getSpeed(flags); if (speed == getMaxSpeed()) { // We cannot be sure if it was a long or a short trip return SHORT_TRIP_FERRY_SPEED; } return speed; } }
/** * @param weightToPrioMap associate a weight with every priority. This sorted map allows * subclasses to 'insert' more important priorities as well as overwrite determined priorities. */ void collect(ReaderWay way, TreeMap<Double, Integer> weightToPrioMap) { String highway = way.getTag("highway"); if (way.hasTag("foot", "designated")) weightToPrioMap.put(100d, PREFER.getValue()); double maxSpeed = getMaxSpeed(way); if (safeHighwayTags.contains(highway) || maxSpeed > 0 && maxSpeed <= 20) { weightToPrioMap.put(40d, PREFER.getValue()); if (way.hasTag("tunnel", intendedValues)) { if (way.hasTag("sidewalk", sidewalksNoValues)) weightToPrioMap.put(40d, AVOID_IF_POSSIBLE.getValue()); else weightToPrioMap.put(40d, UNCHANGED.getValue()); } } else if (maxSpeed > 50 || avoidHighwayTags.contains(highway)) { if (!way.hasTag("sidewalk", sidewalkValues)) weightToPrioMap.put(45d, AVOID_IF_POSSIBLE.getValue()); } if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated")) weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue()); }
@Test public void testFerrySpeed() { ReaderWay way = new ReaderWay(1); way.setTag("route", "ferry"); // a bit longer than an hour way.setTag("duration:seconds", "4000"); long flags = footEncoder.handleWayTags(way, footEncoder.acceptWay(way), 0); assertTrue(footEncoder.getSpeed(flags) > footEncoder.getMaxSpeed()); assertEquals(20, footEncoder.getSpeed(flags), .1); }
@Override public double getSpeed(long flags) { double speed = super.getSpeed(flags); if (speed == getMaxSpeed()) { // We cannot be sure if it was a long or a short trip return SHORT_TRIP_FERRY_SPEED; } return speed; } }
/** * @param weightToPrioMap associate a weight with every priority. This sorted map allows * subclasses to 'insert' more important priorities as well as overwrite determined priorities. */ void collect(ReaderWay way, TreeMap<Double, Integer> weightToPrioMap) { String highway = way.getTag("highway"); if (way.hasTag("foot", "designated")) weightToPrioMap.put(100d, PREFER.getValue()); double maxSpeed = getMaxSpeed(way); if (safeHighwayTags.contains(highway) || maxSpeed > 0 && maxSpeed <= 20) { weightToPrioMap.put(40d, PREFER.getValue()); if (way.hasTag("tunnel", intendedValues)) { if (way.hasTag("sidewalk", sidewalksNoValues)) weightToPrioMap.put(40d, AVOID_IF_POSSIBLE.getValue()); else weightToPrioMap.put(40d, UNCHANGED.getValue()); } } else if (maxSpeed > 50 || avoidHighwayTags.contains(highway)) { if (!way.hasTag("sidewalk", sidewalkValues)) weightToPrioMap.put(45d, AVOID_IF_POSSIBLE.getValue()); } if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated")) weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue()); }
/** * @param weightToPrioMap associate a weight with every priority. This sorted map allows * subclasses to 'insert' more important priorities as well as overwrite determined priorities. */ void collect( OSMWay way, TreeMap<Double, Integer> weightToPrioMap ) { String highway = way.getTag("highway"); if (way.hasTag("foot", "designated")) weightToPrioMap.put(100d, PREFER.getValue()); double maxSpeed = getMaxSpeed(way); if (safeHighwayTags.contains(highway) || maxSpeed > 0 && maxSpeed <= 20) { weightToPrioMap.put(40d, PREFER.getValue()); if (way.hasTag("tunnel", intendedValues)) { if (way.hasTag("sidewalk", sidewalksNoValues)) weightToPrioMap.put(40d, AVOID_IF_POSSIBLE.getValue()); else weightToPrioMap.put(40d, UNCHANGED.getValue()); } } else if (maxSpeed > 50 || avoidHighwayTags.contains(highway)) { if (!way.hasTag("sidewalk", sidewalkValues)) weightToPrioMap.put(45d, AVOID_IF_POSSIBLE.getValue()); } if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated")) weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue()); }
/** * @param weightToPrioMap associate a weight with every priority. This sorted map allows * subclasses to 'insert' more important priorities as well as overwrite determined priorities. */ void collect(ReaderWay way, TreeMap<Double, Integer> weightToPrioMap) { String highway = way.getTag("highway"); if (way.hasTag("foot", "designated")) weightToPrioMap.put(100d, PREFER.getValue()); double maxSpeed = getMaxSpeed(way); if (safeHighwayTags.contains(highway) || maxSpeed > 0 && maxSpeed <= 20) { weightToPrioMap.put(40d, PREFER.getValue()); if (way.hasTag("tunnel", intendedValues)) { if (way.hasTag("sidewalk", sidewalksNoValues)) weightToPrioMap.put(40d, AVOID_IF_POSSIBLE.getValue()); else weightToPrioMap.put(40d, UNCHANGED.getValue()); } } else if (maxSpeed > 50 || avoidHighwayTags.contains(highway)) { if (!way.hasTag("sidewalk", sidewalkValues)) weightToPrioMap.put(45d, AVOID_IF_POSSIBLE.getValue()); } if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated")) weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue()); }