Search in sources :

Example 1 with OSMRoundaboutParser

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());
    }
}
Also used : TagParser(com.graphhopper.routing.util.parsers.TagParser) OSMBikeNetworkTagParser(com.graphhopper.routing.util.parsers.OSMBikeNetworkTagParser) OSMRoundaboutParser(com.graphhopper.routing.util.parsers.OSMRoundaboutParser) PMap(com.graphhopper.util.PMap) ReaderWay(com.graphhopper.reader.ReaderWay) DateRangeParser(com.graphhopper.reader.osm.conditional.DateRangeParser) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)1 DateRangeParser (com.graphhopper.reader.osm.conditional.DateRangeParser)1 OSMBikeNetworkTagParser (com.graphhopper.routing.util.parsers.OSMBikeNetworkTagParser)1 OSMRoundaboutParser (com.graphhopper.routing.util.parsers.OSMRoundaboutParser)1 TagParser (com.graphhopper.routing.util.parsers.TagParser)1 IntsRef (com.graphhopper.storage.IntsRef)1 PMap (com.graphhopper.util.PMap)1 Test (org.junit.jupiter.api.Test)1