Package org.opentripplanner.routing.edgetype

Examples of org.opentripplanner.routing.edgetype.StreetEdge


     */
    private void pruneAreaEdges(Collection<Vertex> startingVertices, Set<Edge> edges) {
        if (edges.size() == 0)
            return;
        TraverseMode mode;
        StreetEdge firstEdge = (StreetEdge) edges.iterator().next();

        if (firstEdge.getPermission().allows(StreetTraversalPermission.PEDESTRIAN)) {
            mode = TraverseMode.WALK;
        } else if (firstEdge.getPermission().allows(StreetTraversalPermission.BICYCLE)) {
            mode = TraverseMode.BICYCLE;
        } else {
            mode = TraverseMode.CAR;
        }
        RoutingRequest options = new RoutingRequest(mode);
View Full Code Here


            double bestElevation = 0;
            for (Edge e : state.vertex.getOutgoing()) {
                if (!(e instanceof StreetEdge)) {
                    continue;
                }
                StreetEdge edge = (StreetEdge) e;
                Vertex tov = e.getToVertex();
                if (tov == initialVertex)
                    continue;

                Double elevation = elevations.get(tov);
                if (elevation != null) {
                    double distance = e.getDistance();
                    if (distance < bestDistance) {
                        bestDistance = distance;
                        bestElevation = elevation;
                    }
                } else {
                    // continue
                    ElevationRepairState newState = new ElevationRepairState(edge, state, tov,
                            e.getDistance() + state.distance, state.initialElevation);
                    pq.insert(newState, e.getDistance() + state.distance);
                }
            } // end loop over outgoing edges

            for (Edge e : state.vertex.getIncoming()) {
                if (!(e instanceof StreetEdge)) {
                    continue;
                }
                StreetEdge edge = (StreetEdge) e;
                Vertex fromv = e.getFromVertex();
                if (fromv == initialVertex)
                    continue;
                Double elevation = elevations.get(fromv);
                if (elevation != null) {
                    double distance = e.getDistance();
                    if (distance < bestDistance) {
                        bestDistance = distance;
                        bestElevation = elevation;
                    }
                } else {
                    // continue
                    ElevationRepairState newState = new ElevationRepairState(edge, state, fromv,
                            e.getDistance() + state.distance, state.initialElevation);
                    pq.insert(newState, e.getDistance() + state.distance);
                }
            } // end loop over incoming edges

            //limit elevation propagation to at max 2km; this prevents an infinite loop
            //in the case of islands missing elevation (and some other cases)
            if (bestDistance == Double.MAX_VALUE && state.distance > 2000) {
                log.warn("While propagating elevations, hit 2km distance limit at " + state.vertex);
                bestDistance = state.distance;
                bestElevation = state.initialElevation;
            }
            if (bestDistance != Double.MAX_VALUE) {
                // we have found a second vertex with elevation, so we can interpolate the elevation
                // for this point
                double totalDistance = bestDistance + state.distance;
                // trace backwards, setting states as we go
                while (true) {
                    // watch out for division by 0 here, which will propagate NaNs
                    // all the way out to edge lengths
                    if (totalDistance == 0)
                        elevations.put(state.vertex, bestElevation);
                    else {
                        double elevation = (bestElevation * state.distance +
                               state.initialElevation * bestDistance) / totalDistance;
                        elevations.put(state.vertex, elevation);
                    }
                    if (state.backState == null)
                        break;
                    bestDistance += state.backEdge.getDistance();
                    state = state.backState;
                    if (elevations.containsKey(state.vertex))
                        break;
                }

            }
        } // end loop over states

        // do actual assignments
        for (Vertex v : graph.getVertices()) {
            Double fromElevation = elevations.get(v);
            for (Edge e : v.getOutgoing()) {
                if (e instanceof StreetWithElevationEdge) {
                    StreetWithElevationEdge edge = ((StreetWithElevationEdge) e);

                    Double toElevation = elevations.get(edge.getToVertex());

                    if (fromElevation == null || toElevation == null) {
                        if (!edge.isElevationFlattened() && !edge.isSlopeOverride())
                            log.warn("Unexpectedly missing elevation for edge " + edge);
                        continue;
                    }

                    if (edge.getElevationProfile() != null && edge.getElevationProfile().size() > 2) {
                        continue;
                    }

                    Coordinate[] coords = new Coordinate[2];
                    coords[0] = new Coordinate(0, fromElevation);
                    coords[1] = new Coordinate(edge.getDistance(), toElevation);

                    PackedCoordinateSequence profile = new PackedCoordinateSequence.Double(coords);

                    if (edge.setElevationProfile(profile, true)) {
                        log.trace(graph.addBuilderAnnotation(new ElevationFlattened(edge)));
                    }
                }
            }
        }
