public RouteSegment loadRouteSegment(int x31, int y31, int memoryLimit) { long tileId = getRoutingTile(x31, y31, memoryLimit, OPTION_SMART_LOAD); TLongObjectHashMap<RouteDataObject> excludeDuplications = new TLongObjectHashMap<RouteDataObject>(); RouteSegment original = null; if (tileRoutes.containsKey(tileId)) { List<RouteDataObject> routes = tileRoutes.get(tileId); if (routes != null) { for (RouteDataObject ro : routes) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { long id = calcRouteId(ro, i); if (excludeDuplications.contains(id)) { continue; excludeDuplications.put(id, ro); RouteSegment segment = new RouteSegment(ro, i); segment.next = original; List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId); if (subregions != null) { for (RoutingSubregionTile rs : subregions) {
public int NZN() { return vector.size(); }
private void removeObject(T object, long tile) { if(objects.containsKey(tile)){ objects.get(tile).remove(object); } }
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 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); } } }
TIntArrayList allPointsLoad = new TIntArrayList(); TLongObjectHashMap<TransportStop> loadedTransportStops = new TLongObjectHashMap<TransportStop>(); for(BinaryMapIndexReader r : routeMap.keySet()) { sr.clearSearchResults(); if(!loadedTransportStops.contains(s.getId())) { loadedTransportStops.put(s.getId(), s); allPoints.addAll(s.getReferencesToRoutes());
protected Collection<PermOverrideData> getOverrides() { //note: overridesAdd and overridesRem are mutually disjoint TLongObjectHashMap<PermOverrideData> data = new TLongObjectHashMap<>(this.overridesAdd); AbstractChannelImpl<?> impl = (AbstractChannelImpl<?>) getChannel(); impl.getOverrideMap().forEachEntry((id, override) -> { //removed by not adding them here, this data set overrides the existing one //we can use remove because it will be reset afterwards either way if (!overridesRem.remove(id) && !data.containsKey(id)) data.put(id, new PermOverrideData(override)); return true; }); return data.valueCollection(); }
SearchRequest<Amenity> request = new SearchRequest<Amenity>(); float coeff = (float) (radius / MapUtils.getTileDistanceWidth(SearchRequest.ZOOM_TO_SEARCH_POI)); TLongObjectHashMap<List<Location>> zooms = new TLongObjectHashMap<List<Location>>(); for (int i = 1; i < route.size(); i++) { Location cr = route.get(i); for (int y = (int) topLeftY; y <= bottomRightY; y++) { long hash = (((long) x) << SearchRequest.ZOOM_TO_SEARCH_POI) + y; if (!zooms.containsKey(hash)) { zooms.put(hash, new LinkedList<Location>()); List<Location> ll = zooms.get(hash); ll.add(pr); ll.add(cr); for (long vl : zooms.keys()) { long x = (vl >> SearchRequest.ZOOM_TO_SEARCH_POI) << (31 - SearchRequest.ZOOM_TO_SEARCH_POI); long y = (vl & ((1 << SearchRequest.ZOOM_TO_SEARCH_POI) - 1)) << (31 - SearchRequest.ZOOM_TO_SEARCH_POI);
public SparseMatrix(){ vector = new TLongObjectHashMap<T>(100,0.8f); }
TLongObjectHashMap<StopRec> toInsertBefore= new TLongObjectHashMap<>(); TLongObjectHashMap<StopRec> toInsertAfter= new TLongObjectHashMap<>(); toInsertAfter.put(pd.p.orderRowId, pd.d); }else{ toInsertAfter.put(pd.p.orderRowId, pd.d); }else{ toInsertBefore.put(pd.d.orderRowId, pd.p); if(toDelete.size()==0 && toInsertBefore.size()==0 && toInsertAfter.size()==0){ return; toDelete.remove(rowid); else if(toInsertBefore.contains(rowid)){ insert(toInsertBefore.remove(rowid), row); else if(toInsertAfter.contains(rowid)){ insert(toInsertAfter.remove(rowid), row+1);
private static TLongObjectHashMap<CfHolder> multiplySparseUnivariate(IntegersZp64 ring, TLongObjectHashMap<CfHolder> a, TLongObjectHashMap<CfHolder> b) { TLongObjectHashMap<CfHolder> result = new TLongObjectHashMap<>(a.size() + b.size()); TLongObjectIterator<CfHolder> ait = a.iterator(); while (ait.hasNext()) { ait.advance(); TLongObjectIterator<CfHolder> bit = b.iterator(); while (bit.hasNext()) { bit.advance(); long deg = ait.key() + bit.key(); long val = ring.multiply(ait.value().coefficient, bit.value().coefficient); CfHolder r = result.putIfAbsent(deg, new CfHolder(val)); if (r != null) r.coefficient = ring.add(r.coefficient, val); } } return result; }
List<TransportRouteSegment> endStops = ctx.getTransportStops(end); TLongObjectHashMap<TransportRouteSegment> endSegments = new TLongObjectHashMap<TransportRouteSegment>(); for(TransportRouteSegment s : endStops) { endSegments.put(s.getId(), s); TransportRouteSegment ex = ctx.visitedSegments.get(segment.getId()); if(ex != null) { if(ex.distFromStart > segment.distFromStart) { ctx.visitedSegments.put(segment.getId(), segment); if (segment.getDepth() > ctx.cfg.maxNumberOfChanges) { continue; ctx.visitedSegments.put(segmentId, segment); TransportStop stop = segment.getStop(ind); TransportRouteSegment f = endSegments.get(segmentId); double distToEnd = MapUtils.getDistance(stop.getLocation(), end); if (f != null && distToEnd < ctx.cfg.walkRadius) {
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( ! ( other instanceof TLongObjectMap ) ) { return false; } TLongObjectMap that = ( TLongObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TLongObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); long key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
routeTree.dataObjects = new ArrayList<RouteDataObject>(); idTables.clear(); restrictions.clear(); List<String> stringTable = null; while(true){ switch (tag) { case 0: TLongObjectIterator<RestrictionInfo> it = restrictions.iterator(); while (it.hasNext()) { it.advance(); RestrictionInfo prev = restrictions.get(from); if(prev != null) { prev.next = ri; } else { restrictions.put(from, ri);
public boolean execute( long key, V value) { put( key, value ); return true; } };
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; }
public void loadAllObjects(final List<RouteDataObject> toFillIn, RoutingContext ctx, TLongObjectHashMap<RouteDataObject> excludeDuplications) { if(routes != null) { Iterator<RouteSegment> it = routes.valueCollection().iterator(); while(it.hasNext()){ RouteSegment rs = it.next(); while(rs != null){ RouteDataObject ro = rs.road; if (!excludeDuplications.contains(ro.id)) { excludeDuplications.put(ro.id, ro); toFillIn.add(ro); } rs = rs.next; } } } else if(searchResult != null) { RouteDataObject[] objects = searchResult.objects; if(objects != null) { for(RouteDataObject ro : objects) { if (ro != null && !excludeDuplications.contains(ro.id)) { excludeDuplications.put(ro.id, ro); toFillIn.add(ro); } } } } }
TLongObjectHashMap<RouteSegment> visitedDirectSegments = new TLongObjectHashMap<RouteSegment>(); TLongObjectHashMap<RouteSegment> visitedOppositeSegments = new TLongObjectHashMap<RouteSegment>(); RouteSegment segment = graphSegments.poll(); ctx.memoryOverhead = (visitedDirectSegments.size() + visitedOppositeSegments.size()) * STANDARD_ROAD_VISITED_OVERHEAD + (graphDirectSegments.size() + graphReverseSegments.size()) * STANDARD_ROAD_IN_QUEUE_OVERHEAD;
@SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_KEY no_entry_key = in.readLong(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { long key = in.readLong(); V val = (V) in.readObject(); put(key, val); } }