Search in sources :

Example 51 with CoordinateBounds

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";
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) StopBean(org.onebusaway.transit_data.model.StopBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) StopsBean(org.onebusaway.transit_data.model.StopsBean)

Example 52 with CoordinateBounds

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);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 53 with CoordinateBounds

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)));
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 54 with CoordinateBounds

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);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Example 55 with CoordinateBounds

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);
}
Also used : CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Aggregations

CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)70 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)15 List (java.util.List)14 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)12 Map (java.util.Map)9 StopBean (org.onebusaway.transit_data.model.StopBean)9 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 RouteBean (org.onebusaway.transit_data.model.RouteBean)7 StopsBean (org.onebusaway.transit_data.model.StopsBean)7 Envelope (com.vividsolutions.jts.geom.Envelope)5 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)5 STRtree (com.vividsolutions.jts.index.strtree.STRtree)4 File (java.io.File)4 IOException (java.io.IOException)4 Filters (org.onebusaway.api.actions.siri.impl.SiriSupportV2.Filters)4 DetailLevel (org.onebusaway.api.actions.siri.model.DetailLevel)4 RoutesBean (org.onebusaway.transit_data.model.RoutesBean)4