use of gnu.trove.procedure.TLongProcedure in project OpenTripPlanner by opentripplanner.
the class HashGridSpatialIndex method insert.
public final void insert(LineString geom, final Object item) {
Coordinate[] coord = geom.getCoordinates();
final TLongSet keys = new TLongHashSet(coord.length * 8);
for (int i = 0; i < coord.length - 1; i++) {
// TODO Cut the segment if longer than bin size
// to reduce the number of wrong bins
Envelope env = new Envelope(coord[i], coord[i + 1]);
visit(env, true, new BinVisitor<T>() {
@Override
public boolean visit(List<T> bin, long mapKey) {
keys.add(mapKey);
return false;
}
});
}
keys.forEach(new TLongProcedure() {
@SuppressWarnings("unchecked")
@Override
public boolean execute(long key) {
// Note: bins have been initialized in the previous visit
bins.get(key).add((T) item);
nEntries++;
return true;
}
});
nObjects++;
}
Aggregations