use of com.graphhopper.reader.ReaderRelation in project graphhopper by graphhopper.
the class OSMXMLHelper method createRelation.
public static ReaderRelation createRelation(long id, XMLStreamReader parser) throws XMLStreamException {
ReaderRelation rel = new ReaderRelation(id);
parser.nextTag();
readMembers(rel, parser);
readTags(rel, parser);
return rel;
}
use of com.graphhopper.reader.ReaderRelation in project graphhopper by graphhopper.
the class PbfBlobDecoder method processRelations.
private void processRelations(List<Osmformat.Relation> relations, PbfFieldDecoder fieldDecoder) {
for (Osmformat.Relation relation : relations) {
Map<String, String> tags = buildTags(relation.getKeysList(), relation.getValsList(), fieldDecoder);
ReaderRelation osmRelation = new ReaderRelation(relation.getId());
osmRelation.setTags(tags);
buildRelationMembers(osmRelation, relation.getMemidsList(), relation.getRolesSidList(), relation.getTypesList(), fieldDecoder);
// Add the bound object to the results.
decodedEntities.add(osmRelation);
}
}
use of com.graphhopper.reader.ReaderRelation in project graphhopper by graphhopper.
the class AbstractBikeFlagEncoderTester method testRelation.
@Test
public void testRelation() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
way.setTag("foot", "yes");
way.setTag("motor_vehicle", "agricultural");
way.setTag("surface", "gravel");
way.setTag("tracktype", "grade3");
ReaderRelation rel = new ReaderRelation(0);
rel.setTag("type", "route");
rel.setTag("network", "rcn");
rel.setTag("route", "bicycle");
ReaderRelation rel2 = new ReaderRelation(1);
rel2.setTag("type", "route");
rel2.setTag("network", "lcn");
rel2.setTag("route", "bicycle");
// two relation tags => we currently cannot store a list, so pick the lower ordinal 'regional'
// Example https://www.openstreetmap.org/way/213492914 => two hike 84544, 2768803 and two bike relations 3162932, 5254650
IntsRef relFlags = encodingManager.handleRelationTags(rel2, encodingManager.handleRelationTags(rel, encodingManager.createRelationFlags()));
IntsRef edgeFlags = encodingManager.handleWayTags(way, relFlags);
EnumEncodedValue<RouteNetwork> enc = encodingManager.getEnumEncodedValue(RouteNetwork.key("bike"), RouteNetwork.class);
assertEquals(RouteNetwork.REGIONAL, enc.getEnum(false, edgeFlags));
}
use of com.graphhopper.reader.ReaderRelation in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testCalcPriority.
@Test
public void testCalcPriority() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "tertiary");
ReaderRelation osmRel = new ReaderRelation(1);
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "icn");
IntsRef relFlags = encodingManager.handleRelationTags(osmRel, encodingManager.createRelationFlags());
IntsRef flags = encodingManager.handleWayTags(osmWay, relFlags);
assertEquals(PriorityCode.getValue(BEST.getValue()), priorityEnc.getDecimal(false, flags), .1);
// for some highways the priority is UNCHANGED
osmWay = new ReaderWay(1);
osmWay.setTag("highway", "track");
flags = encodingManager.handleWayTags(osmWay, encodingManager.createRelationFlags());
assertEquals(PriorityCode.getValue(UNCHANGED.getValue()), priorityEnc.getDecimal(false, flags), .1);
// for unknown highways we should probably keep the priority unchanged, but currently it does not matter
// because the access will be false anyway
osmWay = new ReaderWay(1);
osmWay.setTag("highway", "whatever");
flags = encodingManager.handleWayTags(osmWay, encodingManager.createRelationFlags());
assertEquals(EXCLUDE.getValue(), priorityEnc.getDecimal(false, flags), .1);
}
use of com.graphhopper.reader.ReaderRelation in project graphhopper by graphhopper.
the class BikeFlagEncoderTest method testHandleWayTagsInfluencedByRelation.
@Test
public void testHandleWayTagsInfluencedByRelation() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.setTag("highway", "road");
// unchanged
IntsRef flags = assertPriority(UNCHANGED.getValue(), osmWay);
assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// relation code is
ReaderRelation osmRel = new ReaderRelation(1);
osmRel.setTag("route", "bicycle");
flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
osmRel.setTag("network", "lcn");
flags = assertPriority(PREFER.getValue(), osmWay, osmRel);
assertEquals(12, avgSpeedEnc.getDecimal(false, flags), 1e-1);
// relation code is NICE
osmRel.setTag("network", "rcn");
assertPriority(VERY_NICE.getValue(), osmWay, osmRel);
// relation code is BEST
osmRel.setTag("network", "ncn");
assertPriority(BEST.getValue(), osmWay, osmRel);
// PREFER relation, but tertiary road => no get off the bike but road wayTypeCode and faster
osmWay.clearTags();
osmWay.setTag("highway", "tertiary");
osmRel.setTag("route", "bicycle");
osmRel.setTag("network", "lcn");
assertPriority(PREFER.getValue(), osmWay, osmRel);
}
Aggregations