Search in sources :

Example 61 with IntsRef

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

the class OSMHazmatTunnelParserTest method testIgnoreNonTunnelSubtags.

@Test
public void testIgnoreNonTunnelSubtags() {
    IntsRef intsRef = em.createEdgeFlags();
    ReaderWay readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:B", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 62 with IntsRef

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

the class OSMHazmatTunnelParserTest method testTunnelCat.

@Test
public void testTunnelCat() {
    IntsRef intsRef = em.createEdgeFlags();
    ReaderWay readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:tunnel_cat", "A");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:tunnel_cat", "B");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.B, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:tunnel_cat", "C");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.C, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:tunnel_cat", "D");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.D, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("hazmat:tunnel_cat", "E");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.E, hazTunnelEnc.getEnum(false, intsRef));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 63 with IntsRef

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

the class OSMHazmatTunnelParserTest method testHazmatSubtags.

@Test
public void testHazmatSubtags() {
    IntsRef intsRef = em.createEdgeFlags();
    ReaderWay readerWay = new ReaderWay(1);
    readerWay.setTag("tunnel", "yes");
    readerWay.setTag("hazmat:A", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("tunnel", "yes");
    readerWay.setTag("hazmat:B", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.B, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("tunnel", "yes");
    readerWay.setTag("hazmat:C", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.C, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("tunnel", "yes");
    readerWay.setTag("hazmat:D", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.D, hazTunnelEnc.getEnum(false, intsRef));
    intsRef = em.createEdgeFlags();
    readerWay = new ReaderWay(1);
    readerWay.setTag("tunnel", "yes");
    readerWay.setTag("hazmat:E", "no");
    parser.handleWayTags(intsRef, readerWay, relFlags);
    assertEquals(HazmatTunnel.E, hazTunnelEnc.getEnum(false, intsRef));
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 64 with IntsRef

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

the class ExpressionVisitorTest method before.

@BeforeEach
public void before() {
    StringEncodedValue sev = new StringEncodedValue("country", 10);
    lookup = new GraphBuilder(new EncodingManager.Builder().add(sev).build()).create().getEncodingManager();
    sev.setString(false, new IntsRef(1), "DEU");
}
Also used : GraphBuilder(com.graphhopper.storage.GraphBuilder) StringEncodedValue(com.graphhopper.routing.ev.StringEncodedValue) GraphBuilder(com.graphhopper.storage.GraphBuilder) IntsRef(com.graphhopper.storage.IntsRef) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 65 with IntsRef

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

the class SnapPreventionEdgeFilterTest method accept.

@Test
public void accept() {
    EdgeFilter trueFilter = edgeState -> true;
    EncodingManager em = new EncodingManager.Builder().build();
    EnumEncodedValue<RoadClass> rcEnc = em.getEnumEncodedValue(RoadClass.KEY, RoadClass.class);
    EnumEncodedValue<RoadEnvironment> reEnc = em.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
    SnapPreventionEdgeFilter filter = new SnapPreventionEdgeFilter(trueFilter, rcEnc, reEnc, Arrays.asList("motorway", "ferry"));
    IntsRef intsRef = em.createEdgeFlags();
    assertTrue(filter.accept(GHUtility.createMockedEdgeIteratorState(1, intsRef)));
    reEnc.setEnum(false, intsRef, RoadEnvironment.FERRY);
    assertFalse(filter.accept(GHUtility.createMockedEdgeIteratorState(1, intsRef)));
    reEnc.setEnum(false, intsRef, RoadEnvironment.FORD);
    assertTrue(filter.accept(GHUtility.createMockedEdgeIteratorState(1, intsRef)));
    rcEnc.setEnum(false, intsRef, RoadClass.RESIDENTIAL);
    assertTrue(filter.accept(GHUtility.createMockedEdgeIteratorState(1, intsRef)));
    rcEnc.setEnum(false, intsRef, RoadClass.MOTORWAY);
    assertFalse(filter.accept(GHUtility.createMockedEdgeIteratorState(1, intsRef)));
}
Also used : RoadEnvironment(com.graphhopper.routing.ev.RoadEnvironment) Test(org.junit.jupiter.api.Test) Arrays(java.util.Arrays) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RoadClass(com.graphhopper.routing.ev.RoadClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IntsRef(com.graphhopper.storage.IntsRef) GHUtility(com.graphhopper.util.GHUtility) EnumEncodedValue(com.graphhopper.routing.ev.EnumEncodedValue) RoadEnvironment(com.graphhopper.routing.ev.RoadEnvironment) RoadClass(com.graphhopper.routing.ev.RoadClass) 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