use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.
the class OSMDatabase method processRestriction.
/**
* Store turn restrictions.
*
* @param relation
*/
private void processRestriction(OSMRelation relation) {
long from = -1, to = -1, via = -1;
for (OSMRelationMember member : relation.getMembers()) {
String role = member.getRole();
if (role.equals("from")) {
from = member.getRef();
} else if (role.equals("to")) {
to = member.getRef();
} else if (role.equals("via")) {
via = member.getRef();
}
}
if (from == -1 || to == -1 || via == -1) {
LOG.warn(addBuilderAnnotation(new TurnRestrictionBad(relation.getId(), "One of from|via|to edges are empty in relation")));
return;
}
TraverseModeSet modes = new TraverseModeSet(TraverseMode.BICYCLE, TraverseMode.CAR);
String exceptModes = relation.getTag("except");
if (exceptModes != null) {
for (String m : exceptModes.split(";")) {
if (m.equals("motorcar")) {
modes.setCar(false);
} else if (m.equals("bicycle")) {
modes.setBicycle(false);
LOG.debug(addBuilderAnnotation(new TurnRestrictionException(via, from)));
}
}
}
TurnRestrictionTag tag;
if (relation.isTag("restriction", "no_right_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.RIGHT, relation.getId());
} else if (relation.isTag("restriction", "no_left_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.LEFT, relation.getId());
} else if (relation.isTag("restriction", "no_straight_on")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.STRAIGHT, relation.getId());
} else if (relation.isTag("restriction", "no_u_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.U, relation.getId());
} else if (relation.isTag("restriction", "only_straight_on")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.STRAIGHT, relation.getId());
} else if (relation.isTag("restriction", "only_right_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.RIGHT, relation.getId());
} else if (relation.isTag("restriction", "only_left_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.LEFT, relation.getId());
} else if (relation.isTag("restriction", "only_u_turn")) {
tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.U, relation.getId());
} else {
LOG.warn(addBuilderAnnotation(new TurnRestrictionUnknown(relation.getId(), relation.getTag("restriction"))));
return;
}
tag.modes = modes.clone();
// set the time periods for this restriction, if applicable
if (relation.hasTag("day_on") && relation.hasTag("day_off") && relation.hasTag("hour_on") && relation.hasTag("hour_off")) {
try {
tag.time = RepeatingTimePeriod.parseFromOsmTurnRestriction(relation.getTag("day_on"), relation.getTag("day_off"), relation.getTag("hour_on"), relation.getTag("hour_off"));
} catch (NumberFormatException e) {
LOG.info("Unparseable turn restriction: " + relation.getId());
}
}
turnRestrictionsByFromWay.put(from, tag);
turnRestrictionsByToWay.put(to, tag);
}
use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.
the class TriangleInequalityTest method testTriangleInequalityDrivingOnly.
@Test
public void testTriangleInequalityDrivingOnly() {
TraverseModeSet modes = new TraverseModeSet(TraverseMode.CAR);
checkTriangleInequality(modes);
}
use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.
the class TriangleInequalityTest method testTriangleInequalityWalkTransitMultiSPT.
@Test
public void testTriangleInequalityWalkTransitMultiSPT() {
TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT);
checkTriangleInequality(modes);
}
use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.
the class TriangleInequalityTest method testTriangleInequalityWalkingOnlyBasicSPT.
@Test
public void testTriangleInequalityWalkingOnlyBasicSPT() {
TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK);
checkTriangleInequality(modes);
}
use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.
the class TriangleInequalityTest method testTriangleInequalityDrivingOnlyBasicSPT.
@Test
public void testTriangleInequalityDrivingOnlyBasicSPT() {
TraverseModeSet modes = new TraverseModeSet(TraverseMode.CAR);
checkTriangleInequality(modes);
}
Aggregations