private RouteSegment loadRouteSegment( int x31, int y31, RoutingContext ctx, TLongObjectHashMap<RouteDataObject> excludeDuplications, RouteSegment original) { if (searchResult == null && routes == null) { return original; } access++; if (searchResult == null) { long l = (((long) x31) << 31) + (long) y31; RouteSegment segment = routes.get(l); 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); RouteSegment s = new RouteSegment(ro, segment.getSegmentStart()); s.next = original; original = s; } segment = segment.next; } return original; } // Native use case long nanoTime = System.nanoTime(); RouteDataObject[] res = ctx.nativeLib.getDataObjects(searchResult, x31, y31); ctx.timeToLoad += (System.nanoTime() - nanoTime); if (res != null) { for (RouteDataObject ro : res) { boolean accept = ro != null; if (ctx != null) { accept = ctx.getRouter().acceptLine(ro); } if (accept) { 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); segment.next = original; original = segment; excludeDuplications.put(calcRouteId(ro, i), ro); } } } } } } return original; }
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) { for (int i = 0; i < ro.pointsX.length; i++) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { excludeDuplications.put(calcRouteId(ro, i), ro); RouteSegment segment = new RouteSegment(ro, i); segment.next = original; original = segment; } } } } } List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId); if (subregions != null) { for (RoutingSubregionTile rs : subregions) { original = rs.loadRouteSegment(x31, y31, this, excludeDuplications, original); } } return original; }
public void add(RouteDataObject ro) { tileStatistics.addObject(ro); for (int i = 0; i < ro.pointsX.length; i++) { int x31 = ro.getPoint31XTile(i); int y31 = ro.getPoint31YTile(i); long l = (((long) x31) << 31) + (long) y31; RouteSegment segment = new RouteSegment(ro, i); if (!routes.containsKey(l)) { routes.put(l, segment); } else { RouteSegment orig = routes.get(l); while (orig.next != null) { orig = orig.next; } orig.next = segment; } } }