Search in sources :

Example 1 with StreetTraversalPermission

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);
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) I18NString(org.opentripplanner.util.I18NString) Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) LineString(com.vividsolutions.jts.geom.LineString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) I18NString(org.opentripplanner.util.I18NString)

Example 2 with StreetTraversalPermission

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);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) LineString(com.vividsolutions.jts.geom.LineString)

Example 3 with StreetTraversalPermission

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;
}
Also used : StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) ConflictingBikeTags(org.opentripplanner.graph_builder.annotation.ConflictingBikeTags)

Example 4 with StreetTraversalPermission

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);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) LineString(com.vividsolutions.jts.geom.LineString)

Example 5 with StreetTraversalPermission

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);
}
Also used : StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) WayProperties(org.opentripplanner.graph_builder.module.osm.WayProperties) WayPropertySet(org.opentripplanner.graph_builder.module.osm.WayPropertySet)

Aggregations

StreetTraversalPermission (org.opentripplanner.routing.edgetype.StreetTraversalPermission)16 LineString (com.vividsolutions.jts.geom.LineString)10 Coordinate (com.vividsolutions.jts.geom.Coordinate)9 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)8 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 P2 (org.opentripplanner.common.model.P2)3 I18NString (org.opentripplanner.util.I18NString)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 Point (com.vividsolutions.jts.geom.Point)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 OSMWithTags (org.opentripplanner.openstreetmap.model.OSMWithTags)2 NamedArea (org.opentripplanner.routing.edgetype.NamedArea)2 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)2 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)2 VLPoint (org.opentripplanner.visibility.VLPoint)2 Polygon (com.vividsolutions.jts.geom.Polygon)1 Point (java.awt.Point)1