Search in sources :

Example 21 with ReaderWay

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

the class ConditionalOSMTagInspectorTest method testConditionalSingleDay.

@Test
public void testConditionalSingleDay() {
    Calendar cal = getCalendar(2015, Calendar.DECEMBER, 27);
    ConditionalTagInspector acceptor = new ConditionalOSMTagInspector(cal, getSampleConditionalTags(), getSampleRestrictedValues(), getSamplePermissiveValues());
    ReaderWay way = new ReaderWay(1);
    way.setTag("vehicle:conditional", "no @ (Su)");
    assertTrue(acceptor.isPermittedWayConditionallyRestricted(way));
}
Also used : ConditionalTagInspector(com.graphhopper.reader.ConditionalTagInspector) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 22 with ReaderWay

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

the class EdgeElevationInterpolatorTest method setUp.

@SuppressWarnings("resource")
@BeforeEach
public void setUp() {
    graph = new GraphBuilder(encodingManager = new EncodingManager.Builder().add(new CarFlagEncoder()).add(new FootFlagEncoder()).build()).set3D(true).create();
    roadEnvEnc = encodingManager.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
    edgeElevationInterpolator = createEdgeElevationInterpolator();
    relFlags = encodingManager.createRelationFlags();
    interpolatableWay = createInterpolatableWay();
    normalWay = new ReaderWay(0);
    normalWay.setTag("highway", "primary");
}
Also used : RoadEnvironment(com.graphhopper.routing.ev.RoadEnvironment) GraphBuilder(com.graphhopper.storage.GraphBuilder) GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) FootFlagEncoder(com.graphhopper.routing.util.FootFlagEncoder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 23 with ReaderWay

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

the class PathTest method generatePathDetailsGraph.

private Graph generatePathDetailsGraph() {
    final Graph graph = new GraphBuilder(carManager).create();
    final NodeAccess na = graph.getNodeAccess();
    na.setNode(1, 52.514, 13.348);
    na.setNode(2, 52.514, 13.349);
    na.setNode(3, 52.514, 13.350);
    na.setNode(4, 52.515, 13.349);
    na.setNode(5, 52.516, 13.3452);
    na.setNode(6, 52.516, 13.344);
    ReaderWay w = new ReaderWay(1);
    w.setTag("highway", "tertiary");
    w.setTag("maxspeed", "50");
    EdgeIteratorState tmpEdge;
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(5)).setName("1-2");
    assertNotEquals(EncodingManager.Access.CAN_SKIP, ((AbstractFlagEncoder) encoder).getAccess(w));
    IntsRef relFlags = carManager.createRelationFlags();
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(4, 5).setDistance(5)).setName("4-5");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    w.setTag("maxspeed", "100");
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(2, 3).setDistance(5)).setName("2-3");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    w.setTag("maxspeed", "10");
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(3, 4).setDistance(10)).setName("3-4");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    tmpEdge = GHUtility.setSpeed(60, true, true, encoder, graph.edge(5, 6).setDistance(0.01)).setName("3-4");
    tmpEdge.setFlags(carManager.handleWayTags(w, relFlags));
    return graph;
}
Also used : NodeAccess(com.graphhopper.storage.NodeAccess) Graph(com.graphhopper.storage.Graph) GraphBuilder(com.graphhopper.storage.GraphBuilder) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef)

Example 24 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testAvoidMotorway.

@Test
public void testAvoidMotorway() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "motorway");
    osmWay.setTag("bicycle", "yes");
    assertPriority(AVOID.getValue(), osmWay);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 25 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testRelation.

@Test
public void testRelation() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    way.setTag("foot", "yes");
    way.setTag("motor_vehicle", "agricultural");
    way.setTag("surface", "gravel");
    way.setTag("tracktype", "grade3");
    ReaderRelation rel = new ReaderRelation(0);
    rel.setTag("type", "route");
    rel.setTag("network", "rcn");
    rel.setTag("route", "bicycle");
    ReaderRelation rel2 = new ReaderRelation(1);
    rel2.setTag("type", "route");
    rel2.setTag("network", "lcn");
    rel2.setTag("route", "bicycle");
    // two relation tags => we currently cannot store a list, so pick the lower ordinal 'regional'
    // Example https://www.openstreetmap.org/way/213492914 => two hike 84544, 2768803 and two bike relations 3162932, 5254650
    IntsRef relFlags = encodingManager.handleRelationTags(rel2, encodingManager.handleRelationTags(rel, encodingManager.createRelationFlags()));
    IntsRef edgeFlags = encodingManager.handleWayTags(way, relFlags);
    EnumEncodedValue<RouteNetwork> enc = encodingManager.getEnumEncodedValue(RouteNetwork.key("bike"), RouteNetwork.class);
    assertEquals(RouteNetwork.REGIONAL, enc.getEnum(false, edgeFlags));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) ReaderRelation(com.graphhopper.reader.ReaderRelation) Test(org.junit.jupiter.api.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