Search in sources :

Example 81 with ReaderWay

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

the class GraphHopperStorageLMTest method testLoad.

@Test
public void testLoad() {
    String defaultGraphLoc = "./target/ghstorage_lm";
    Helper.removeDir(new File(defaultGraphLoc));
    CarFlagEncoder carFlagEncoder = new CarFlagEncoder();
    EncodingManager encodingManager = new EncodingManager.Builder().add(carFlagEncoder).add(Subnetwork.create("my_profile")).build();
    GraphHopperStorage graph = GraphBuilder.start(encodingManager).setRAM(defaultGraphLoc, true).create();
    // 0-1
    ReaderWay way_0_1 = new ReaderWay(27l);
    way_0_1.setTag("highway", "primary");
    way_0_1.setTag("maxheight", "4.4");
    GHUtility.setSpeed(60, true, true, carFlagEncoder, graph.edge(0, 1).setDistance(1));
    updateDistancesFor(graph, 0, 0.00, 0.00);
    updateDistancesFor(graph, 1, 0.01, 0.01);
    graph.getEdgeIteratorState(0, 1).setFlags(carFlagEncoder.handleWayTags(encodingManager.createEdgeFlags(), way_0_1));
    // 1-2
    ReaderWay way_1_2 = new ReaderWay(28l);
    way_1_2.setTag("highway", "primary");
    way_1_2.setTag("maxweight", "45");
    GHUtility.setSpeed(60, true, true, carFlagEncoder, graph.edge(1, 2).setDistance(1));
    updateDistancesFor(graph, 2, 0.02, 0.02);
    graph.getEdgeIteratorState(1, 2).setFlags(carFlagEncoder.handleWayTags(encodingManager.createEdgeFlags(), way_1_2));
    graph.flush();
    graph.close();
    GraphHopper hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
    hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
    // does lm preparation
    hopper.importOrLoad();
    EncodingManager em = hopper.getEncodingManager();
    assertNotNull(em);
    assertEquals(1, em.fetchEdgeEncoders().size());
    assertEquals(16, hopper.getLMPreparationHandler().getLandmarks());
    hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
    hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
    // just loads the LM data
    hopper.importOrLoad();
    assertEquals(1, em.fetchEdgeEncoders().size());
    assertEquals(16, hopper.getLMPreparationHandler().getLandmarks());
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) LMProfile(com.graphhopper.config.LMProfile) ReaderWay(com.graphhopper.reader.ReaderWay) GraphHopper(com.graphhopper.GraphHopper) File(java.io.File) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Profile(com.graphhopper.config.Profile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 82 with ReaderWay

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

the class FootFlagEncoderTest method handleWayTagsRoundabout.

@Test
public void handleWayTagsRoundabout() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("junction", "roundabout");
    way.setTag("highway", "tertiary");
    long flags = footEncoder.handleWayTags(way, footEncoder.acceptWay(way), 0);
    assertTrue(footEncoder.isBool(flags, FlagEncoder.K_ROUNDABOUT));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 83 with ReaderWay

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

the class DataFlagEncoderTest method testBridge.

@Test
public void testBridge() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("bridge", "yes");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("primary", encoder.getHighwayAsString(edge));
    assertEquals("bridge", encoder.getTransportModeAsString(edge));
    assertFalse(encoder.isTransportModeTunnel(edge));
    assertTrue(encoder.isTransportModeBridge(edge));
    osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("bridge", "yes");
    osmWay.setTag("tunnel", "yes");
    flags = encoder.handleWayTags(osmWay, 1, 0);
    edge = GHUtility.createMockedEdgeIteratorState(0, flags);
    assertEquals("bridge", encoder.getTransportModeAsString(edge));
    assertFalse(encoder.isTransportModeTunnel(edge));
    assertTrue(encoder.isTransportModeBridge(edge));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 84 with ReaderWay

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

the class DataFlagEncoderTest method acceptWay.

@Test
public void acceptWay() {
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    assertTrue(encoder.acceptWay(osmWay) != 0);
    // important to filter out illegal highways to reduce the number of edges before adding them to the graph
    osmWay.setTag("highway", "building");
    assertTrue(encoder.acceptWay(osmWay) == 0);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

Example 85 with ReaderWay

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

the class DataFlagEncoderTest method reverseEdge.

@Test
public void reverseEdge() {
    Graph graph = new GraphBuilder(encodingManager).create();
    EdgeIteratorState edge = graph.edge(0, 1);
    ReaderWay osmWay = new ReaderWay(0);
    osmWay.setTag("highway", "primary");
    osmWay.setTag("maxspeed:forward", "10");
    long flags = encoder.handleWayTags(osmWay, 1, 0);
    edge.setFlags(flags);
    assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
    assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
    edge = edge.detach(true);
    assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
    assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
}
Also used : Graph(com.graphhopper.storage.Graph) GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.Test)

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