Search in sources :

Example 16 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class ShapeGeospatialIndexTask method run.

@Override
public void run() {
    try {
        Map<CoordinateBounds, List<AgencyAndId>> shapeIdsByGridCell = buildShapeSpatialIndex();
        File path = _bundle.getShapeGeospatialIndexDataPath();
        ObjectSerializationLibrary.writeObject(path, shapeIdsByGridCell);
        _refreshService.refresh(RefreshableResources.SHAPE_GEOSPATIAL_INDEX);
    } catch (Exception ex) {
        throw new IllegalStateException("error creating shape geospatial index data", ex);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds)

Example 17 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds 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";
    }
}
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 18 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class RoutesAction method execute.

@Override
@Actions({ @Action(value = "/where/iphone/routes") })
public String execute() throws ServiceException {
    if (_query == null || _query.length() == 0)
        return INPUT;
    CoordinateBounds bounds = getServiceArea();
    if (bounds == null) {
        pushNextAction("routes", "query", _query);
        return "query-default-search-location";
    }
    SearchQueryBean query = new SearchQueryBean();
    query.setBounds(bounds);
    query.setMaxCount(5);
    query.setQuery(_query);
    query.setType(EQueryType.BOUNDS_OR_CLOSEST);
    RoutesBean routesResult = _transitDataService.getRoutes(query);
    _routes = routesResult.getRoutes();
    if (_routes.size() == 0) {
        return "noRoutesFound";
    } else if (_routes.size() > 1) {
        return "multipleRoutesFound";
    } else {
        _route = _routes.get(0);
        return "singleRouteFound";
    }
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Actions(org.apache.struts2.convention.annotation.Actions)

Example 19 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class StopsAction method execute.

@Override
@Actions({ @Action(value = "/where/iphone/stops") })
public String execute() throws ServiceException {
    CoordinateBounds bounds = getServiceArea();
    if (bounds == null) {
        pushNextAction("stops", "code", _code);
        return "query-default-search-location";
    }
    SearchQueryBean searchQuery = new SearchQueryBean();
    searchQuery.setBounds(bounds);
    searchQuery.setMaxCount(5);
    searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
    searchQuery.setQuery(_code);
    StopsBean stopsResult = _transitDataService.getStops(searchQuery);
    _stops = stopsResult.getStops();
    if (_stops.size() == 0) {
        return "noStopsFound";
    } else if (_stops.size() > 1) {
        return "multipleStopsFound";
    } else {
        _stop = _stops.get(0);
        return "singleStopFound";
    }
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) StopsBean(org.onebusaway.transit_data.model.StopsBean) Actions(org.apache.struts2.convention.annotation.Actions)

Example 20 with CoordinateBounds

use of org.onebusaway.geospatial.model.CoordinateBounds in project onebusaway-application-modules by camsys.

the class FederatedByCoordinateBoundsMethodInvocationHandlerImpl method invoke.

public Object invoke(FederatedServiceCollection collection, Method method, Object[] args) throws ServiceAreaServiceException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Object value = args[_argumentIndex];
    if (_expression != null)
        value = _expression.invoke(value);
    CoordinateBounds bounds = (CoordinateBounds) value;
    FederatedService service = collection.getServiceForBounds(bounds);
    return method.invoke(service, args);
}
Also used : FederatedService(org.onebusaway.federations.FederatedService) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds)

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