Search in sources :

Example 6 with StopCluster

use of org.opentripplanner.profile.StopCluster in project OpenTripPlanner by opentripplanner.

the class GraphIndex method clusterByParentStation.

/**
 * Rather than using the names and geographic locations of stops to cluster them, group them by their declared
 * parent station in the GTFS data. This should be a much more reliable method where these fields have been
 * included in the GTFS data. However:
 *
 * FIXME OBA parentStation field is a string, not an AgencyAndId, so it has no agency/feed scope.
 * That means it would only work reliably if there is only one GTFS feed loaded.
 * The DC regional graph has no parent stations pre-defined, so we use the alternative proximity / name method.
 * Trimet stops have "landmark" or Transit Center parent stations, so we don't use the parent stop field.
 */
private void clusterByParentStation() {
    LOG.info("Clustering stops by parent station...");
    for (Stop stop : stopForId.values()) {
        String ps = stop.getParentStation();
        if (ps == null || ps.isEmpty()) {
            continue;
        }
        StopCluster cluster;
        if (stopClusterForId.containsKey(ps)) {
            cluster = stopClusterForId.get(ps);
        } else {
            cluster = new StopCluster(ps, stop.getName());
            Stop parent = graph.parentStopById.get(new AgencyAndId(stop.getId().getAgencyId(), ps));
            cluster.setCoordinates(parent.getLat(), parent.getLon());
            stopClusterForId.put(ps, cluster);
        }
        cluster.children.add(stop);
        stopClusterForStop.put(stop, cluster);
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) Stop(org.onebusaway.gtfs.model.Stop) StopCluster(org.opentripplanner.profile.StopCluster)

Example 7 with StopCluster

use of org.opentripplanner.profile.StopCluster in project OpenTripPlanner by opentripplanner.

the class GraphIndex method findNearbyStopClusters.

/**
 * Find transfer candidates for profile routing.
 * TODO replace with an on-street search using the existing profile router functions.
 */
public Map<StopCluster, Double> findNearbyStopClusters(StopCluster sc, double radius) {
    Map<StopCluster, Double> ret = Maps.newHashMap();
    Envelope env = new Envelope(new Coordinate(sc.lon, sc.lat));
    env.expandBy(SphericalDistanceLibrary.metersToLonDegrees(radius, sc.lat), SphericalDistanceLibrary.metersToDegrees(radius));
    for (StopCluster cluster : stopClusterSpatialIndex.query(env)) {
        // TODO this should account for area-like nature of clusters. Use size of bounding boxes.
        double distance = SphericalDistanceLibrary.distance(sc.lat, sc.lon, cluster.lat, cluster.lon);
        if (distance < radius)
            ret.put(cluster, distance);
    }
    return ret;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) StopCluster(org.opentripplanner.profile.StopCluster) Envelope(com.vividsolutions.jts.geom.Envelope)

Aggregations

StopCluster (org.opentripplanner.profile.StopCluster)7 Stop (org.onebusaway.gtfs.model.Stop)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 Envelope (com.vividsolutions.jts.geom.Envelope)3 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)3 File (java.io.File)1 IOException (java.io.IOException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 P2 (org.opentripplanner.common.model.P2)1 StopClusterDetail (org.opentripplanner.index.model.StopClusterDetail)1 ProfileTransfer (org.opentripplanner.profile.ProfileTransfer)1 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)1 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)1