Search in sources :

Example 26 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testPreferenceForSlowSpeed.

@Test
public void testPreferenceForSlowSpeed() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "tertiary");
    IntsRef edgeFlags = encodingManager.createEdgeFlags();
    avgSpeedEnc.setDecimal(false, edgeFlags, encoder.applyMaxSpeed(osmWay, 49));
    assertEquals(30, avgSpeedEnc.getDecimal(false, edgeFlags), 1e-1);
    assertPriority(PREFER.getValue(), osmWay);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 27 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testAccess.

@Test
public void testAccess() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("highway", "motorway");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("highway", "footway");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("bicycle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("highway", "footway");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("highway", "pedestrian");
    way.setTag("bicycle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("highway", "pedestrian");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("bicycle", "yes");
    way.setTag("highway", "cycleway");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "path");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("highway", "path");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "track");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("mtb", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("foot", "official");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("bicycle", "official");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("motorroad", "yes");
    assertTrue(encoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("ford", "yes");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "secondary");
    way.setTag("access", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("bicycle", "dismount");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "secondary");
    way.setTag("vehicle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("bicycle", "dismount");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "cycleway");
    way.setTag("cycleway", "track");
    way.setTag("railway", "abandoned");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "platform");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "platform");
    way.setTag("bicycle", "dismount");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "platform");
    way.setTag("bicycle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    DateFormat simpleDateFormat = Helper.createFormatter("yyyy MMM dd");
    way.clearTags();
    way.setTag("highway", "road");
    way.setTag("bicycle:conditional", "no @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertTrue(encoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "road");
    way.setTag("access", "no");
    way.setTag("bicycle:conditional", "yes @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertTrue(encoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("vehicle", "forestry");
    assertTrue(encoder.getAccess(way).canSkip());
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
}
Also used : DateFormat(java.text.DateFormat) ReaderWay(com.graphhopper.reader.ReaderWay) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 28 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testSacScale.

@Test
public void testSacScale() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "service");
    way.setTag("sac_scale", "hiking");
    // allow
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("sac_scale", "alpine_hiking");
    assertTrue(encoder.getAccess(way).canSkip());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 29 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testService.

@Test
public void testService() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "service");
    assertEquals(14, encoder.getSpeed(way));
    assertPriority(PREFER.getValue(), way);
    way.setTag("service", "parking_aisle");
    assertEquals(6, encoder.getSpeed(way));
    assertPriority(SLIGHT_AVOID.getValue(), way);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 30 with ReaderWay

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

the class AbstractBikeFlagEncoderTester method testReduceToMaxSpeed.

@Test
public void testReduceToMaxSpeed() {
    ReaderWay way = new ReaderWay(12);
    way.setTag("maxspeed", "90");
    assertEquals(12, encoder.applyMaxSpeed(way, 12), 1e-2);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) 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