Search in sources :

Example 71 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class BikeFlagEncoderTest method testOneway.

@Test
public void testOneway() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "tertiary");
    IntsRef flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.setTag("oneway", "yes");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertFalse(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("oneway:bicycle", "yes");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertFalse(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("vehicle:forward", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertFalse(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("bicycle:forward", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertFalse(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("vehicle:backward", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertFalse(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("motor_vehicle:backward", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("oneway", "yes");
    way.setTag("bicycle:backward", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertFalse(encoder.getAccessEnc().getBool(true, flags));
    way.setTag("bicycle:backward", "yes");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("oneway", "yes");
    way.setTag("bicycle:backward", "yes");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("oneway", "-1");
    way.setTag("bicycle:forward", "yes");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("bicycle:forward", "use_sidepath");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("bicycle:forward", "use_sidepath");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("oneway", "yes");
    way.setTag("cycleway", "opposite");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("oneway", "yes");
    way.setTag("cycleway:left", "opposite_lane");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(encoder.getAccessEnc().getBool(false, flags));
    assertTrue(encoder.getAccessEnc().getBool(true, flags));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 72 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class AbstractBikeFlagEncoderTester method testHandleWayTagsCallsHandlePriority.

@Test
public void testHandleWayTagsCallsHandlePriority() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "cycleway");
    IntsRef edgeFlags = encoder.handleWayTags(encodingManager.createEdgeFlags(), osmWay);
    DecimalEncodedValue priorityEnc = encodingManager.getDecimalEncodedValue(EncodingManager.getKey(encoder, "priority"));
    assertEquals(PriorityCode.getValue(VERY_NICE.getValue()), priorityEnc.getDecimal(false, edgeFlags), 1e-3);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 73 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class OSMSmoothnessParserTest method testSimpleTags.

@Test
public void testSimpleTags() {
    IntsRef relFlags = em.createRelationFlags();
    ReaderWay readerWay = new ReaderWay(1);
    IntsRef intsRef = em.createEdgeFlags();
    readerWay.setTag("highway", "primary");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(Smoothness.MISSING, smoothnessEnc.getEnum(false, intsRef));
    readerWay.setTag("smoothness", "bad");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(Smoothness.BAD, smoothnessEnc.getEnum(false, intsRef));
    assertTrue(Smoothness.BAD.ordinal() < Smoothness.VERY_BAD.ordinal());
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 74 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class AbstractBikeFlagEncoderTester method getSpeedFromFlags.

protected double getSpeedFromFlags(ReaderWay way) {
    IntsRef relFlags = encodingManager.createRelationFlags();
    IntsRef flags = encodingManager.handleWayTags(way, relFlags);
    return avgSpeedEnc.getDecimal(false, flags);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef)

Example 75 with IntsRef

use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.

the class EncodingManagerTest method testCombineRelations.

@Test
public void testCombineRelations() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "track");
    ReaderRelation osmRel = new ReaderRelation(1);
    BikeFlagEncoder defaultBike = new BikeFlagEncoder();
    BikeFlagEncoder lessRelationCodes = new BikeFlagEncoder() {

        @Override
        public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay way) {
            if (bikeRouteEnc.getEnum(false, edgeFlags) != RouteNetwork.MISSING)
                priorityEnc.setDecimal(false, edgeFlags, PriorityCode.getFactor(2));
            return edgeFlags;
        }

        @Override
        public String getName() {
            return "less_relations_bits";
        }
    };
    EncodingManager manager = new EncodingManager.Builder().add(lessRelationCodes).add(defaultBike).build();
    // relation code is PREFER
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "lcn");
    IntsRef relFlags = manager.handleRelationTags(osmRel, manager.createRelationFlags());
    IntsRef edgeFlags = manager.handleWayTags(osmWay, relFlags);
    assertTrue(defaultBike.priorityEnc.getDecimal(false, edgeFlags) > lessRelationCodes.priorityEnc.getDecimal(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

IntsRef (com.graphhopper.storage.IntsRef)108 Test (org.junit.jupiter.api.Test)96 ReaderWay (com.graphhopper.reader.ReaderWay)67 ReaderRelation (com.graphhopper.reader.ReaderRelation)7 GraphBuilder (com.graphhopper.storage.GraphBuilder)7 EncodingManager (com.graphhopper.routing.util.EncodingManager)5 Graph (com.graphhopper.storage.Graph)5 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)3 NodeAccess (com.graphhopper.storage.NodeAccess)3 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)2 RoadEnvironment (com.graphhopper.routing.ev.RoadEnvironment)2 VirtualEdgeIteratorState (com.graphhopper.routing.querygraph.VirtualEdgeIteratorState)2 TransportationMode (com.graphhopper.routing.util.TransportationMode)2 CountryRule (com.graphhopper.routing.util.countryrules.CountryRule)2 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)2 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)2 PMap (com.graphhopper.util.PMap)2 PointList (com.graphhopper.util.PointList)2