Search in sources :

Example 56 with ReaderWay

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

the class FootFlagEncoderTest method testSlowHiking.

@Test
public void testSlowHiking() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("sac_scale", "hiking");
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(FootFlagEncoder.MEAN_SPEED, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
    way.setTag("highway", "track");
    way.setTag("sac_scale", "mountain_hiking");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(FootFlagEncoder.SLOW_SPEED, footAvgSpeedEnc.getDecimal(false, flags), 1e-1);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 57 with ReaderWay

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

the class FootFlagEncoderTest method testRailPlatformIssue366.

@Test
public void testRailPlatformIssue366() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("railway", "platform");
    IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertFalse(flags.isEmpty());
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertFalse(flags.isEmpty());
    way.clearTags();
    // only tram, no highway => no access
    way.setTag("railway", "tram");
    flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertTrue(flags.isEmpty());
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 58 with ReaderWay

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

the class FootFlagEncoderTest method testAccess.

@Test
public void testAccess() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    way.setTag("sidewalk", "yes");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("sidewalk", "left");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("sidewalk", "none");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("sidewalk", "left");
    way.setTag("access", "private");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "pedestrian");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("highway", "footway");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("highway", "platform");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("highway", "motorway");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.setTag("highway", "path");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("bicycle", "official");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("foot", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.setTag("foot", "official");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.setTag("foot", "yes");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("vehicle", "no");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("foot", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "tertiary");
    way.setTag("motorroad", "yes");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "cycleway");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.setTag("foot", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.setTag("access", "yes");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("foot", "yes");
    way.setTag("access", "no");
    assertTrue(footEncoder.getAccess(way).isWay());
    way.clearTags();
    way.setTag("route", "ferry");
    assertTrue(footEncoder.getAccess(way).isFerry());
    way.setTag("foot", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    // #1562, test if ferry route with foot
    way.clearTags();
    way.setTag("route", "ferry");
    way.setTag("foot", "yes");
    assertTrue(footEncoder.getAccess(way).isFerry());
    way.setTag("foot", "designated");
    assertTrue(footEncoder.getAccess(way).isFerry());
    way.setTag("foot", "official");
    assertTrue(footEncoder.getAccess(way).isFerry());
    way.setTag("foot", "permissive");
    assertTrue(footEncoder.getAccess(way).isFerry());
    way.setTag("foot", "no");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.setTag("foot", "designated");
    way.setTag("access", "private");
    assertTrue(footEncoder.getAccess(way).canSkip());
    DateFormat simpleDateFormat = Helper.createFormatter("yyyy MMM dd");
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("access:conditional", "no @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertTrue(footEncoder.getAccess(way).canSkip());
    way.clearTags();
    way.setTag("highway", "footway");
    way.setTag("access", "no");
    way.setTag("access:conditional", "yes @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertTrue(footEncoder.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 59 with ReaderWay

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

the class MountainBikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.

@Test
public void testHandleWayTagsInfluencedByRelation() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "track");
    ReaderRelation osmRel = new ReaderRelation(1);
    IntsRef relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    // unchanged
    IntsRef flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    assertPriority(PriorityCode.PREFER.getValue(), osmWay);
    // relation code is PREFER
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "lcn");
    relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    assertPriority(PriorityCode.PREFER.getValue(), osmWay);
    // relation code is PREFER
    osmRel.setTag("network", "rcn");
    relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertPriority(PriorityCode.PREFER.getValue(), osmWay);
    assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // relation code is PREFER
    osmRel.setTag("network", "ncn");
    relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertPriority(PriorityCode.PREFER.getValue(), osmWay);
    assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    // PREFER relation, but tertiary road
    // => no pushing section but road wayTypeCode and faster
    osmWay.clearTags();
    osmWay.setTag("highway", "tertiary");
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "lcn");
    relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
    flags = encodingManager.handleWayTags(osmWay, relFlags);
    assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
    assertPriority(PriorityCode.PREFER.getValue(), osmWay);
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) ReaderRelation(com.graphhopper.reader.ReaderRelation) Test(org.junit.jupiter.api.Test)

Example 60 with ReaderWay

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

the class RacingBikeFlagEncoderTest method testClassBicycle.

@Test
public void testClassBicycle() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "tertiary");
    way.setTag("class:bicycle:roadcycling", "3");
    assertPriority(BEST.getValue(), way);
    way.setTag("class:bicycle", "-2");
    assertPriority(BEST.getValue(), way);
}
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