Search in sources :

Example 31 with IntsRef

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);
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) Test(org.junit.jupiter.api.Test)

Example 32 with IntsRef

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);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 33 with IntsRef

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) {
    }
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 34 with IntsRef

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);
}
Also used : IntsRef(com.graphhopper.storage.IntsRef) Test(org.junit.jupiter.api.Test)

Example 35 with IntsRef

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());
}
Also used : 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