use of com.graphhopper.routing.util.parsers.OSMRoundaboutParser in project graphhopper by graphhopper.
the class TagParsingTest method testSharedEncodedValues.
@Test
public void testSharedEncodedValues() {
EncodingManager manager = EncodingManager.create("car,foot,bike,motorcycle,mtb");
BooleanEncodedValue roundaboutEnc = manager.getBooleanEncodedValue(Roundabout.KEY);
List<TagParser> tagParsers = Arrays.asList(new OSMRoundaboutParser(roundaboutEnc), new CarTagParser(manager, new PMap()), new FootTagParser(manager, new PMap()), new BikeTagParser(manager, new PMap()), new MotorcycleTagParser(manager, new PMap()), new MountainBikeTagParser(manager, new PMap()));
for (TagParser tagParser : tagParsers) if (tagParser instanceof VehicleTagParser)
((VehicleTagParser) tagParser).init(new DateRangeParser());
final IntsRef edgeFlags = manager.createEdgeFlags();
IntsRef relFlags = manager.createRelationFlags();
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("junction", "roundabout");
tagParsers.forEach(p -> p.handleWayTags(edgeFlags, way, relFlags));
for (FlagEncoder tmp : manager.fetchEdgeEncoders()) {
BooleanEncodedValue accessEnc = tmp.getAccessEnc();
assertTrue(accessEnc.getBool(false, edgeFlags));
assertTrue(roundaboutEnc.getBool(false, edgeFlags), tmp.toString());
}
final IntsRef edgeFlags2 = manager.createEdgeFlags();
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("junction", "circular");
tagParsers.forEach(p -> p.handleWayTags(edgeFlags2, way, relFlags));
for (FlagEncoder tmp : manager.fetchEdgeEncoders()) {
BooleanEncodedValue accessEnc = tmp.getAccessEnc();
assertTrue(accessEnc.getBool(false, edgeFlags));
assertTrue(roundaboutEnc.getBool(false, edgeFlags), tmp.toString());
}
}
Aggregations