Search in sources :

Example 21 with GHIntHashSet

use of com.graphhopper.coll.GHIntHashSet in project graphhopper by graphhopper.

the class TunnelElevationInterpolatorTest method interpolatesElevationOfTunnelWithTwoOuterNodes.

@Test
public void interpolatesElevationOfTunnelWithTwoOuterNodes() {
    // @formatter:off
    /*
         * Graph structure:
         * 0-----1--T--2--T--3-----4
         */
    // @formatter:on
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 0, 0);
    na.setNode(1, 10, 0, 10);
    na.setNode(2, 20, 0, 1000);
    na.setNode(3, 30, 0, 30);
    na.setNode(4, 40, 0, 40);
    FlagEncoder encoder = encodingManager.getEncoder("car");
    EdgeIteratorState edge01 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(0, 1).setDistance(10));
    EdgeIteratorState edge12 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(10));
    EdgeIteratorState edge23 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(2, 3).setDistance(10));
    EdgeIteratorState edge34 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(3, 4).setDistance(10));
    edge01.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge12.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge23.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge34.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    final GHIntHashSet outerNodeIds = new GHIntHashSet();
    final GHIntHashSet innerNodeIds = new GHIntHashSet();
    gatherOuterAndInnerNodeIdsOfStructure(edge12, outerNodeIds, innerNodeIds);
    assertEquals(GHIntHashSet.from(1, 3), outerNodeIds);
    assertEquals(GHIntHashSet.from(2), 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);
}
Also used : NodeAccess(com.graphhopper.storage.NodeAccess) GHIntHashSet(com.graphhopper.coll.GHIntHashSet) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) Test(org.junit.jupiter.api.Test)

Example 22 with GHIntHashSet

use of com.graphhopper.coll.GHIntHashSet 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

GHIntHashSet (com.graphhopper.coll.GHIntHashSet)22 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)9 Test (org.junit.jupiter.api.Test)8 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)6 NodeAccess (com.graphhopper.storage.NodeAccess)6 Test (org.junit.Test)5 IntSet (com.carrotsearch.hppc.IntSet)3 Graph (com.graphhopper.storage.Graph)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 IntProcedure (com.carrotsearch.hppc.procedures.IntProcedure)2 GraphEdgeIdFinder (com.graphhopper.storage.GraphEdgeIdFinder)2 Circle (com.graphhopper.util.shapes.Circle)2 ArrayList (java.util.ArrayList)2 IntArrayList (com.carrotsearch.hppc.IntArrayList)1 IntCursor (com.carrotsearch.hppc.cursors.IntCursor)1 IntPredicate (com.carrotsearch.hppc.predicates.IntPredicate)1 GHBitSet (com.graphhopper.coll.GHBitSet)1 GHIntObjectHashMap (com.graphhopper.coll.GHIntObjectHashMap)1 GHTBitSet (com.graphhopper.coll.GHTBitSet)1 QueryGraph (com.graphhopper.routing.querygraph.QueryGraph)1