use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testIssue_1256.
@Test
public void testIssue_1256() {
ReaderWay way = new ReaderWay(1);
way.setTag("route", "ferry");
way.setTag("estimated_distance", 257);
CarFlagEncoder lowFactorCar = new CarFlagEncoder(10, 1, 0);
EncodingManager.create(lowFactorCar);
List<EncodedValue> list = new ArrayList<>();
lowFactorCar.setEncodedValueLookup(em);
lowFactorCar.createEncodedValues(list);
assertEquals(2.5, encoder.ferrySpeedCalc.getSpeed(way), .1);
assertEquals(.5, lowFactorCar.ferrySpeedCalc.getSpeed(way), .1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testMilitaryAccess.
@Test
public void testMilitaryAccess() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("access", "military");
assertTrue(encoder.getAccess(way).canSkip());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testSpeed.
@Test
public void testSpeed() {
// limit bigger than default road speed
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "trunk");
way.setTag("maxspeed", "110");
IntsRef edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(100, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "residential");
way.setTag("surface", "cobblestone");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(30, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "track");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(15, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "track");
way.setTag("tracktype", "grade1");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(20, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "secondary");
way.setTag("surface", "compacted");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(30, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "secondary");
way.setTag("motorroad", "yes");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(90, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "motorway");
// this tag should be ignored
way.setTag("motorroad", "yes");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(100, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way.clearTags();
way.setTag("highway", "motorway_link");
// this tag should be ignored
way.setTag("motorroad", "yes");
edgeFlags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(70, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
try {
avSpeedEnc.setDecimal(false, em.createEdgeFlags(), -1);
assertTrue(false);
} catch (IllegalArgumentException ex) {
}
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testMaxValue.
@Test
public void testMaxValue() {
CarFlagEncoder instance = new CarFlagEncoder(10, 0.5, 0);
EncodingManager em = EncodingManager.create(instance);
DecimalEncodedValue avSpeedEnc = em.getDecimalEncodedValue(EncodingManager.getKey(instance, "average_speed"));
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "motorway_link");
way.setTag("maxspeed", "60 mph");
IntsRef edgeFlags = instance.handleWayTags(em.createEdgeFlags(), way);
// double speed = AbstractFlagEncoder.parseSpeed("60 mph");
// => 96.56 * 0.9 => 86.9
assertEquals(86.9, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
assertEquals(86.9, avSpeedEnc.getDecimal(true, edgeFlags), 1e-1);
// test that maxPossibleValue is not exceeded
way = new ReaderWay(2);
way.setTag("highway", "motorway_link");
way.setTag("maxspeed", "70 mph");
edgeFlags = instance.handleWayTags(em.createEdgeFlags(), way);
assertEquals(101.5, avSpeedEnc.getDecimal(false, edgeFlags), .1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testFordAccess.
@Test
public void testFordAccess() {
ReaderNode node = new ReaderNode(0, 0.0, 0.0);
node.setTag("ford", "yes");
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "unclassified");
way.setTag("ford", "yes");
// Node and way are initially blocking
assertTrue(encoder.isBlockFords());
assertTrue(encoder.getAccess(way).canSkip());
assertTrue(encoder.isBarrier(node));
CarFlagEncoder tmpEncoder = new CarFlagEncoder(new PMap("block_fords=false"));
EncodingManager.create(tmpEncoder);
assertTrue(tmpEncoder.getAccess(way).isWay());
assertFalse(tmpEncoder.isBarrier(node));
}
Aggregations