Search in sources :

Example 6 with Refreshable

use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.

the class StopSearchServiceImpl method initialize.

@PostConstruct
@Refreshable(dependsOn = RefreshableResources.STOP_SEARCH_DATA)
public void initialize() throws IOException {
    File path = _bundle.getStopSearchIndexPath();
    if (path.exists()) {
        IndexReader reader = IndexReader.open(path);
        _searcher = new IndexSearcher(reader);
    } else {
        _searcher = null;
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) IndexReader(org.apache.lucene.index.IndexReader) File(java.io.File) Refreshable(org.onebusaway.container.refresh.Refreshable) PostConstruct(javax.annotation.PostConstruct)

Example 7 with Refreshable

use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.

the class WhereGeospatialServiceImpl method initialize.

@PostConstruct
@Refreshable(dependsOn = RefreshableResources.STOP_GEOSPATIAL_INDEX)
public void initialize() {
    List<StopEntry> stops = _transitGraphDao.getAllStops();
    if (stops.size() == 0) {
        _tree = null;
        return;
    }
    _tree = new STRtree(stops.size());
    for (StopEntry stop : stops) {
        float x = (float) stop.getStopLon();
        float y = (float) stop.getStopLat();
        Envelope env = new Envelope(x, x, y, y);
        _tree.insert(env, stop.getId());
    }
    _tree.build();
}
Also used : STRtree(com.vividsolutions.jts.index.strtree.STRtree) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) Envelope(com.vividsolutions.jts.geom.Envelope) Refreshable(org.onebusaway.container.refresh.Refreshable) PostConstruct(javax.annotation.PostConstruct)

Example 8 with Refreshable

use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.

the class RoutesBeanServiceImpl method setup.

@Refreshable(dependsOn = { RefreshableResources.NARRATIVE_DATA })
@PostConstruct
public void setup() {
    _stopTreesByRouteId.clear();
    for (StopEntry stop : _graphDao.getAllStops()) {
        Set<AgencyAndId> routeIds = _routeService.getRouteCollectionIdsForStop(stop.getId());
        for (AgencyAndId routeId : routeIds) {
            STRtree tree = _stopTreesByRouteId.get(routeId);
            if (tree == null) {
                tree = new STRtree();
                _stopTreesByRouteId.put(routeId, tree);
            }
            double x = stop.getStopLon();
            double y = stop.getStopLat();
            Envelope env = new Envelope(x, x, y, y);
            tree.insert(env, routeId);
        }
    }
    for (STRtree tree : _stopTreesByRouteId.values()) tree.build();
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) STRtree(com.vividsolutions.jts.index.strtree.STRtree) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) Envelope(com.vividsolutions.jts.geom.Envelope) Refreshable(org.onebusaway.container.refresh.Refreshable) PostConstruct(javax.annotation.PostConstruct)

Example 9 with Refreshable

use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.

the class BlockRunServiceImpl method setup.

@PostConstruct
@Refreshable(dependsOn = RefreshableResources.TRANSIT_GRAPH)
public void setup() throws IOException, ClassNotFoundException {
    _log.info("bundle path=" + _bundle.getPath());
    File path = _bundle.getBlockRunDataPath();
    if (path.exists()) {
        _log.info("loading BlockRunIndex...");
        _map = ObjectSerializationLibrary.readObject(path);
        _log.info("loading BlockRunIndex...done");
    } else {
        // this index is optional, do not fail if not found
        _log.info("failed BlockRunIndex load, path not found of " + path);
        _map = new HashMap<String, List<BlockRunIndex>>();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Refreshable(org.onebusaway.container.refresh.Refreshable) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)9 Refreshable (org.onebusaway.container.refresh.Refreshable)9 File (java.io.File)6 Envelope (com.vividsolutions.jts.geom.Envelope)2 STRtree (com.vividsolutions.jts.index.strtree.STRtree)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IndexReader (org.apache.lucene.index.IndexReader)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)2 IOException (java.io.IOException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)1 RouteBean (org.onebusaway.transit_data.model.RouteBean)1 BundleMetadata (org.onebusaway.transit_data.model.config.BundleMetadata)1