View Full Code Here

                        }
                    }
                    P2<StreetEdge> streets = getEdgesForStreet(startEndpoint, endEndpoint,
                            way, i, osmStartNode.getId(), osmEndNode.getId(), permissions, geometry);

                    StreetEdge street = streets.first;
                    StreetEdge backStreet = streets.second;
                    applyWayProperties(street, backStreet, wayData, way);

                    applyEdgesToTurnRestrictions(way, startNode, endNode, street, backStreet);
                    startNode = endNode;
                    osmStartNode = osmdb.getNode(startNode);
View Full Code Here

                        }
                    }
                    if (!(e instanceof StreetEdge)) {
                        continue;
                    }
                    StreetEdge pse = (StreetEdge) e;

                    if (!seenEdges.contains(e)) {
                        seenEdges.add(e);
                        pse.setBicycleSafetyFactor(pse.getBicycleSafetyFactor() / bestBikeSafety);
                    }
                }
                for (Edge e : vertex.getIncoming()) {
                    if (!(e instanceof StreetEdge)) {
                        continue;
                    }
                    StreetEdge pse = (StreetEdge) e;

                    if (!seenEdges.contains(e)) {
                        seenEdges.add(e);
                        pse.setBicycleSafetyFactor(pse.getBicycleSafetyFactor() / bestBikeSafety);
                    }
                }
            }
        }
View Full Code Here

            if (permissions.allowsNothing()) {
                return new P2<StreetEdge>(null, null);
            }

            LineString backGeometry = (LineString) geometry.reverse();
            StreetEdge street = null, backStreet = null;
            double length = this.getGeometryLengthMeters(geometry);

            P2<StreetTraversalPermission> permissionPair = OSMFilter.getPermissions(permissions,
                    way);
            StreetTraversalPermission permissionsFront = permissionPair.first;
            StreetTraversalPermission permissionsBack = permissionPair.second;

            if (permissionsFront.allowsAnything()) {
                street = getEdgeForStreet(start, end, way, index, startNode, endNode, length,
                        permissionsFront, geometry, false);
            }
            if (permissionsBack.allowsAnything()) {
                backStreet = getEdgeForStreet(end, start, way, index, endNode, startNode, length,
                        permissionsBack, backGeometry, true);
            }
            if (street != null && backStreet != null) {
                backStreet.shareData(street);
            }

            /* mark edges that are on roundabouts */
            if (way.isRoundabout()) {
                if (street != null)
                    street.setRoundabout(true);
                if (backStreet != null)
                    backStreet.setRoundabout(true);
            }

            return new P2<StreetEdge>(street, backStreet);
View Full Code Here

                length *= 2;
            }

            float carSpeed = wayPropertySet.getCarSpeedForWay(way, back);

            StreetEdge street = edgeFactory.createEdge(start, end, geometry, name, length,
                    permissions, back);
            street.setCarSpeed(carSpeed);

            String highway = way.getTag("highway");
            int cls;
            if ("crossing".equals(highway) && !way.isTag("bicycle", "designated")) {
                cls = StreetEdge.CLASS_CROSSING;
            } else if ("footway".equals(highway) && way.isTag("footway", "crossing")
                    && !way.isTag("bicycle", "designated")) {
                cls = StreetEdge.CLASS_CROSSING;
            } else if ("residential".equals(highway) || "tertiary".equals(highway)
                    || "secondary".equals(highway) || "secondary_link".equals(highway)
                    || "primary".equals(highway) || "primary_link".equals(highway)
                    || "trunk".equals(highway) || "trunk_link".equals(highway)) {
                cls = StreetEdge.CLASS_STREET;
            } else {
                cls = StreetEdge.CLASS_OTHERPATH;
            }

            cls |= OSMFilter.getStreetClasses(way);
            street.setStreetClass(cls);

            if (!way.hasTag("name") && !way.hasTag("ref")) {
                street.setHasBogusName(true);
            }
            street.setStairs(steps);

            /* TODO: This should probably generalized somehow? */
            if (!ignoreWheelchairAccessibility
                    && (way.isTagFalse("wheelchair") || (steps && !way.isTagTrue("wheelchair")))) {
                street.setWheelchairAccessible(false);
            }

            street.setSlopeOverride(wayPropertySet.getSlopeOverride(way));

            // < 0.04: account for
            if (carSpeed < 0.04) {
                LOG.warn(graph.addBuilderAnnotation(new StreetCarSpeedZero(way.getId())));
            }
