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());
}
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));
}
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));
}
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);
}
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);
}
Aggregations