use of org.opentripplanner.routing.edgetype.StreetTraversalPermission in project OpenTripPlanner by opentripplanner.
the class PlatformLinker method makePlatformEdges.
private void makePlatformEdges(Area area, OsmVertex from, OsmVertex to) {
Coordinate[] coordinates = new Coordinate[] { from.getCoordinate(), to.getCoordinate() };
GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory();
LineString line = geometryFactory.createLineString(coordinates);
double length = SphericalDistanceLibrary.distance(from.getCoordinate(), to.getCoordinate());
StreetTraversalPermission areaPermissions = OSMFilter.getPermissionsForEntity(area.parent, StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE);
String labelFromTo = "way (area) " + area.parent.getId() + " from " + from.getLabel() + " to " + to.getLabel();
I18NString nameFromTo = getNameForWay(area.parent, labelFromTo);
factory.createEdge(from, to, line, nameFromTo, length, areaPermissions, true);
String labelToFrom = "way (area) " + area.parent.getId() + " from " + to.getLabel() + " to " + from.getLabel();
I18NString nameToFrom = getNameForWay(area.parent, labelToFrom);
factory.createEdge(to, from, line, nameToFrom, length, areaPermissions, true);
}
use of org.opentripplanner.routing.edgetype.StreetTraversalPermission in project OpenTripPlanner by opentripplanner.
the class BarrierVertexTest method edge.
/**
* Create an edge. If twoWay, create two edges (back and forth).
*
* @param vA
* @param vB
* @param length
* @param back true if this is a reverse edge
*/
private StreetEdge edge(StreetVertex vA, StreetVertex vB, double length, boolean back) {
String labelA = vA.getLabel();
String labelB = vB.getLabel();
String name = String.format("%s_%s", labelA, labelB);
Coordinate[] coords = new Coordinate[2];
coords[0] = vA.getCoordinate();
coords[1] = vB.getCoordinate();
LineString geom = GeometryUtils.getGeometryFactory().createLineString(coords);
StreetTraversalPermission perm = StreetTraversalPermission.ALL;
return new StreetEdge(vA, vB, geom, name, length, perm, back);
}
use of org.opentripplanner.routing.edgetype.StreetTraversalPermission in project OpenTripPlanner by opentripplanner.
the class OSMFilter method getPermissionsForWay.
/**
* Computes permissions for an OSMWay.
*
* @param way
* @param def
* @return
*/
public static StreetTraversalPermission getPermissionsForWay(OSMWay way, StreetTraversalPermission def, Graph graph, boolean banDiscouragedWalking, boolean banDiscouragedBiking) {
StreetTraversalPermission permissions = getPermissionsForEntity(way, def);
// Compute pedestrian permissions.
if (way.isPedestrianExplicitlyAllowed()) {
permissions = permissions.add(StreetTraversalPermission.PEDESTRIAN);
} else if (way.isPedestrianExplicitlyDenied()) {
permissions = permissions.remove(StreetTraversalPermission.PEDESTRIAN);
}
// Check for foot=discouraged, if applicable
if (banDiscouragedWalking && way.hasTag("foot") && way.getTag("foot").equals("discouraged")) {
permissions = permissions.remove(StreetTraversalPermission.PEDESTRIAN);
}
// Compute bike permissions, check consistency.
boolean forceBikes = false;
if (way.isBicycleExplicitlyAllowed()) {
permissions = permissions.add(StreetTraversalPermission.BICYCLE);
forceBikes = true;
}
if (way.isBicycleDismountForced() || (banDiscouragedBiking && way.hasTag("bicycle") && way.getTag("bicycle").equals("discouraged"))) {
permissions = permissions.remove(StreetTraversalPermission.BICYCLE);
if (forceBikes) {
LOG.warn(graph.addBuilderAnnotation(new ConflictingBikeTags(way.getId())));
}
}
return permissions;
}
use of org.opentripplanner.routing.edgetype.StreetTraversalPermission in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method edge.
/**
* Create an edge. If twoWay, create two edges (back and forth).
*
* @param vA
* @param vB
* @param length
* @param back true if this is a reverse edge
*/
private StreetEdge edge(StreetVertex vA, StreetVertex vB, double length, boolean back) {
String labelA = vA.getLabel();
String labelB = vB.getLabel();
String name = String.format("%s_%s", labelA, labelB);
Coordinate[] coords = new Coordinate[2];
coords[0] = vA.getCoordinate();
coords[1] = vB.getCoordinate();
LineString geom = GeometryUtils.getGeometryFactory().createLineString(coords);
StreetTraversalPermission perm = StreetTraversalPermission.ALL;
return new StreetEdge(vA, vB, geom, name, length, perm, back);
}
use of org.opentripplanner.routing.edgetype.StreetTraversalPermission in project OpenTripPlanner by opentripplanner.
the class OSMWayTest method getWayProperties.
private P2<StreetTraversalPermission> getWayProperties(OSMWay way) {
WayPropertySet wayPropertySet = new WayPropertySet();
WayProperties wayData = wayPropertySet.getDataForWay(way);
StreetTraversalPermission permissions = OSMFilter.getPermissionsForWay(way, wayData.getPermission(), null);
return OSMFilter.getPermissions(permissions, way);
}
Aggregations