示例#1
0
文件: Paths.java 项目: jpollo/rcrss
 private void setPathIDForRoads(List<Path> paths) {
   for (Path path : paths) {
     for (Road road : path) {
       roadHelper.setPathId(road.getID(), path.getId());
     }
   }
 }
示例#2
0
文件: Paths.java 项目: jpollo/rcrss
  private Path getNearestPath(Road road, List<Path> paths) {
    int range = 10000;
    int minDistance = Integer.MAX_VALUE;
    EntityID nearestPath = null;

    while (nearestPath == null) {
      Collection<StandardEntity> entities = world.getObjectsInRange(road, range);

      for (StandardEntity entity : entities) {
        if (entity instanceof Road) {
          EntityID pathId = roadHelper.getPathId(entity.getID());

          if (pathId != null) {
            int distance = Util.distance((Area) entity, road);
            if (distance < minDistance) {
              nearestPath = pathId;
              minDistance = distance;
            }
          }
        }
      }
      range += 10000;
    }

    for (Path path : paths) {
      if (path.getId().equals(nearestPath)) {
        return path;
      }
    }
    return null;
  }
示例#3
0
文件: Paths.java 项目: jpollo/rcrss
 private void addToPath(Road road, EntityID pathId, List<Path> paths) {
   for (Path path : paths) {
     if (path.getId().equals(pathId)) {
       adding(road, path);
       break;
     }
   }
 }
示例#4
0
文件: Paths.java 项目: jpollo/rcrss
 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));
     }
   }
 }
示例#5
0
文件: Paths.java 项目: jpollo/rcrss
 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);
       }
     }
   }
 }