Search in sources :

Example 36 with IntsRef

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

the class StringEncodedValueTest method testStoreTooManyEntries.

@Test
public void testStoreTooManyEntries() {
    StringEncodedValue prop = new StringEncodedValue("country", 3);
    prop.init(new EncodedValue.InitializerConfig());
    IntsRef ref = new IntsRef(1);
    assertEquals(null, prop.getString(false, ref));
    prop.setString(false, ref, "aut");
    assertEquals("aut", prop.getString(false, ref));
    prop.setString(false, ref, "deu");
    assertEquals("deu", prop.getString(false, ref));
    prop.setString(false, ref, "che");
    assertEquals("che", prop.getString(false, ref));
    try {
        prop.setString(false, ref, "xyz");
        fail("The encoded value should only allow a limited number of values");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().startsWith("Maximum number of values reached for"));
    }
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 37 with IntsRef

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

the class StringEncodedValueTest method testLookup.

@Test
public void testLookup() {
    StringEncodedValue prop = new StringEncodedValue("country", 3);
    prop.init(new EncodedValue.InitializerConfig());
    IntsRef ref = new IntsRef(1);
    assertEquals(null, prop.getString(false, ref));
    assertEquals(0, prop.getValues().size());
    prop.setString(false, ref, "aut");
    assertEquals("aut", prop.getString(false, ref));
    assertEquals(1, prop.getValues().size());
    prop.setString(false, ref, "deu");
    assertEquals("deu", prop.getString(false, ref));
    assertEquals(2, prop.getValues().size());
    prop.setString(false, ref, "che");
    assertEquals("che", prop.getString(false, ref));
    assertEquals(3, prop.getValues().size());
    prop.setString(false, ref, "deu");
    assertEquals("deu", prop.getString(false, ref));
    assertEquals(3, prop.getValues().size());
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 38 with IntsRef

use of com.graphhopper.storage.IntsRef 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 39 with IntsRef

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

the class AbstractBikeFlagEncoderTester method assertPriority.

protected IntsRef assertPriority(int expectedPrio, ReaderWay way, ReaderRelation rel) {
    IntsRef relFlags = encodingManager.handleRelationTags(rel, encodingManager.createRelationFlags());
    IntsRef edgeFlags = encodingManager.handleWayTags(way, relFlags);
    DecimalEncodedValue enc = encodingManager.getDecimalEncodedValue(EncodingManager.getKey(encoder.toString(), "priority"));
    assertEquals(PriorityCode.getValue(expectedPrio), enc.getDecimal(false, edgeFlags), 0.01);
    return edgeFlags;
}
Also used : IntsRef(com.graphhopper.storage.IntsRef)

Example 40 with IntsRef

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

the class AbstractBikeFlagEncoderTester method testTramStations.

@Test
public void testTramStations() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "rail");
    assertTrue(encoder.getAccess(way).isWay());
    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "station");
    assertTrue(encoder.getAccess(way).isWay());
    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "station");
    way.setTag("bicycle", "yes");
    assertTrue(encoder.getAccess(way).isWay());
    way.setTag("bicycle", "no");
    assertTrue(encoder.getAccess(way).canSkip());
    way = new ReaderWay(1);
    way.setTag("railway", "platform");
    IntsRef flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertNotEquals(true, flags.isEmpty());
    way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertNotEquals(true, flags.isEmpty());
    way = new ReaderWay(1);
    way.setTag("highway", "track");
    way.setTag("railway", "platform");
    way.setTag("bicycle", "no");
    flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
    assertEquals(true, flags.isEmpty());
}
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