use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class EncodingManagerTest method testMixBikeTypesAndRelationCombination.
@Test
public void testMixBikeTypesAndRelationCombination() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "track");
osmWay.setTag("tracktype", "grade1");
ReaderRelation osmRel = new ReaderRelation(1);
BikeFlagEncoder bikeEncoder = new BikeFlagEncoder();
MountainBikeFlagEncoder mtbEncoder = new MountainBikeFlagEncoder();
EncodingManager manager = EncodingManager.create(bikeEncoder, mtbEncoder);
// relation code for network rcn is NICE for bike and PREFER for mountainbike
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "rcn");
IntsRef relFlags = manager.handleRelationTags(osmRel, manager.createRelationFlags());
IntsRef edgeFlags = manager.handleWayTags(osmWay, relFlags);
// bike: uninfluenced speed for grade but via network => NICE
// mtb: uninfluenced speed only PREFER
assertTrue(bikeEncoder.priorityEnc.getDecimal(false, edgeFlags) > mtbEncoder.priorityEnc.getDecimal(false, edgeFlags));
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMRoadEnvironmentParserTest method ferry.
@Test
void ferry() {
OSMRoadEnvironmentParser parser = new OSMRoadEnvironmentParser();
CarFlagEncoder carEncoder = new CarFlagEncoder();
EncodingManager em = new EncodingManager.Builder().add(carEncoder).add(parser).build();
EnumEncodedValue<RoadEnvironment> roadEnvironmentEnc = em.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
IntsRef edgeFlags = em.createEdgeFlags();
ReaderWay way = new ReaderWay(0);
way.setTag("route", "shuttle_train");
parser.handleWayTags(edgeFlags, way, em.createRelationFlags());
RoadEnvironment roadEnvironment = roadEnvironmentEnc.getEnum(false, edgeFlags);
assertEquals(RoadEnvironment.FERRY, roadEnvironment);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMSurfaceParserTest 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(Surface.MISSING, surfaceEnc.getEnum(false, intsRef));
readerWay.setTag("surface", "cobblestone");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Surface.COBBLESTONE, surfaceEnc.getEnum(false, intsRef));
assertTrue(Surface.COBBLESTONE.ordinal() > Surface.ASPHALT.ordinal());
readerWay.setTag("surface", "earth");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(Surface.DIRT, surfaceEnc.getEnum(false, intsRef));
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMTrackTypeParserTest method testNoNPE.
@Test
public void testNoNPE() {
ReaderWay readerWay = new ReaderWay(1);
IntsRef intsRef = em.createEdgeFlags();
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.MISSING, ttEnc.getEnum(false, intsRef));
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMTrackTypeParserTest method testSimpleTags.
@Test
public void testSimpleTags() {
ReaderWay readerWay = new ReaderWay(1);
IntsRef intsRef = em.createEdgeFlags();
readerWay.setTag("tracktype", "grade1");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.GRADE1, ttEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("tracktype", "grade2");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.GRADE2, ttEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("tracktype", "grade3");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.GRADE3, ttEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("tracktype", "grade4");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.GRADE4, ttEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay.setTag("tracktype", "grade5");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(TrackType.GRADE5, ttEnc.getEnum(false, intsRef));
}
Aggregations