use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.
the class StopByNumberAction method execute.
@Override
public String execute() throws ServiceException {
if (_text != null)
_text.trim();
if (_text == null || _text.length() == 0)
return INPUT;
String[] tokens = _text.trim().split("\\s+");
if (tokens.length == 0)
return INPUT;
CoordinateBounds serviceArea = _serviceAreaService.getServiceArea();
if (serviceArea == null) {
pushNextAction("stop-by-number", "text", _text);
return "query-default-search-location";
}
_stopQuery = tokens[0];
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(serviceArea);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopQuery);
StopsBean results = _transitDataService.getStops(searchQuery);
_stops = results.getStops();
int stopIndex = 0;
if (_stops.isEmpty()) {
return "noStopsFound";
} else if (_stops.size() > 1) {
if (0 <= _selectedIndex && _selectedIndex < _stops.size()) {
stopIndex = _selectedIndex;
} else {
pushNextAction("stop-by-number", "text", _text);
pushNextAction("handle-multi-selection");
return "multipleStopsFound";
}
}
StopBean stop = _stops.get(stopIndex);
_stopId = stop.getId();
_args = new String[tokens.length - 1];
System.arraycopy(tokens, 1, _args, 0, _args.length);
return "arrivals-and-departures";
}
use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.
the class CoordinateBoundsTest method testCoordinateBoundsDoubleDouble.
@Test
public void testCoordinateBoundsDoubleDouble() {
CoordinateBounds bounds = new CoordinateBounds(1, 2);
assertFalse(bounds.isEmpty());
assertEquals(1, bounds.getMinLat(), 0);
assertEquals(2, bounds.getMinLon(), 0);
assertEquals(1, bounds.getMaxLat(), 0);
assertEquals(2, bounds.getMaxLon(), 0);
}
use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.
the class CoordinateBoundsTest method testIntersects.
@Test
public void testIntersects() {
CoordinateBounds bounds = new CoordinateBounds(1, 2, 3, 4);
assertTrue(bounds.intersects(new CoordinateBounds(1, 2, 3, 4)));
assertTrue(bounds.intersects(new CoordinateBounds(0, 0, 2, 3)));
assertTrue(bounds.intersects(new CoordinateBounds(0, 0, 1, 2)));
assertFalse(bounds.intersects(new CoordinateBounds(0, 0, 1, 1)));
}
use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.
the class CoordinateBoundsTest method testCoordinateBoundsDoubleDoubleDoubleDouble.
@Test
public void testCoordinateBoundsDoubleDoubleDoubleDouble() {
CoordinateBounds bounds = new CoordinateBounds(1, 2, 0, 5);
assertFalse(bounds.isEmpty());
assertEquals(0, bounds.getMinLat(), 0);
assertEquals(2, bounds.getMinLon(), 0);
assertEquals(1, bounds.getMaxLat(), 0);
assertEquals(5, bounds.getMaxLon(), 0);
}
use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.
the class CoordinateBoundsTest method testGetSet.
@Test
public void testGetSet() {
CoordinateBounds bounds = new CoordinateBounds(1, 2);
bounds.setMinLat(3);
bounds.setMinLon(4);
bounds.setMaxLat(5);
bounds.setMaxLon(6);
assertEquals(3, bounds.getMinLat(), 0);
assertEquals(4, bounds.getMinLon(), 0);
assertEquals(5, bounds.getMaxLat(), 0);
assertEquals(6, bounds.getMaxLon(), 0);
}
Aggregations