use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testOneway.
@Test
public void testOneway() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "tertiary");
IntsRef flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.setTag("oneway", "yes");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertFalse(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("oneway:bicycle", "yes");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertFalse(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("vehicle:forward", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("bicycle:forward", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("vehicle:backward", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertFalse(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("motor_vehicle:backward", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("oneway", "yes");
way.setTag("bicycle:backward", "no");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertFalse(encoder.getAccessEnc().getBool(true, flags));
way.setTag("bicycle:backward", "yes");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "residential");
way.setTag("oneway", "yes");
way.setTag("bicycle:backward", "yes");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "residential");
way.setTag("oneway", "-1");
way.setTag("bicycle:forward", "yes");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("bicycle:forward", "use_sidepath");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("bicycle:forward", "use_sidepath");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "tertiary");
way.setTag("oneway", "yes");
way.setTag("cycleway", "opposite");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
way.clearTags();
way.setTag("highway", "residential");
way.setTag("oneway", "yes");
way.setTag("cycleway:left", "opposite_lane");
flags = encoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(encoder.getAccessEnc().getBool(false, flags));
assertTrue(encoder.getAccessEnc().getBool(true, flags));
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class AbstractBikeFlagEncoderTester method testHandleWayTagsCallsHandlePriority.
@Test
public void testHandleWayTagsCallsHandlePriority() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "cycleway");
IntsRef edgeFlags = encoder.handleWayTags(encodingManager.createEdgeFlags(), osmWay);
DecimalEncodedValue priorityEnc = encodingManager.getDecimalEncodedValue(EncodingManager.getKey(encoder, "priority"));
assertEquals(PriorityCode.getValue(VERY_NICE.getValue()), priorityEnc.getDecimal(false, edgeFlags), 1e-3);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMSmoothnessParserTest method testSimpleTags.
@Test
public void testSimpleTags() {
IntsRef relFlags = em.createRelationFlags();
ReaderWay readerWay = new ReaderWay(1);
IntsRef intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Smoothness.MISSING, smoothnessEnc.getEnum(false, intsRef));
readerWay.setTag("smoothness", "bad");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Smoothness.BAD, smoothnessEnc.getEnum(false, intsRef));
assertTrue(Smoothness.BAD.ordinal() < Smoothness.VERY_BAD.ordinal());
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class AbstractBikeFlagEncoderTester method getSpeedFromFlags.
protected double getSpeedFromFlags(ReaderWay way) {
IntsRef relFlags = encodingManager.createRelationFlags();
IntsRef flags = encodingManager.handleWayTags(way, relFlags);
return avgSpeedEnc.getDecimal(false, flags);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class EncodingManagerTest method testCombineRelations.
@Test
public void testCombineRelations() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "track");
ReaderRelation osmRel = new ReaderRelation(1);
BikeFlagEncoder defaultBike = new BikeFlagEncoder();
BikeFlagEncoder lessRelationCodes = new BikeFlagEncoder() {
@Override
public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay way) {
if (bikeRouteEnc.getEnum(false, edgeFlags) != RouteNetwork.MISSING)
priorityEnc.setDecimal(false, edgeFlags, PriorityCode.getFactor(2));
return edgeFlags;
}
@Override
public String getName() {
return "less_relations_bits";
}
};
EncodingManager manager = new EncodingManager.Builder().add(lessRelationCodes).add(defaultBike).build();
// relation code is PREFER
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "lcn");
IntsRef relFlags = manager.handleRelationTags(osmRel, manager.createRelationFlags());
IntsRef edgeFlags = manager.handleWayTags(osmWay, relFlags);
assertTrue(defaultBike.priorityEnc.getDecimal(false, edgeFlags) > lessRelationCodes.priorityEnc.getDecimal(false, edgeFlags));
}
Aggregations