use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class AbstractBikeFlagEncoderTester method testTramStations.
@Test
public void testTramStations() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "secondary");
way.setTag("railway", "rail");
assertTrue(encoder.getAccess(way).isWay());
way = new ReaderWay(1);
way.setTag("highway", "secondary");
way.setTag("railway", "station");
assertTrue(encoder.getAccess(way).isWay());
way = new ReaderWay(1);
way.setTag("highway", "secondary");
way.setTag("railway", "station");
way.setTag("bicycle", "yes");
assertTrue(encoder.getAccess(way).isWay());
way.setTag("bicycle", "no");
assertTrue(encoder.getAccess(way).canSkip());
way = new ReaderWay(1);
way.setTag("railway", "platform");
IntsRef flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertNotEquals(true, flags.isEmpty());
way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("railway", "platform");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertNotEquals(true, flags.isEmpty());
way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("railway", "platform");
way.setTag("bicycle", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertEquals(true, flags.isEmpty());
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class Bike2WeightFlagEncoderTest method testApplyWayTags.
@Test
public void testApplyWayTags() {
Graph graph = initExampleGraph();
EdgeIteratorState edge = GHUtility.getEdge(graph, 0, 1);
ReaderWay way = new ReaderWay(1);
encoder.applyWayTags(way, edge);
IntsRef flags = edge.getFlags();
// decrease speed
assertEquals(2, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// increase speed but use maximum speed (calculated was 24)
assertEquals(18, avgSpeedEnc.getDecimal(true, flags), 1e-1);
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class Bike2WeightFlagEncoderTest method testRoutingFailsWithInvalidGraph_issue665.
@Test
public void testRoutingFailsWithInvalidGraph_issue665() {
GraphHopperStorage graph = new GraphBuilder(encodingManager).set3D(true).create();
ReaderWay way = new ReaderWay(0);
way.setTag("route", "ferry");
assertNotEquals(EncodingManager.Access.CAN_SKIP, encoder.getAccess(way));
IntsRef wayFlags = encodingManager.handleWayTags(way, encodingManager.createRelationFlags());
graph.edge(0, 1).setDistance(247).setFlags(wayFlags);
assertTrue(isGraphValid(graph, encoder));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class DecimalEncodedValueTest method testMaxValue.
@Test
public void testMaxValue() {
CarFlagEncoder carEncoder = new CarFlagEncoder(10, 0.5, 0);
EncodingManager em = EncodingManager.create(carEncoder);
DecimalEncodedValue carAverageSpeedEnc = em.getDecimalEncodedValue(EncodingManager.getKey(carEncoder, "average_speed"));
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "motorway_link");
way.setTag("maxspeed", "70 mph");
IntsRef flags = carEncoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(101.5, carAverageSpeedEnc.getDecimal(true, flags), 1e-1);
DecimalEncodedValue instance1 = new DecimalEncodedValueImpl("test1", 8, 0.5, false);
instance1.init(new EncodedValue.InitializerConfig());
flags = em.createEdgeFlags();
instance1.setDecimal(false, flags, 100d);
assertEquals(100, instance1.getDecimal(false, flags), 1e-1);
}
use of com.graphhopper.reader.ReaderWay 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());
}
}
Aggregations