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"));
}
}
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());
}
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);
}
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;
}
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());
}
Aggregations