use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueTest method testMaxValue.
@Test
public void testMaxValue() {
CarFlagEncoder carEncoder = new CarFlagEncoder(10, 0.5, 0);
EncodingManager em = EncodingManager.create(carEncoder);
DecimalEncodedValue carAverageSpeedEnc = em.getDecimalEncodedValue(EncodingManager.getKey(carEncoder, "average_speed"));
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "motorway_link");
way.setTag("maxspeed", "70 mph");
IntsRef flags = carEncoder.handleWayTags(em.createEdgeFlags(), way);
assertEquals(101.5, carAverageSpeedEnc.getDecimal(true, flags), 1e-1);
DecimalEncodedValue instance1 = new DecimalEncodedValueImpl("test1", 8, 0.5, false);
instance1.init(new EncodedValue.InitializerConfig());
flags = em.createEdgeFlags();
instance1.setDecimal(false, flags, 100d);
assertEquals(100, instance1.getDecimal(false, flags), 1e-1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueTest method testInit.
@Test
public void testInit() {
DecimalEncodedValue prop = new DecimalEncodedValueImpl("test", 10, 2, false);
prop.init(new EncodedValue.InitializerConfig());
IntsRef ref = new IntsRef(1);
prop.setDecimal(false, ref, 10d);
assertEquals(10d, prop.getDecimal(false, ref), 0.1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueTest method testNegativeBounds.
@Test
public void testNegativeBounds() {
DecimalEncodedValue prop = new DecimalEncodedValueImpl("test", 10, 5, false);
prop.init(new EncodedValue.InitializerConfig());
try {
prop.setDecimal(false, new IntsRef(1), -1);
assertTrue(false);
} catch (Exception ex) {
}
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class MaxWeightTest method testSetAndGet.
@Test
public void testSetAndGet() {
DecimalEncodedValue mappedDecimalEnc = MaxWeight.create();
mappedDecimalEnc.init(new EncodedValue.InitializerConfig());
IntsRef intsRef = new IntsRef(1);
mappedDecimalEnc.setDecimal(false, intsRef, 20);
assertEquals(20, mappedDecimalEnc.getDecimal(false, intsRef), .1);
intsRef = new IntsRef(1);
mappedDecimalEnc.setDecimal(false, intsRef, Double.POSITIVE_INFINITY);
assertEquals(Double.POSITIVE_INFINITY, mappedDecimalEnc.getDecimal(false, intsRef), .1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class StringEncodedValueTest method testNull.
@Test
public void testNull() {
StringEncodedValue prop = new StringEncodedValue("country", 3);
prop.init(new EncodedValue.InitializerConfig());
IntsRef ref = new IntsRef(1);
prop.setString(false, ref, null);
assertEquals(0, prop.getValues().size());
}
Aggregations