Search in sources :

Example 11 with STRtree

use of com.vividsolutions.jts.index.strtree.STRtree 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)

Aggregations

Envelope (com.vividsolutions.jts.geom.Envelope)11 STRtree (com.vividsolutions.jts.index.strtree.STRtree)11 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)3 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 PostConstruct (javax.annotation.PostConstruct)2 Refreshable (org.onebusaway.container.refresh.Refreshable)2 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)2 Edge (org.opentripplanner.routing.graph.Edge)2 Vertex (org.opentripplanner.routing.graph.Vertex)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 SpatialIndex (com.vividsolutions.jts.index.SpatialIndex)1 File (java.io.File)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Random (java.util.Random)1