Search in sources :

Example 46 with FlagEncoder

use of com.graphhopper.routing.util.FlagEncoder in project graphhopper by graphhopper.

the class BridgeElevationInterpolatorTest method interpolatesElevationOfPillarNodes.

@Test
public void interpolatesElevationOfPillarNodes() {
    // @formatter:off
    /*
         * Graph structure:
         * 0-----1-----2-----3-----4
         *        \    |    /
         *         \   |   /
         *          T  T  T
         *           \ | /
         *            \|/
         * 5-----6--T--7--T--8-----9
         */
    // @formatter:on
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 0, 0);
    na.setNode(1, 10, 0, 10);
    na.setNode(2, 20, 0, 20);
    na.setNode(3, 30, 0, 30);
    na.setNode(4, 40, 0, 40);
    na.setNode(5, 0, 10, 40);
    na.setNode(6, 10, 10, 30);
    na.setNode(7, 20, 10, 1000);
    na.setNode(8, 30, 10, 10);
    na.setNode(9, 40, 10, 0);
    FlagEncoder encoder = encodingManager.getEncoder("car");
    EdgeIteratorState edge01, edge12, edge23, edge34, edge56, edge67, edge78, edge89, edge17, edge27, edge37;
    GHUtility.setSpeed(60, 60, encoder, edge01 = graph.edge(0, 1).setDistance(10), edge12 = graph.edge(1, 2).setDistance(10), edge23 = graph.edge(2, 3).setDistance(10), edge34 = graph.edge(3, 4).setDistance(10), edge56 = graph.edge(5, 6).setDistance(10), edge67 = graph.edge(6, 7).setDistance(10), edge78 = graph.edge(7, 8).setDistance(10), edge89 = graph.edge(8, 9).setDistance(10), edge17 = graph.edge(1, 7).setDistance(10), edge27 = graph.edge(2, 7).setDistance(10), edge37 = graph.edge(3, 7).setDistance(10));
    edge17.setWayGeometry(Helper.createPointList3D(12, 2, 200, 14, 4, 400, 16, 6, 600, 18, 8, 800));
    IntsRef relFlags = encodingManager.createRelationFlags();
    edge01.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge12.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge23.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge34.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge56.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge67.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge78.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge89.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge17.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge27.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge37.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    final GHIntHashSet outerNodeIds = new GHIntHashSet();
    final GHIntHashSet innerNodeIds = new GHIntHashSet();
    gatherOuterAndInnerNodeIdsOfStructure(edge27, outerNodeIds, innerNodeIds);
    assertEquals(GHIntHashSet.from(1, 2, 3, 6, 8), outerNodeIds);
    assertEquals(GHIntHashSet.from(7), innerNodeIds);
    edgeElevationInterpolator.execute();
    assertEquals(0, na.getEle(0), PRECISION);
    assertEquals(10, na.getEle(1), PRECISION);
    assertEquals(20, na.getEle(2), PRECISION);
    assertEquals(30, na.getEle(3), PRECISION);
    assertEquals(40, na.getEle(4), PRECISION);
    assertEquals(40, na.getEle(5), PRECISION);
    assertEquals(30, na.getEle(6), PRECISION);
    assertEquals(20, na.getEle(7), PRECISION);
    assertEquals(10, na.getEle(8), PRECISION);
    assertEquals(0, na.getEle(9), PRECISION);
    final PointList edge17PointList = edge17.fetchWayGeometry(FetchMode.ALL);
    assertEquals(6, edge17PointList.size());
    assertEquals(10, edge17PointList.getEle(0), PRECISION);
    assertEquals(12, edge17PointList.getEle(1), PRECISION);
    assertEquals(14, edge17PointList.getEle(2), PRECISION);
    assertEquals(16, edge17PointList.getEle(3), PRECISION);
    assertEquals(18, edge17PointList.getEle(4), PRECISION);
    assertEquals(20, edge17PointList.getEle(5), PRECISION);
}
Also used : NodeAccess(com.graphhopper.storage.NodeAccess) GHIntHashSet(com.graphhopper.coll.GHIntHashSet) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Aggregations

FlagEncoder (com.graphhopper.routing.util.FlagEncoder)46 Test (org.junit.jupiter.api.Test)23 EncodingManager (com.graphhopper.routing.util.EncodingManager)19 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)14 GraphBuilder (com.graphhopper.storage.GraphBuilder)14 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)13 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)12 NodeAccess (com.graphhopper.storage.NodeAccess)10 Graph (com.graphhopper.storage.Graph)7 GHIntHashSet (com.graphhopper.coll.GHIntHashSet)6 Test (org.junit.Test)6 BikeFlagEncoder (com.graphhopper.routing.util.BikeFlagEncoder)5 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)5 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)4 IntArrayList (com.carrotsearch.hppc.IntArrayList)3 GHBitSetImpl (com.graphhopper.coll.GHBitSetImpl)3 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)3 LMProfile (com.graphhopper.config.LMProfile)3 ReaderWay (com.graphhopper.reader.ReaderWay)3 AllEdgesIterator (com.graphhopper.routing.util.AllEdgesIterator)3