use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testPrivateTag.
@Test
public void testPrivateTag() {
// allow private access
CarFlagEncoder carEncoder = new CarFlagEncoder(new PMap("block_private=false"));
FlagEncoder bikeEncoder = new BikeFlagEncoder(new PMap("block_private=false"));
EncodingManager em = new EncodingManager.Builder().add(carEncoder).add(bikeEncoder).build();
FastestWeighting weighting = new FastestWeighting(carEncoder);
FastestWeighting bikeWeighting = new FastestWeighting(bikeEncoder);
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "secondary");
assertNotEquals(EncodingManager.Access.CAN_SKIP, carEncoder.getAccess(way));
IntsRef edgeFlags = em.handleWayTags(way, em.createRelationFlags());
assertEquals(60, weighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
assertEquals(200, bikeWeighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
way.setTag("highway", "secondary");
way.setTag("access", "private");
assertNotEquals(EncodingManager.Access.CAN_SKIP, carEncoder.getAccess(way));
edgeFlags = em.handleWayTags(way, em.createRelationFlags());
assertEquals(600, weighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
// private should influence bike only slightly
assertEquals(240, bikeWeighting.calcEdgeWeight(GHUtility.createMockedEdgeIteratorState(1000, edgeFlags), false), 0.1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testOneway.
@Test
public void testOneway() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
IntsRef flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertTrue(accessEnc.getBool(false, flags));
assertTrue(accessEnc.getBool(true, flags));
way.setTag("oneway", "yes");
flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertTrue(accessEnc.getBool(false, flags));
assertFalse(accessEnc.getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertTrue(accessEnc.getBool(false, flags));
assertTrue(accessEnc.getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("vehicle:forward", "no");
flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertFalse(accessEnc.getBool(false, flags));
assertTrue(accessEnc.getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("vehicle:backward", "no");
flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertTrue(accessEnc.getBool(false, flags));
assertFalse(accessEnc.getBool(true, flags));
way.clearTags();
// This is no one way
way.setTag("highway", "tertiary");
way.setTag("vehicle:backward", "designated");
flags = encoder.handleWayTags(em.createEdgeFlags(), way);
assertTrue(accessEnc.getBool(false, flags));
assertTrue(accessEnc.getBool(true, flags));
way.clearTags();
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class CarFlagEncoderTest method testMaxSpeed.
@Test
public void testMaxSpeed() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "trunk");
way.setTag("maxspeed", "500");
IntsRef relFlags = em.createRelationFlags();
IntsRef edgeFlags = em.handleWayTags(way, relFlags);
assertEquals(140, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("maxspeed:backward", "10");
way.setTag("maxspeed:forward", "20");
edgeFlags = em.handleWayTags(way, relFlags);
assertEquals(10, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("maxspeed:forward", "20");
edgeFlags = em.handleWayTags(way, relFlags);
assertEquals(20, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("maxspeed:backward", "20");
edgeFlags = em.handleWayTags(way, relFlags);
assertEquals(20, avSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
way = new ReaderWay(1);
way.setTag("highway", "motorway");
way.setTag("maxspeed", "none");
edgeFlags = em.handleWayTags(way, relFlags);
assertEquals(135, avSpeedEnc.getDecimal(false, edgeFlags), .1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testMixSpeedAndSafe.
@Test
public void testMixSpeedAndSafe() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "motorway");
IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(0, flags.ints[0]);
way.setTag("sidewalk", "yes");
flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(5, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
way.clearTags();
way.setTag("highway", "track");
flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(5, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testFerrySpeed.
@Test
public void testFerrySpeed() {
ReaderWay way = new ReaderWay(1);
way.setTag("route", "ferry");
// a bit longer than an hour
way.setTag("duration:seconds", "4000");
assertEquals(30, footEncoder.ferrySpeedCalc.getSpeed(way), .1);
IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(15, footAvgSpeedEnc.getDecimal(false, flags), .1);
}
Aggregations