use of com.vividsolutions.jts.index.strtree.STRtree in project OpenTripPlanner by opentripplanner.
the class StreetMatcher method createIndex.
STRtree createIndex() {
STRtree edgeIndex = new STRtree();
for (Vertex v : graph.getVertices()) {
for (Edge e : v.getOutgoing()) {
if (e instanceof StreetEdge) {
Envelope envelope;
Geometry geometry = e.getGeometry();
envelope = geometry.getEnvelopeInternal();
edgeIndex.insert(envelope, e);
}
}
}
log.debug("Created index");
return edgeIndex;
}
use of com.vividsolutions.jts.index.strtree.STRtree in project onebusaway-application-modules by camsys.
the class TransitGraphImpl method initialize.
public void initialize() {
if (_stopLocationTree == null) {
System.out.println("initializing transit graph...");
if (_stops.size() == 0) {
_log.warn("no stops found for graph");
} else {
_stopLocationTree = new STRtree(_stops.size());
for (int i = 0; i < _stops.size(); i++) {
StopEntry stop = _stops.get(i);
double x = stop.getStopLon();
double y = stop.getStopLat();
Envelope r = new Envelope(x, x, y, y);
_stopLocationTree.insert(r, stop);
}
_stopLocationTree.build();
}
System.out.println(" stops=" + _stops.size());
System.out.println(" trips= " + _trips.size());
}
if (_agencyEntriesById == null || _agencyEntriesById.size() < _agencies.size()) {
refreshAgencyMapping();
}
if (_tripEntriesById == null || _tripEntriesById.size() < _trips.size()) {
refreshTripMapping();
}
if (_blockEntriesById == null || _blockEntriesById.size() < _blocks.size()) {
refreshBlockMapping();
}
if (_stopEntriesById == null || _stopEntriesById.size() < _stops.size())
refreshStopMapping();
if (_routeCollectionEntriesById == null || _routeCollectionEntriesById.size() < _routeCollections.size())
refreshRouteCollectionMapping();
if (_routeEntriesById == null || _routeEntriesById.size() < _routes.size())
refreshRouteMapping();
int i = 0;
for (StopEntryImpl stop : _stops) stop.setIndex(i++);
}
use of com.vividsolutions.jts.index.strtree.STRtree in project onebusaway-application-modules by camsys.
the class HierarchicalSTRtree method query.
@SuppressWarnings("unchecked")
public List<T> query(CoordinateBounds b) {
List<T> results = new ArrayList<T>();
Envelope env = new Envelope(b.getMinLon(), b.getMaxLon(), b.getMinLat(), b.getMaxLat());
List<STRtree> subTrees = _parentTree.query(env);
for (STRtree subTree : subTrees) {
List<T> result = subTree.query(env);
results.addAll(result);
}
return results;
}
use of com.vividsolutions.jts.index.strtree.STRtree in project onebusaway-application-modules by camsys.
the class HierarchicalSTRtreeFactory method create.
public HierarchicalSTRtree<T> create() {
STRtree parentTree = new STRtree();
for (Map.Entry<CoordinateBounds, STRtree> entry : _treesByBounds.entrySet()) {
CoordinateBounds b = entry.getKey();
Envelope env = new Envelope(b.getMinLon(), b.getMaxLon(), b.getMinLat(), b.getMaxLat());
STRtree tree = entry.getValue();
tree.build();
parentTree.insert(env, tree);
}
parentTree.build();
return new HierarchicalSTRtree<T>(parentTree);
}
use of com.vividsolutions.jts.index.strtree.STRtree 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();
}
Aggregations