Beispiel #1
0
 private void adding(Road road, Path path) {
   roadHelper.setPathId(road.getID(), path.getId());
   if (!path.contains(road)) {
     path.add(road);
     if (entrances.contains(road)) {
       path.addEntrance(getEntrance(road));
     }
   }
 }
Beispiel #2
0
  private void createAPath(Road neighbourRoad, Path path) {
    if (!path.contains(neighbourRoad)) {
      path.add(neighbourRoad);
      added.add(neighbourRoad);
    }

    addEntrances(path, neighbourRoad);

    for (Road road : roadHelper.getConnectedRoads(neighbourRoad.getID())) {
      if (entrances.contains(road) || added.contains(road)) {
        continue;
      }
      if (end || roadHelper.getConnectedRoads(neighbourRoad.getID()).size() == 1) {
        return;
      }
      if (headRoads.contains(road)) {
        if (!end) {
          end = true;
          if (!path.contains(road)) {
            path.add(road);
          }
          path.setEndOfPath(road);
        }
      } else if (!end) {
        createAPath(road, path);
      }
    }
    if (!end) {
      for (Road neighbourR : roadHelper.getConnectedRoads(neighbourRoad.getID())) {
        if (headRoads.contains(neighbourR)) {
          if (!path.contains(neighbourR)) {
            path.add(neighbourR);
          }
          path.setEndOfPath(neighbourR);
          end = true;
        }
      }
    }
  }
Beispiel #3
0
 private void addEntrances(Path path, Road road) {
   Entrance entrance;
   for (Road n : roadHelper.getConnectedRoads(road.getID())) {
     if (entrances.contains(n)) {
       roadHelper.setPathId(n.getID(), path.getId());
       if (!path.contains(n) && !added.contains(n)) {
         path.add(n);
         added.add(n);
       }
       entrance = getEntrance(n);
       if (!path.getEntrances().contains(entrance)) {
         path.addEntrance(entrance);
       }
     }
   }
 }
Beispiel #4
0
 private void createPathsNeighbours() {
   Set<Path> neighbours;
   for (Path path : this) {
     neighbours = new FastSet<Path>();
     for (Road road : path) {
       for (EntityID entityID : road.getNeighbours()) {
         if (world.getEntity(entityID) instanceof Road) {
           for (Path p : this) {
             if (!path.equals(p) && p.contains((Road) world.getEntity(entityID))) {
               if (!neighbours.contains(p)) {
                 neighbours.add(p);
               }
             }
           }
         }
       }
     }
     path.setNeighbours(neighbours);
   }
 }