示例#1
0
 // Morteza2012*****************************************************************
 public ArrayList<Road> checkNeighborRoads() {
   ArrayList<Road> rs = new ArrayList<Road>();
   for (Area a : position.getNeighbours()) {
     if (a instanceof Road) {
       Road r = ((Road) a);
       if (Utility.hasIntersect(expandedBlock, r.getExpandedArea())) {
         if (!r.getNeighborBlockades().contains(this)) {
           rs.add(r);
           r.getNeighborBlockades().remove(this);
           r.getNeighborBlockades().add(this);
         }
       } else if (r.getNeighborBlockades().contains(this)) {
         r.getNeighborBlockades().remove(this);
         rs.add(r);
       }
     }
   }
   rs.add(position);
   return rs;
 }
示例#2
0
  // Morteza2011*****************************************************************
  public static ArrayList<SOSArea> mergeBlockades(Road road, ArrayList<SOSArea> blockades) {
    // log(road).logln("RoadID:" + road.getID());
    //		for (SOSArea b : blockades) {
    // log(road).logln(b.getReachablityBlockades());
    //		}
    for (short i = 0; i < blockades.size(); i++) {
      for (short j = (short) (i + 1); j < blockades.size(); j++) {
        if (Utility.hasIntersect(blockades.get(i), blockades.get(j))) {
          SOSArea a1 = blockades.get(i);
          SOSArea a2 = blockades.get(j);
          SOSArea a3;
          try {
            a3 = merge(road, a1, a2, (short) (0));
          } catch (Exception e) {
            a3 = reMerge(a1, a2);
            e.printStackTrace();
          }

          blockades.remove(j--);
          if (!a3.getEdges().isEmpty()) {
            blockades.set(i, a3);
          }
          i--;
          break;
        } else {
          try {
            if (blockades
                .get(i)
                .getShape()
                .contains(
                    blockades.get(j).getEdges().get(0).getStart().getX(),
                    blockades.get(j).getEdges().get(0).getStart().getY())) {
              // log(road).logln(blockades.get(j)+" has included in "+blockades.get(i));
              blockades.get(i).addReachablityBlockades(blockades.get(j).getReachablityBlockades());
              blockades.remove(j--);
            } else {
              if (blockades
                  .get(j)
                  .getShape()
                  .contains(
                      blockades.get(i).getEdges().get(0).getStart().getX(),
                      blockades.get(i).getEdges().get(0).getStart().getY())) {
                // log(road).logln(blockades.get(i)+" has included in "+blockades.get(j));
                blockades
                    .get(j)
                    .addReachablityBlockades(blockades.get(i).getReachablityBlockades());
                blockades.remove(i--);
                break;
              }
              // else
              // log(road).logln("intersect:no and included:no!");

            }
          } catch (Exception e) {
            try {
              e.printStackTrace();
              SOSArea a1 = blockades.get(i);
              SOSArea a2 = blockades.get(j);
              SOSArea a3;
              a3 = reMerge(a1, a2);
              blockades.remove(j--);
              if (!a3.getEdges().isEmpty()) {
                blockades.set(i, a3);
              }
              i--;
              break;
            } catch (Exception e1) {

            }
          }
        }
      }
    }
    return blockades;
  }