Search in sources :

Example 1 with EnumEncodedValue

use of com.graphhopper.routing.ev.EnumEncodedValue 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

EnumEncodedValue (com.graphhopper.routing.ev.EnumEncodedValue)1 RoadClass (com.graphhopper.routing.ev.RoadClass)1 RoadEnvironment (com.graphhopper.routing.ev.RoadEnvironment)1 IntsRef (com.graphhopper.storage.IntsRef)1 GHUtility (com.graphhopper.util.GHUtility)1 Arrays (java.util.Arrays)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Test (org.junit.jupiter.api.Test)1