View Full Code Here

                            coordinates[i + 1], worldCRS);
                }
                P2<StreetTraversalPermission> permissions = permissionConverter.convert(feature);

                // TODO Set appropriate car speed from shapefile source.
                StreetEdge street = edgeFactory.createEdge(startIntersection, endIntersection,
                        geom, name, length, permissions.first, false);
                LineString reversed = (LineString) geom.reverse();
                StreetEdge backStreet = edgeFactory.createEdge(endIntersection, startIntersection,
                        reversed, name, length, permissions.second, true);
                backStreet.shareData(street);

                if (noteConverter != null) {
                  String note = noteConverter.convert(feature);
                  if (note != null && note.length() > 0) {
        Alert noteAlert = Alert.createSimpleAlerts(note);
        graph.streetNotesService.addStaticNote(street, noteAlert, StreetNotesService.ALWAYS_MATCHER);
        graph.streetNotesService.addStaticNote(backStreet, noteAlert, StreetNotesService.ALWAYS_MATCHER);
                  }
                }

                boolean slopeOverride = slopeOverrideCoverter.convert(feature);
                street.setSlopeOverride(slopeOverride);
                backStreet.setSlopeOverride(slopeOverride);

                if (safetyConverter != null) {
                    P2<Double> safetyFactors = safetyConverter.convert(feature);
                    if (safetyFactors != null) {
                        street.setBicycleSafetyFactor(safetyFactors.first.floatValue());
                        backStreet.setBicycleSafetyFactor(safetyFactors.second.floatValue());
                    }
                }
            }
        } catch (Exception ex) {
            throw new IllegalStateException("error loading shapefile street data", ex);
View Full Code Here

        Collection<Edge> edges = streetIndexService.getEdgesForEnvelope(env);

        int counter = 0;
        for (Edge edge : edges) {
            if (edge instanceof StreetEdge) {
                StreetEdge streetEdge = (StreetEdge) edge;
                double dis = DistanceOp.distance(streetEdge.getGeometry(),
                        geometryFactory.createPoint(ts.getCoordinate()));
                double disMeters = (dis * Math.PI / 180) * rInMeters;
                if (disMeters <= distance && streetEdge.getPermission().allows(allowedPermission)) {
                    counter++;
                }
            }
        }

View Full Code Here

    @Override
    public StreetEdge createEdge(IntersectionVertex startEndpoint, IntersectionVertex endEndpoint,
            LineString geometry, String name, double length, StreetTraversalPermission permissions,
            boolean back) {
        StreetEdge pse;
        if (useElevationData) {
            pse = new StreetWithElevationEdge(startEndpoint, endEndpoint, geometry, name, length,
                    permissions, back);
        } else {
            pse = new StreetEdge(startEndpoint, endEndpoint, geometry, name, length, permissions,
                    back);
        }
        return pse;
    }
View Full Code Here

            narrativeBean.setTo(getVertexAsBean(beansByVertex,
                narrative.getToVertex()));

            Map<String, Object> tags = new HashMap<String, Object>();
            if (edge instanceof StreetEdge) {
              StreetEdge streetEdge = (StreetEdge) edge;
              StreetTraversalPermission permission = streetEdge.getPermission();
              if (permission != null)
                tags.put("access", permission.toString().toLowerCase());
            }

            if (!tags.isEmpty())
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.edgetype.StreetEdge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.