public T elementAt(long index) { return vector.get(index); }
public T elementAt(long index) { return vector.get(index); }
@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; } });
private void removeObject(T object, long tile) { if(objects.containsKey(tile)){ objects.get(tile).remove(object); } }
public T get(int[] indices) { long idx = getIdx(indices[0],indices[1]); return vector.get(idx); }
public T get(int id1, int id2) { long idx = getIdx(id1,id2); return vector.get(idx); }
public T elementAt(int[] indices) { long idx = getIdx(indices); return vector.get(idx); }
private long addObject(T object, long tile) { if(!objects.containsKey(tile)){ objects.put(tile, new ArrayList<T>()); } objects.get(tile).add(object); return tile; }
private void putObjects(int tx, int ty, List<T> r){ if(objects.containsKey(evTile(tx, ty))){ r.addAll(objects.get(evTile(tx, ty))); } }
private void getAllObjects(long tileId, final List<RouteDataObject> toFillIn, TLongObjectHashMap<RouteDataObject> excludeDuplications) { if (tileRoutes.containsKey(tileId)) { List<RouteDataObject> routes = tileRoutes.get(tileId); if (routes != null) { for (RouteDataObject ro : routes) { if (!excludeDuplications.contains(ro.id)) { excludeDuplications.put(ro.id, ro); toFillIn.add(ro); } } } } List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId); if (subregions != null) { for (RoutingSubregionTile rs : subregions) { rs.loadAllObjects(toFillIn, this, excludeDuplications); } } }
private List<TransportRouteSegment> loadNativeTransportStops(int sx, int sy, boolean change, List<TransportRouteSegment> res) throws IOException { long nanoTime = System.nanoTime(); int d = change ? walkChangeRadiusIn31 : walkRadiusIn31; int lx = (sx - d ) >> (31 - cfg.ZOOM_TO_LOAD_TILES); int rx = (sx + d ) >> (31 - cfg.ZOOM_TO_LOAD_TILES); int ty = (sy - d ) >> (31 - cfg.ZOOM_TO_LOAD_TILES); int by = (sy + d ) >> (31 - cfg.ZOOM_TO_LOAD_TILES); for(int x = lx; x <= rx; x++) { for(int y = ty; y <= by; y++) { int tileId = x << (cfg.ZOOM_TO_LOAD_TILES + 1) + y; List<TransportRouteSegment> list = quadTree.get(tileId); if(list == null) { list = loadTile(x, y); quadTree.put(tileId, list); } for(TransportRouteSegment r : list) { TransportStop st = r.getStop(r.segStart); if (Math.abs(st.x31 - sx) > walkRadiusIn31 || Math.abs(st.y31 - sy) > walkRadiusIn31) { wrongLoadedWays++; } else { loadedWays++; res.add(r); } } } } loadTime += System.nanoTime() - nanoTime; return res; }
List<T> bin = bins.get(mapKey); if (createIfEmpty && bin == null) { bin = new ArrayList<>();
zooms.put(hash, new LinkedList<Location>()); List<Location> ll = zooms.get(hash); ll.add(pr); ll.add(cr);
indexedSubregions.put(tileId, collection); List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId); if (subregions != null) { boolean load = false;
RestrictionInfo prev = restrictions.get(from); if(prev != null) { prev.next = ri;
RouteSegment original = null; if (tileRoutes.containsKey(tileId)) { List<RouteDataObject> routes = tileRoutes.get(tileId); if (routes != null) { for (RouteDataObject ro : routes) { List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId); if (subregions != null) { for (RoutingSubregionTile rs : subregions) {
private boolean checkIfInitialMovementAllowedOnSegment(final RoutingContext ctx, boolean reverseWaySearch, TLongObjectHashMap<RouteSegment> visitedSegments, RouteSegment segment, final RouteDataObject road) { boolean directionAllowed; int oneway = ctx.getRouter().isOneWay(road); // use positive direction as agreed if (!reverseWaySearch) { if (segment.isPositive()) { directionAllowed = oneway >= 0; } else { directionAllowed = oneway <= 0; } } else { if (segment.isPositive()) { directionAllowed = oneway <= 0; } else { directionAllowed = oneway >= 0; } } RouteSegment visitedSegment = visitedSegments.get(calculateRoutePointId(segment, segment.isPositive())); if (directionAllowed && visitedSegment != null) { if (visitedSegment.distanceFromStart <= segment.distanceFromStart) { directionAllowed = false; } } return directionAllowed; }
while (segment != null) { RouteDataObject ro = segment.road; RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, segment.getSegmentStart())); if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) { excludeDuplications.put(calcRouteId(ro, segment.getSegmentStart()), ro); for (int i = 0; i < ro.pointsX.length; i++) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, i)); if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) { RouteSegment segment = new RouteSegment(ro, i);
if (req.radius > 0) { LatLon loc = am.getLocation(); List<Location> locs = req.tiles.get(req.getTileHashOnPath(loc.getLatitude(), loc.getLongitude())); if (locs == null) { return null;
private boolean checkIfOppositeSegmentWasVisited(final RoutingContext ctx, boolean reverseWaySearch, PriorityQueue<RouteSegment> graphSegments, RouteSegment segment, TLongObjectHashMap<RouteSegment> oppositeSegments, int segmentPoint, float segmentDist, float obstaclesTime) { RouteDataObject road = segment.getRoad(); long opp = calculateRoutePointId(road, segment.isPositive() ? segmentPoint - 1 : segmentPoint, !segment.isPositive()); if (oppositeSegments.containsKey(opp)) { RouteSegment opposite = oppositeSegments.get(opp); RouteSegment to = reverseWaySearch ? getParentDiffId(segment) : getParentDiffId(opposite); RouteSegment from = !reverseWaySearch ? getParentDiffId(segment) : getParentDiffId(opposite); if (checkViaRestrictions(from, to)) { FinalRouteSegment frs = new FinalRouteSegment(road, segmentPoint); float distStartObstacles = segment.distanceFromStart + calculateTimeWithObstacles(ctx, road, segmentDist, obstaclesTime); frs.setParentRoute(segment); frs.setParentSegmentEnd(segmentPoint); frs.reverseWaySearch = reverseWaySearch; frs.distanceFromStart = opposite.distanceFromStart + distStartObstacles; frs.distanceToEnd = 0; frs.opposite = opposite; graphSegments.add(frs); if (TRACE_ROUTING) { printRoad(" >> Final segment : ", frs, reverseWaySearch); } return true; } } return false; }