Search in sources :

Example 76 with IntsRef

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

the class EncodingManagerTest method testMixBikeTypesAndRelationCombination.

@Test
public void testMixBikeTypesAndRelationCombination() {
    ReaderWay osmWay = new ReaderWay(1);
    osmWay.setTag("highway", "track");
    osmWay.setTag("tracktype", "grade1");
    ReaderRelation osmRel = new ReaderRelation(1);
    BikeFlagEncoder bikeEncoder = new BikeFlagEncoder();
    MountainBikeFlagEncoder mtbEncoder = new MountainBikeFlagEncoder();
    EncodingManager manager = EncodingManager.create(bikeEncoder, mtbEncoder);
    // relation code for network rcn is NICE for bike and PREFER for mountainbike
    osmRel.setTag("route", "bicycle");
    osmRel.setTag("network", "rcn");
    IntsRef relFlags = manager.handleRelationTags(osmRel, manager.createRelationFlags());
    IntsRef edgeFlags = manager.handleWayTags(osmWay, relFlags);
    // bike: uninfluenced speed for grade but via network => NICE
    // mtb: uninfluenced speed only PREFER
    assertTrue(bikeEncoder.priorityEnc.getDecimal(false, edgeFlags) > mtbEncoder.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)

Example 77 with IntsRef

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

the class OSMRoadEnvironmentParserTest method ferry.

@Test
void ferry() {
    OSMRoadEnvironmentParser parser = new OSMRoadEnvironmentParser();
    CarFlagEncoder carEncoder = new CarFlagEncoder();
    EncodingManager em = new EncodingManager.Builder().add(carEncoder).add(parser).build();
    EnumEncodedValue<RoadEnvironment> roadEnvironmentEnc = em.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
    IntsRef edgeFlags = em.createEdgeFlags();
    ReaderWay way = new ReaderWay(0);
    way.setTag("route", "shuttle_train");
    parser.handleWayTags(edgeFlags, way, em.createRelationFlags());
    RoadEnvironment roadEnvironment = roadEnvironmentEnc.getEnum(false, edgeFlags);
    assertEquals(RoadEnvironment.FERRY, roadEnvironment);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) RoadEnvironment(com.graphhopper.routing.ev.RoadEnvironment) IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Test(org.junit.jupiter.api.Test)

Example 78 with IntsRef

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

the class OSMSurfaceParserTest 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(Surface.MISSING, surfaceEnc.getEnum(false, intsRef));
    readerWay.setTag("surface", "cobblestone");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(Surface.COBBLESTONE, surfaceEnc.getEnum(false, intsRef));
    assertTrue(Surface.COBBLESTONE.ordinal() > Surface.ASPHALT.ordinal());
    readerWay.setTag("surface", "earth");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(Surface.DIRT, surfaceEnc.getEnum(false, intsRef));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 79 with IntsRef

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

the class OSMTrackTypeParserTest method testNoNPE.

@Test
public void testNoNPE() {
    ReaderWay readerWay = new ReaderWay(1);
    IntsRef intsRef = em.createEdgeFlags();
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.MISSING, ttEnc.getEnum(false, intsRef));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 80 with IntsRef

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

the class OSMTrackTypeParserTest method testSimpleTags.

@Test
public void testSimpleTags() {
    ReaderWay readerWay = new ReaderWay(1);
    IntsRef intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "grade1");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.GRADE1, ttEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "grade2");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.GRADE2, ttEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "grade3");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.GRADE3, ttEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "grade4");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.GRADE4, ttEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay.setTag("tracktype", "grade5");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(TrackType.GRADE5, ttEnc.getEnum(false, intsRef));
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) 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