use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class BlockSequenceIndex method toString.
@Override
public String toString() {
BlockSequence first = _sequences.get(0);
BlockConfigurationEntry blockConfig = first.getBlockConfig();
BlockEntry block = blockConfig.getBlock();
List<BlockStopTimeEntry> bsts = first.getStopTimes();
BlockStopTimeEntry firstBst = bsts.get(0);
BlockStopTimeEntry lastBst = bsts.get(bsts.size() - 1);
StopEntry fromStop = firstBst.getStopTime().getStop();
StopEntry toStop = lastBst.getStopTime().getStop();
return "BlockSequenceIndex [ex: block=" + block.getId() + " fromStop=" + fromStop.getId() + " toStop=" + toStop.getId() + " serviceIds=" + getServiceIds() + "]";
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class GtfsRealtimeEntitySource method getStopId.
public AgencyAndId getStopId(String stopId) {
for (String agencyId : _agencyIds) {
AgencyAndId id = new AgencyAndId(agencyId, stopId);
StopEntry stop = _transitGraphDao.getStopEntryForId(id);
if (stop != null)
return id;
}
try {
AgencyAndId id = AgencyAndId.convertFromString(stopId);
StopEntry stop = _transitGraphDao.getStopEntryForId(id);
if (stop != null)
return id;
} catch (IllegalArgumentException ex) {
}
_log.debug("stop not found with id \"{}\"", stopId);
// If not found, just return null.
return null;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class StopIdsController method index.
@RequestMapping()
public ModelAndView index() {
List<String> ids = new ArrayList<String>();
for (StopEntry stop : _graphDao.getAllStops()) {
String id = AgencyAndIdLibrary.convertToString(stop.getId());
ids.add(id);
}
return new ModelAndView("stop-ids.jspx", "ids", ids);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class AgencyServiceImpl method getAgencyIdsAndCoverageAreas.
@Cacheable
public Map<String, CoordinateBounds> getAgencyIdsAndCoverageAreas() {
Map<String, CoordinateBounds> boundsByAgencyId = new HashMap<String, CoordinateBounds>();
for (AgencyEntry agency : _graph.getAllAgencies()) {
CoordinateBounds bounds = new CoordinateBounds();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
for (RouteEntry route : routeCollection.getChildren()) {
for (TripEntry trip : route.getTrips()) {
for (StopTimeEntry stopTime : trip.getStopTimes()) {
StopEntry stop = stopTime.getStop();
bounds.addPoint(stop.getStopLat(), stop.getStopLon());
}
}
}
}
boundsByAgencyId.put(agency.getId(), bounds);
}
return boundsByAgencyId;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class ArrivalAndDepartureServiceImpl method getArrivalAndDepartureForStop.
@Override
public ArrivalAndDepartureInstance getArrivalAndDepartureForStop(ArrivalAndDepartureQuery query) {
StopEntry stop = query.getStop();
int stopSequence = query.getStopSequence();
TripEntry trip = query.getTrip();
long serviceDate = query.getServiceDate();
AgencyAndId vehicleId = query.getVehicleId();
long time = query.getTime();
Map<BlockInstance, List<BlockLocation>> locationsByInstance = _blockStatusService.getBlocks(trip.getBlock().getId(), serviceDate, vehicleId, time);
if (locationsByInstance.isEmpty())
return null;
Map.Entry<BlockInstance, List<BlockLocation>> entry = locationsByInstance.entrySet().iterator().next();
BlockInstance blockInstance = entry.getKey();
List<BlockLocation> locations = entry.getValue();
int timeOfServiceDate = (int) ((time - serviceDate) / 1000);
ArrivalAndDepartureInstance instance = createArrivalAndDeparture(blockInstance, trip.getId(), stop.getId(), stopSequence, serviceDate, timeOfServiceDate, time);
if (!locations.isEmpty()) {
/**
* What if there are multiple locations? Pick the first?
*/
BlockLocation location = locations.get(0);
applyBlockLocationToInstance(instance, location, time);
}
return instance;
}
Aggregations