@Test public void testPriority() { long flags = encoder.priorityWayEncoder.setValue(0, PriorityCode.BEST.getValue()); assertEquals(1, encoder.getDouble(flags, PriorityWeighting.KEY), 1e-3); flags = encoder.priorityWayEncoder.setValue(0, PriorityCode.AVOID_IF_POSSIBLE.getValue()); assertEquals(3d / 7d, encoder.getDouble(flags, PriorityWeighting.KEY), 1e-3); }
@Test public void testHandleWayTagsCallsHandlePriority() { ReaderWay osmWay = new ReaderWay(1); osmWay.setTag("highway", "cycleway"); long encoded = encoder.handleWayTags(osmWay, encoder.acceptBit, 0); assertEquals((double) VERY_NICE.getValue() / BEST.getValue(), encoder.getDouble(encoded, PriorityWeighting.KEY), 1e-3); }
@Test public void testCalcPriority() { long allowed = encoder.acceptBit; ReaderWay osmWay = new ReaderWay(1); ReaderRelation osmRel = new ReaderRelation(1); osmRel.setTag("route", "bicycle"); osmRel.setTag("network", "icn"); long relFlags = encoder.handleRelationTags(osmRel, 0); long flags = encoder.handleWayTags(osmWay, allowed, relFlags); assertEquals((double) BEST.getValue() / BEST.getValue(), encoder.getDouble(flags, PriorityWeighting.KEY), 1e-3); // important: UNCHANGED should not get 0 priority! osmWay = new ReaderWay(1); osmWay.setTag("highway", "somethingelse"); flags = encoder.handleWayTags(osmWay, allowed, 0); assertEquals((double) UNCHANGED.getValue() / BEST.getValue(), encoder.getDouble(flags, PriorityWeighting.KEY), 1e-3); }