示例#1
0
  /**
   * merge real fire zones
   *
   * @param targets
   * @param mergeList
   */
  private void mergeRealFireZones(
      Pair<ArrayList<SOSRealFireZone>, SOSEstimatedFireZone> target,
      ArrayList<SOSAbstractFireZone> mergeList) {
    if (target == null) return;
    ArrayList<SOSRealFireZone> realZones = target.first();

    getFireSites().remove(target);

    SOSRealFireZone newRealFireSite = new SOSRealFireZone(lastAssignedIndex++, this);
    SOSRealFireZone real;

    for (SOSAbstractFireZone fz : mergeList) {
      real = (SOSRealFireZone) fz;
      realZones.remove(real);
      for (Building b : real.getAllBuildings()) {
        if (!b.getSOSRealFireSite().equals(newRealFireSite)) {
          b.setSOSRealFireSite(newRealFireSite);
          newRealFireSite.addFieryBuilding(b);
          newRealFireSite.updateXY(b, 1);
        }
      }
      real.update(model.time());
    }

    realZones.add(newRealFireSite);
    getFireSites()
        .add(
            new Pair<ArrayList<SOSRealFireZone>, SOSEstimatedFireZone>(realZones, target.second()));
  }
示例#2
0
  /**
   * create new fire zones by buildings that don't belong to any existence fire zones
   *
   * @param time
   */
  private void createNewZones(int time) {
    for (Iterator<Building> it = model.fieryBuildings().iterator(); it.hasNext(); ) {
      Building b = it.next();

      if (b.getSOSEstimateFireSite() == null) {
        SOSEstimatedFireZone estimatefz = new SOSEstimatedFireZone(lastAssignedIndex, this);
        lastAssignedIndex++;
        log.info("New Estimate Fire Zone Created  " + estimatefz + "\t" + b);
        getFireSites()
            .add(
                new Pair<ArrayList<SOSRealFireZone>, SOSEstimatedFireZone>(
                    new ArrayList<SOSRealFireZone>(), estimatefz));
        updateNewSite(b, estimatefz);
        estimatefz.update(time);
      }

      if (b.getSOSRealFireSite() == null) {
        SOSRealFireZone realfz = new SOSRealFireZone(lastAssignedIndex, this);
        lastAssignedIndex++;
        log.info("New Real Fire Zone Created  " + realfz + "\t" + b);
        getFireZonePair(b.getSOSEstimateFireSite()).first().add(realfz);
        updateNewSite(b, realfz);
        realfz.update(time);
      }
    }
  }
示例#3
0
 private void updateNewSite(Building b, SOSAbstractFireZone f) { // TODO BFS
   log.info("updating building of new Site " + f + "     checkin for " + b);
   if (f instanceof SOSEstimatedFireZone) {
     if ((b.virtualData[0].getFieryness() > 0) && b.getSOSEstimateFireSite() == null) {
       f.addFieryBuilding(b);
       log.info(b + "  addet to fireSite " + f);
       b.setSOSEstimateFireSite((SOSEstimatedFireZone) f);
       for (Building b2 : b.realNeighbors_Building()) {
         updateNewSite(b2, f);
       }
     }
   } else if (f instanceof SOSRealFireZone) {
     if ((b.getFieryness() > 0) && b.getSOSRealFireSite() == null) {
       f.addFieryBuilding(b);
       log.info(b + "  addet to fireSite " + f);
       b.setSOSRealFireSite((SOSRealFireZone) f);
       for (Building b2 : b.realNeighbors_Building()) {
         updateNewSite(b2, f);
       }
     }
   }
 }