Search in sources :

Example 11 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class DataFlagEncoderTest method testCircularJunction.

@Test
public void testCircularJunction() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "unclassified");
    osmWay.setTag("junction", "circular");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertTrue(encoder.isRoundabout(edge));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 12 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class GenericWeightingTest method setUp.

@Before
public void setUp() {
    ReaderWay way = new ReaderWay(27l);
    way.setTag("highway", "primary");
    way.setTag("maxspeed", "10");
    way.setTag("maxheight", "4.4");
    graph = new GraphBuilder(em).create();
    // 0-1
    graph.edge(0, 1, 1, true);
    AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.00, 0.00);
    AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01);
    graph.getEdgeIteratorState(0, 1).setFlags(encoder.handleWayTags(way, 1, 0));
}
Also used : GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) Before(org.junit.Before)

Example 13 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class PathTest method testCalcInstructionsForDataFlagEncoder.

@Test
public void testCalcInstructionsForDataFlagEncoder() {
    final Graph g = new GraphBuilder(dataFlagManager).create();
    final NodeAccess na = g.getNodeAccess();
    na.setNode(1, 48.982618, 13.122021);
    na.setNode(2, 48.982565, 13.121597);
    na.setNode(3, 48.982611, 13.121012);
    na.setNode(4, 48.982336, 13.121002);
    ReaderWay w = new ReaderWay(1);
    w.setTag("highway", "tertiary");
    g.edge(1, 2, 5, true).setFlags(dataFlagEncoder.handleWayTags(w, 1, 0));
    g.edge(2, 4, 5, true).setFlags(dataFlagEncoder.handleWayTags(w, 1, 0));
    g.edge(2, 3, 5, true).setFlags(dataFlagEncoder.handleWayTags(w, 1, 0));
    Path p = new Dijkstra(g, new GenericWeighting(dataFlagEncoder, new HintsMap()), TraversalMode.NODE_BASED).calcPath(1, 3);
    assertTrue(p.isFound());
    InstructionList wayList = p.calcInstructions(tr);
    assertEquals(3, wayList.size());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) GenericWeighting(com.graphhopper.routing.weighting.GenericWeighting) Test(org.junit.Test)

Example 14 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class OSMXMLHelper method createWay.

public static ReaderWay createWay(long id, XMLStreamReader parser) throws XMLStreamException {
    ReaderWay way = new ReaderWay(id);
    parser.nextTag();
    readNodes(way, parser);
    readTags(way, parser);
    return way;
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay)

Example 15 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class PbfBlobDecoder method processWays.

private void processWays(List<Osmformat.Way> ways, PbfFieldDecoder fieldDecoder) {
    for (Osmformat.Way way : ways) {
        Map<String, String> tags = buildTags(way.getKeysList(), way.getValsList(), fieldDecoder);
        ReaderWay osmWay = new ReaderWay(way.getId());
        osmWay.setTags(tags);
        // Build up the list of way nodes for the way. The node ids are
        // delta encoded meaning that each id is stored as a delta against
        // the previous one.
        long nodeId = 0;
        LongIndexedContainer wayNodes = osmWay.getNodes();
        for (long nodeIdOffset : way.getRefsList()) {
            nodeId += nodeIdOffset;
            wayNodes.add(nodeId);
        }
        decodedEntities.add(osmWay);
    }
}
Also used : LongIndexedContainer(com.carrotsearch.hppc.LongIndexedContainer) ReaderWay(com.graphhopper.reader.ReaderWay) Osmformat(org.openstreetmap.osmosis.osmbinary.Osmformat)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)157 Test (org.junit.jupiter.api.Test)119 IntsRef (com.graphhopper.storage.IntsRef)67 Test (org.junit.Test)24 EncodingManager (com.graphhopper.routing.util.EncodingManager)9 GraphBuilder (com.graphhopper.storage.GraphBuilder)9 ReaderRelation (com.graphhopper.reader.ReaderRelation)8 ConditionalTagInspector (com.graphhopper.reader.ConditionalTagInspector)7 Graph (com.graphhopper.storage.Graph)7 DateFormat (java.text.DateFormat)6 Date (java.util.Date)6 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)5 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 PMap (com.graphhopper.util.PMap)4 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)3 DataFlagEncoder (com.graphhopper.routing.util.DataFlagEncoder)3 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 LongIndexedContainer (com.carrotsearch.hppc.LongIndexedContainer)2