use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class FootFlagEncoderTest method testRailPlatformIssue366.
@Test
public void testRailPlatformIssue366() {
ReaderWay way = new ReaderWay(1);
way.setTag("railway", "platform");
IntsRef flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(flags.isEmpty());
way.clearTags();
way.setTag("highway", "track");
way.setTag("railway", "platform");
flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertFalse(flags.isEmpty());
way.clearTags();
// only tram, no highway => no access
way.setTag("railway", "tram");
flags = footEncoder.handleWayTags(encodingManager.createEdgeFlags(), way);
assertTrue(flags.isEmpty());
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class MountainBikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.
@Test
public void testHandleWayTagsInfluencedByRelation() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "track");
ReaderRelation osmRel = new ReaderRelation(1);
IntsRef relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
// unchanged
IntsRef flags = encodingManager.handleWayTags(osmWay, relFlags);
assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
assertPriority(PriorityCode.PREFER.getValue(), osmWay);
// relation code is PREFER
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "lcn");
relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
flags = encodingManager.handleWayTags(osmWay, relFlags);
assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
assertPriority(PriorityCode.PREFER.getValue(), osmWay);
// relation code is PREFER
osmRel.setTag("network", "rcn");
relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
flags = encodingManager.handleWayTags(osmWay, relFlags);
assertPriority(PriorityCode.PREFER.getValue(), osmWay);
assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// relation code is PREFER
osmRel.setTag("network", "ncn");
relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
flags = encodingManager.handleWayTags(osmWay, relFlags);
assertPriority(PriorityCode.PREFER.getValue(), osmWay);
assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// PREFER relation, but tertiary road
// => no pushing section but road wayTypeCode and faster
osmWay.clearTags();
osmWay.setTag("highway", "tertiary");
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "lcn");
relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
flags = encodingManager.handleWayTags(osmWay, relFlags);
assertEquals(18, avgSpeedEnc.getDecimal(false, flags), 1e-1);
assertPriority(PriorityCode.PREFER.getValue(), osmWay);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class RacingBikeFlagEncoderTest method testPriority_avoidanceOfHighMaxSpeed.
@Test
public void testPriority_avoidanceOfHighMaxSpeed() {
// here we test the priority that would be calculated if the way was accessible (even when it is not)
// therefore we need a modified encoder that always yields access=WAY
BikeCommonFlagEncoder encoder = new RacingBikeFlagEncoder(new PMap("block_fords=true")) {
@Override
public EncodingManager.Access getAccess(ReaderWay way) {
return WAY;
}
};
EncodingManager encodingManager = EncodingManager.create(encoder);
DecimalEncodedValue avgSpeedEnc = encoder.getAverageSpeedEnc();
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "tertiary");
osmWay.setTag("maxspeed", "50");
IntsRef intsRef = encodingManager.createEdgeFlags();
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "60");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "80");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, PREFER.getValue(), osmWay);
osmWay.setTag("maxspeed", "90");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
osmWay.setTag("highway", "motorway");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID.getValue(), osmWay);
osmWay.setTag("tunnel", "yes");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "motorway");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "80");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "motorway");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "notdefined");
osmWay.setTag("tunnel", "yes");
osmWay.setTag("maxspeed", "120");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, AVOID_MORE.getValue(), osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "notdefined");
osmWay.setTag("maxspeed", "50");
encoder.setSpeed(false, intsRef, encoder.applyMaxSpeed(osmWay, 20));
assertEquals(20, avgSpeedEnc.getDecimal(false, intsRef), 1e-1);
assertPriority(encodingManager, UNCHANGED.getValue(), osmWay);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMRoadAccessParserTest method countryRule.
@Test
void countryRule() {
EncodingManager em = EncodingManager.create("car");
EnumEncodedValue<RoadAccess> roadAccessEnc = em.getEnumEncodedValue(RoadAccess.KEY, RoadAccess.class);
Graph graph = new GraphBuilder(em).create();
FlagEncoder encoder = em.getEncoder("car");
EdgeIteratorState e1 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(0, 1).setDistance(100));
EdgeIteratorState e2 = GHUtility.setSpeed(60, true, true, encoder, graph.edge(1, 2).setDistance(100));
OSMRoadAccessParser parser = new OSMRoadAccessParser(roadAccessEnc, OSMRoadAccessParser.toOSMRestrictions(TransportationMode.CAR));
IntsRef relFlags = em.createRelationFlags();
ReaderWay way = new ReaderWay(27L);
way.setTag("highway", "track");
way.setTag("country_rule", new CountryRule() {
@Override
public RoadAccess getAccess(ReaderWay readerWay, TransportationMode transportationMode, RoadAccess currentRoadAccess) {
return RoadAccess.DESTINATION;
}
});
parser.handleWayTags(e1.getFlags(), way, relFlags);
assertEquals(RoadAccess.DESTINATION, e1.get(roadAccessEnc));
// if there is no country rule we get the default value
way.removeTag("country_rule");
parser.handleWayTags(e2.getFlags(), way, relFlags);
assertEquals(RoadAccess.YES, e2.get(roadAccessEnc));
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMTollParserTest method testSimpleTags.
@Test
public void testSimpleTags() {
ReaderWay readerWay = new ReaderWay(1);
IntsRef relFlags = em.createRelationFlags();
IntsRef intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.MISSING, tollEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
readerWay.setTag("toll:hgv", "yes");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.HGV, tollEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
readerWay.setTag("toll:N2", "yes");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.HGV, tollEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
readerWay.setTag("toll:N3", "yes");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.HGV, tollEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
readerWay.setTag("toll", "yes");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.ALL, tollEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("highway", "primary");
readerWay.setTag("toll", "yes");
readerWay.setTag("toll:hgv", "yes");
readerWay.setTag("toll:N2", "yes");
readerWay.setTag("toll:N3", "yes");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Toll.ALL, tollEnc.getEnum(false, intsRef));
}
Aggregations