use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class EncodingManagerTest method testSharedEncodedValues.
@Test
public void testSharedEncodedValues() {
EncodingManager manager = EncodingManager.create("car,foot,bike,motorcycle,mtb");
for (FlagEncoder tmp : manager.fetchEdgeEncoders()) {
AbstractFlagEncoder encoder = (AbstractFlagEncoder) tmp;
BooleanEncodedValue accessEnc = encoder.getAccessEnc();
BooleanEncodedValue roundaboutEnc = manager.getBooleanEncodedValue(Roundabout.KEY);
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("junction", "roundabout");
IntsRef edgeFlags = manager.handleWayTags(way, manager.createRelationFlags());
assertTrue(accessEnc.getBool(false, edgeFlags));
if (!encoder.getName().equals("foot"))
assertFalse(accessEnc.getBool(true, edgeFlags), encoder.getName());
assertTrue(roundaboutEnc.getBool(false, edgeFlags), encoder.getName());
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("junction", "circular");
edgeFlags = manager.handleWayTags(way, manager.createRelationFlags());
assertTrue(accessEnc.getBool(false, edgeFlags));
if (!encoder.getName().equals("foot"))
assertFalse(accessEnc.getBool(true, edgeFlags), encoder.getName());
assertTrue(roundaboutEnc.getBool(false, edgeFlags), encoder.getName());
}
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class EncodingManagerTest method testCompatibilityBug.
@Test
public void testCompatibilityBug() {
EncodingManager manager2 = EncodingManager.create(new DefaultFlagEncoderFactory(), "bike2");
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "footway");
osmWay.setTag("name", "test");
BikeFlagEncoder singleBikeEnc = (BikeFlagEncoder) manager2.getEncoder("bike2");
IntsRef flags = manager2.handleWayTags(osmWay, manager2.createRelationFlags());
double singleSpeed = singleBikeEnc.avgSpeedEnc.getDecimal(false, flags);
assertEquals(4, singleSpeed, 1e-3);
assertEquals(singleSpeed, singleBikeEnc.avgSpeedEnc.getDecimal(true, flags), 1e-3);
EncodingManager manager = EncodingManager.create(new DefaultFlagEncoderFactory(), "bike2,bike,foot");
FootFlagEncoder foot = (FootFlagEncoder) manager.getEncoder("foot");
BikeFlagEncoder bike = (BikeFlagEncoder) manager.getEncoder("bike2");
flags = manager.handleWayTags(osmWay, manager.createRelationFlags());
assertEquals(singleSpeed, bike.avgSpeedEnc.getDecimal(false, flags), 1e-2);
assertEquals(singleSpeed, bike.avgSpeedEnc.getDecimal(true, flags), 1e-2);
assertEquals(5, foot.avgSpeedEnc.getDecimal(false, flags), 1e-2);
assertEquals(5, foot.avgSpeedEnc.getDecimal(true, flags), 1e-2);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testGetSpeed.
@Test
public void testGetSpeed() {
IntsRef fl = encodingManager.createEdgeFlags();
footAccessEnc.setBool(false, fl, true);
footAccessEnc.setBool(true, fl, true);
footAvgSpeedEnc.setDecimal(false, fl, 10);
assertEquals(10, footAvgSpeedEnc.getDecimal(false, fl), 1e-1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testCombined.
@Test
public void testCombined() {
Graph g = new GraphBuilder(encodingManager).create();
EdgeIteratorState edge = g.edge(0, 1);
edge.set(footAvgSpeedEnc, 10.0).set(footAccessEnc, true, true);
edge.set(carAvSpeedEnc, 100.0).set(carAccessEnc, true, false);
assertEquals(10, edge.get(footAvgSpeedEnc), 1e-1);
assertTrue(edge.get(footAccessEnc));
assertTrue(edge.getReverse(footAccessEnc));
assertEquals(100, edge.get(carAvSpeedEnc), 1e-1);
assertTrue(edge.get(carAccessEnc));
assertFalse(edge.getReverse(carAccessEnc));
IntsRef raw = encodingManager.createEdgeFlags();
footAvgSpeedEnc.setDecimal(false, raw, 10);
footAccessEnc.setBool(false, raw, true);
footAccessEnc.setBool(true, raw, true);
assertEquals(0, carAvSpeedEnc.getDecimal(false, raw), 1e-1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testSlowHiking.
@Test
public void testSlowHiking() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("sac_scale", "hiking");
IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(FootFlagEncoder.MEAN_SPEED, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
way.setTag("highway", "track");
way.setTag("sac_scale", "mountain_hiking");
flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(FootFlagEncoder.SLOW_SPEED, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
}
Aggregations