Search in sources :

Example 1 with CarTagParser

use of com.graphhopper.routing.util.CarTagParser in project graphhopper by graphhopper.

the class DecimalEncodedValueTest method testMaxValue.

@Test
public void testMaxValue() {
    FlagEncoder carEncoder = FlagEncoders.createCar(new PMap("speed_bits=10|speed_factor=0.5"));
    EncodingManager em = EncodingManager.create(carEncoder);
    DecimalEncodedValue carAverageSpeedEnc = em.getDecimalEncodedValue(EncodingManager.getKey(carEncoder, "average_speed"));
    CarTagParser carTagParser = new CarTagParser(em, new PMap());
    carTagParser.init(new DateRangeParser());
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway_link");
    way.setTag("maxspeed", "70 mph");
    IntsRef flags = carTagParser.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) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) CarTagParser(com.graphhopper.routing.util.CarTagParser) PMap(com.graphhopper.util.PMap) ReaderWay(com.graphhopper.reader.ReaderWay) IntsRef(com.graphhopper.storage.IntsRef) DateRangeParser(com.graphhopper.reader.osm.conditional.DateRangeParser) Test(org.junit.jupiter.api.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)1 DateRangeParser (com.graphhopper.reader.osm.conditional.DateRangeParser)1 CarTagParser (com.graphhopper.routing.util.CarTagParser)1 EncodingManager (com.graphhopper.routing.util.EncodingManager)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 IntsRef (com.graphhopper.storage.IntsRef)1 PMap (com.graphhopper.util.PMap)1 Test (org.junit.jupiter.api.Test)1