use of com.graphhopper.storage.IntsRef 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.storage.IntsRef 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.storage.IntsRef 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.storage.IntsRef 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);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class BooleanEncodedValueTest method testBitDirected.
@Test
public void testBitDirected() {
EncodedValue.InitializerConfig config = new EncodedValue.InitializerConfig();
BooleanEncodedValue bool = new SimpleBooleanEncodedValue("access", true);
bool.init(config);
IntsRef ref = new IntsRef(1);
bool.setBool(false, ref, false);
bool.setBool(true, ref, true);
assertFalse(bool.getBool(false, ref));
assertTrue(bool.getBool(true, ref));
}
Aggregations