Search in sources :

Example 41 with FlagEncoder

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

the class LMPreparationHandlerTest method maximumLMWeight.

@Test
public void maximumLMWeight() {
    LMPreparationHandler handler = new LMPreparationHandler();
    handler.setLMProfiles(new LMProfile("conf1").setMaximumLMWeight(65_000), new LMProfile("conf2").setMaximumLMWeight(20_000));
    FlagEncoder car = new CarFlagEncoder();
    EncodingManager em = EncodingManager.create(car);
    List<LMConfig> lmConfigs = Arrays.asList(new LMConfig("conf1", new FastestWeighting(car)), new LMConfig("conf2", new ShortestWeighting(car)));
    List<PrepareLandmarks> preparations = handler.createPreparations(lmConfigs, new GraphBuilder(em).build(), null);
    assertEquals(1, preparations.get(0).getLandmarkStorage().getFactor(), .1);
    assertEquals(0.3, preparations.get(1).getLandmarkStorage().getFactor(), .1);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) LMProfile(com.graphhopper.config.LMProfile) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) GraphBuilder(com.graphhopper.storage.GraphBuilder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) ShortestWeighting(com.graphhopper.routing.weighting.ShortestWeighting) Test(org.junit.jupiter.api.Test)

Example 42 with FlagEncoder

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

the class LMProfileSelectorTest method setup.

@BeforeEach
public void setup() {
    FlagEncoder carEncoder = new CarFlagEncoder();
    FlagEncoder bikeEncoder = new BikeFlagEncoder();
    encodingManager = EncodingManager.create(carEncoder, bikeEncoder);
    fastCar = new Profile("fast_car").setVehicle("car").setWeighting("fastest").setTurnCosts(false);
    fastCarEdge = new Profile("fast_car_edge").setVehicle("car").setWeighting("fastest").setTurnCosts(true);
    fastBike = new Profile("fast_bike").setVehicle("bike").setWeighting("fastest").setTurnCosts(false);
    shortBikeEdge = new Profile("short_bike_edge").setVehicle("bike").setWeighting("shortest").setTurnCosts(true);
}
Also used : CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) BikeFlagEncoder(com.graphhopper.routing.util.BikeFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) BikeFlagEncoder(com.graphhopper.routing.util.BikeFlagEncoder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) CHProfile(com.graphhopper.config.CHProfile) Profile(com.graphhopper.config.Profile) LMProfile(com.graphhopper.config.LMProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 43 with FlagEncoder

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

the class TunnelElevationInterpolatorTest method doesNotInterpolateElevationOfTunnelWithZeroOuterNodes.

@Test
public void doesNotInterpolateElevationOfTunnelWithZeroOuterNodes() {
    // @formatter:off
    /*
         * Graph structure:
         * 0--T--1--T--2     3--T--4
         * Tunnel 0-1-2 has a single outer node 2.
         */
    // @formatter:on
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 0, 0);
    na.setNode(1, 10, 0, 0);
    na.setNode(2, 20, 0, 10);
    na.setNode(3, 30, 0, 20);
    na.setNode(4, 40, 0, 0);
    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 edge34 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(3, 4).setDistance(10));
    edge01.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge12.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge34.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    final GHIntHashSet outerNodeIds = new GHIntHashSet();
    final GHIntHashSet innerNodeIds = new GHIntHashSet();
    gatherOuterAndInnerNodeIdsOfStructure(edge01, outerNodeIds, innerNodeIds);
    assertEquals(GHIntHashSet.from(), outerNodeIds);
    assertEquals(GHIntHashSet.from(0, 1, 2), innerNodeIds);
    edgeElevationInterpolator.execute();
    assertEquals(0, na.getEle(0), PRECISION);
    assertEquals(0, na.getEle(1), PRECISION);
    assertEquals(10, na.getEle(2), PRECISION);
    assertEquals(20, na.getEle(3), PRECISION);
    assertEquals(0, 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 44 with FlagEncoder

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

the class TunnelElevationInterpolatorTest method interpolatesElevationOfTunnelWithSingleOuterNode.

@Test
public void interpolatesElevationOfTunnelWithSingleOuterNode() {
    // @formatter:off
    /*
         * Graph structure:
         * 0--T--1--T--2-----3--T--4
         */
    // @formatter:on
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 0, 0);
    na.setNode(1, 10, 0, 00);
    na.setNode(2, 20, 0, 10);
    na.setNode(3, 30, 0, 20);
    na.setNode(4, 40, 0, 00);
    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(interpolatableWay, relFlags));
    edge12.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    edge23.setFlags(encodingManager.handleWayTags(normalWay, relFlags));
    edge34.setFlags(encodingManager.handleWayTags(interpolatableWay, relFlags));
    final GHIntHashSet outerNodeIds = new GHIntHashSet();
    final GHIntHashSet innerNodeIds = new GHIntHashSet();
    gatherOuterAndInnerNodeIdsOfStructure(edge01, outerNodeIds, innerNodeIds);
    assertEquals(GHIntHashSet.from(2), outerNodeIds);
    assertEquals(GHIntHashSet.from(0, 1), innerNodeIds);
    edgeElevationInterpolator.execute();
    assertEquals(10, na.getEle(0), PRECISION);
    assertEquals(10, na.getEle(1), PRECISION);
    assertEquals(10, na.getEle(2), PRECISION);
    assertEquals(20, na.getEle(3), PRECISION);
    assertEquals(20, 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 45 with FlagEncoder

use of com.graphhopper.routing.util.FlagEncoder 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)

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