Example #1
0
 private 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);
         }
       }
     }
   }
 }
Example #2
0
 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;
     }
   }
 }
Example #3
0
    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;
    }