use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class StopsBeanServiceImpl method constructResult.
private StopsBean constructResult(List<StopBean> stopBeans, boolean limitExceeded) {
Collections.sort(stopBeans, new StopBeanIdComparator());
StopsBean result = new StopsBean();
result.setStops(stopBeans);
result.setLimitExceeded(limitExceeded);
return result;
}
use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getStopsForBounds.
private List<StopBean> getStopsForBounds(CoordinateBounds bounds) {
if (bounds != null) {
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(bounds);
queryBean.setMaxCount(Integer.MAX_VALUE);
StopsBean stops = _transitDataService.getStops(queryBean);
return stops.getStops();
}
return new ArrayList<StopBean>();
}
use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceTest method testStopPointsByBounds.
@Test
public void testStopPointsByBounds() throws Exception {
// MOCKS
// Coordinate Bounds
CoordinateBounds bounds = new CoordinateBounds(Double.parseDouble("47.612813"), Double.parseDouble("-122.339662"), Double.parseDouble("47.608813"), Double.parseDouble("-122.337662"));
// Stops For Bounds
StopsBean stopsBean = new StopsBean();
stopsBean.setStops(stops);
when(transitDataService.getRouteForId("1_100194")).thenReturn(routeBean);
when(transitDataService.getStops(any(SearchQueryBean.class))).thenReturn(stopsBean);
when(transitDataService.getStopsForRoute("1_100194")).thenReturn(stopsForRouteBean);
when(transitDataService.stopHasUpcomingScheduledService(anyString(), anyLong(), anyString(), anyString(), anyString())).thenReturn(true);
// EXPECTED
LineDirectionStructure lds = new LineDirectionStructure();
DirectionRefStructure drs = new DirectionRefStructure();
LineRefStructure lrs = new LineRefStructure();
lds.setDirectionRef(drs);
lds.setLineRef(lrs);
drs.setValue("0");
lrs.setValue("1_100194");
LocationStructure ls = new LocationStructure();
BigDecimal lat = new BigDecimal(47.610813);
BigDecimal lon = new BigDecimal(-122.338662);
ls.setLatitude(lat.setScale(6, BigDecimal.ROUND_HALF_DOWN));
ls.setLongitude(lon.setScale(6, BigDecimal.ROUND_HALF_DOWN));
NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure();
stopName.setValue("3rd Ave & Pine St");
List<NaturalLanguageStringStructure> stopNames = new ArrayList<NaturalLanguageStringStructure>();
stopNames.add(stopName);
StopPointRefStructure stopPointRef = new StopPointRefStructure();
stopPointRef.setValue("1_430");
Boolean monitored = true;
AnnotatedStopPointStructure mockStopPoint = new AnnotatedStopPointStructure();
mockStopPoint.setLines(new AnnotatedStopPointStructure.Lines());
mockStopPoint.getLines().getLineRefOrLineDirection().add(lds);
mockStopPoint.setLocation(ls);
mockStopPoint.getStopName().add(stopName);
mockStopPoint.setStopPointRef(stopPointRef);
mockStopPoint.setMonitored(monitored);
// REALTIME ARGUMENTS
// Agency Ids
List<String> agencyIds = new ArrayList<String>();
String agencyId = "1";
agencyIds.add(agencyId);
// Route Ids
List<AgencyAndId> routeIds = new ArrayList<AgencyAndId>();
AgencyAndId routeId = AgencyAndIdLibrary.convertFromString("1_100194");
routeIds.add(routeId);
// Detail Level
DetailLevel detailLevel = DetailLevel.NORMAL;
// Time
long time = System.currentTimeMillis();
// Filters
Map<Filters, String> filters = new HashMap<Filters, String>();
Map<Boolean, List<AnnotatedStopPointStructure>> actualResult = realtimeService.getAnnotatedStopPointStructures(bounds, agencyIds, routeIds, detailLevel, time, filters);
AnnotatedStopPointStructure actualStopPoint = actualResult.get(true).get(0);
assertTrue(isEqual(mockStopPoint, actualStopPoint));
}
use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class StopForCodeAction method execute.
public String execute() throws Exception {
_log.info("in stop for code");
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_stopCode == null || _stopCode.length() == 0)
return INPUT;
if (_stop != null) {
_stops = Arrays.asList(_stop);
} else {
_log.info("searching on stopCode=" + _stopCode);
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(bounds);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopCode);
StopsBean stopsBean = _transitDataService.getStops(searchQuery);
_stops = stopsBean.getStops();
}
logUserInteraction("query", _stopCode);
if (_stops.size() == 0) {
sessionMap.put("messageFromAction", getText(Messages.NO_STOPS_WERE_FOUND));
sessionMap.put("backAction", "stops-index");
return "noStopsFound";
} else if (_stops.size() == 1) {
StopBean stop = _stops.get(0);
_stopIds = Arrays.asList(stop.getId());
return SUCCESS;
} else {
sessionMap.put("stops", _stops);
return "multipleStopsFound";
}
}
use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class StopsWithinBoundsAction method execute.
@Override
public String execute() {
if (_bounds == null) {
return SUCCESS;
}
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(_bounds);
queryBean.setMaxCount(200);
StopsBean stops = null;
try {
stops = _transitDataService.getStops(queryBean);
} catch (OutOfServiceAreaServiceException e) {
_log.error(" invalid results: ", e);
return SUCCESS;
}
for (StopBean stop : stops.getStops()) {
String agencyId = AgencyAndIdLibrary.convertFromString(stop.getId()).getAgencyId();
if (_transitDataService.stopHasRevenueService(agencyId, stop.getId())) {
_stops.add(new StopOnRoute(stop));
}
}
return SUCCESS;
}
Aggregations