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);
}
}
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;
}
Aggregations