use of com.graphhopper.reader.ReaderWay 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.reader.ReaderWay 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));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class OSMHazmatTunnelParserTest method testIgnoreNonTunnelSubtags.
@Test
public void testIgnoreNonTunnelSubtags() {
IntsRef intsRef = em.createEdgeFlags();
ReaderWay readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:B", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class OSMHazmatTunnelParserTest method testTunnelCat.
@Test
public void testTunnelCat() {
IntsRef intsRef = em.createEdgeFlags();
ReaderWay readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:tunnel_cat", "A");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:tunnel_cat", "B");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.B, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:tunnel_cat", "C");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.C, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:tunnel_cat", "D");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.D, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("hazmat:tunnel_cat", "E");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.E, hazTunnelEnc.getEnum(false, intsRef));
}
use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.
the class OSMHazmatTunnelParserTest method testHazmatSubtags.
@Test
public void testHazmatSubtags() {
IntsRef intsRef = em.createEdgeFlags();
ReaderWay readerWay = new ReaderWay(1);
readerWay.setTag("tunnel", "yes");
readerWay.setTag("hazmat:A", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.A, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("tunnel", "yes");
readerWay.setTag("hazmat:B", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.B, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("tunnel", "yes");
readerWay.setTag("hazmat:C", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.C, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("tunnel", "yes");
readerWay.setTag("hazmat:D", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.D, hazTunnelEnc.getEnum(false, intsRef));
intsRef = em.createEdgeFlags();
readerWay = new ReaderWay(1);
readerWay.setTag("tunnel", "yes");
readerWay.setTag("hazmat:E", "no");
parser.handleWayTags(intsRef, readerWay, relFlags);
assertEquals(HazmatTunnel.E, hazTunnelEnc.getEnum(false, intsRef));
}
Aggregations