Exemple #1
0
  /* Needs Testing! */
  public Drivelane[] getLanesLeadingFrom(Drivelane lane, int ruType) throws InfraException {
    Road road = lane.getRoad();
    // Road[] which will contain the Roads of this Node in a sorted fashion:
    // [0] == the drivelanes on this Road will have to turn left to get to 'road', ..
    Road[] srt_rarr = new Road[3];

    if (allRoads[0] == road) {
      srt_rarr[0] = allRoads[1]; // Must turn left
      srt_rarr[1] = allRoads[2]; // Must go straight on
      srt_rarr[2] = allRoads[3]; // Must turn right
    } else if (allRoads[1] == road) {
      srt_rarr[0] = allRoads[2];
      srt_rarr[1] = allRoads[3];
      srt_rarr[2] = allRoads[0];
    } else if (allRoads[2] == road) {
      srt_rarr[0] = allRoads[3];
      srt_rarr[1] = allRoads[0];
      srt_rarr[2] = allRoads[1];
    } else {
      srt_rarr[0] = allRoads[0];
      srt_rarr[1] = allRoads[1];
      srt_rarr[2] = allRoads[2];
    }

    // System.out.println("Junction getLanesLeadingFrom "+nodeId);
    Vector v = new Vector();
    Drivelane[] lanes;
    int num_lanes;
    int cnt_lanes = 0;
    boolean[] targets = lane.getTargets();

    for (int i = 0; i < 3; i++) {
      if (srt_rarr[i] != null && targets[i] == true) {
        // System.out.println("Road at target:"+i+" isnt null, getting Outboundlanes");
        lanes = srt_rarr[i].getOutboundLanes(this);
        num_lanes = lanes.length;
        // System.out.println("Num lanes :"+num_lanes);
        for (int j = 0; j < num_lanes; j++) {
          Drivelane l = lanes[j];
          // System.out.println("Lane"+j+" being checked now. Has type:"+l.getType());
          if (l.mayUse(ruType)) {
            v.addElement(l);
            cnt_lanes++;
          }
        }
      }
    }
    return (Drivelane[]) v.toArray(new Drivelane[cnt_lanes]);
  }
Exemple #2
0
  public Drivelane[] getLanesLeadingTo(Drivelane lane, int ruType) throws InfraException {
    Road road = lane.getRoad();
    // Road[] which will contain the Roads of this Node in a sorted fashion:
    // [0] == the drivelanes on this Road will have to turn left to get to 'road', ..
    Road[] srt_rarr = new Road[3];

    if (allRoads[0] == road) {
      srt_rarr[0] = allRoads[3]; // Must turn left
      srt_rarr[1] = allRoads[2]; // Must go straight on
      srt_rarr[2] = allRoads[1]; // Must turn right
    } else if (allRoads[1] == road) {
      srt_rarr[0] = allRoads[0];
      srt_rarr[1] = allRoads[3];
      srt_rarr[2] = allRoads[2];
    } else if (allRoads[2] == road) {
      srt_rarr[0] = allRoads[1];
      srt_rarr[1] = allRoads[0];
      srt_rarr[2] = allRoads[3];
    } else {
      srt_rarr[0] = allRoads[2];
      srt_rarr[1] = allRoads[1];
      srt_rarr[2] = allRoads[0];
    }

    Vector v = new Vector();
    Drivelane[] lanes;
    int num_lanes;
    int cnt_lanes = 0;
    boolean[] targets;

    for (int i = 0; i < 3; i++) {
      if (srt_rarr[i] != null) {
        lanes = srt_rarr[i].getInboundLanes(this);
        num_lanes = lanes.length;
        for (int j = 0; j < num_lanes; j++) {
          Drivelane l = lanes[j];
          targets = l.getTargets();
          if (targets[i] == true && l.mayUse(ruType)) {
            v.addElement(l);
            cnt_lanes++;
          }
        }
      }
    }

    return (Drivelane[]) v.toArray(new Drivelane[cnt_lanes]);
  }
Exemple #3
0
  protected Target[] ownedTargets(Sign tl, int pos, Node des, boolean light) {
    // This method will determine to which destinations you can go starting at this source
    // represented in this QEntry

    CountEntry dummy = new CountEntry(tl, pos, des, light, tl, pos);
    Target[] ownedtargets;
    Vector candidate_targets;
    candidate_targets = new Vector();

    // Use the count table to sort this out, we need all Targets from
    // Only the elements in the count table are used, other  just give a P

    Enumeration _enum = count.elements();
    while (_enum.hasMoreElements()) {
      CountEntry current_entry = (CountEntry) _enum.nextElement();
      if (current_entry.sameSource(dummy) != 0) {
        candidate_targets.addElement(new Target(current_entry.tl_new, current_entry.pos_new));
      }
    }
    ownedtargets = new Target[candidate_targets.size()];
    candidate_targets.copyInto(ownedtargets);
    return ownedtargets;
  }
Exemple #4
0
 public void loadSecondStage(Dictionary dictionaries)
     throws XMLInvalidInputException, XMLTreeException {
   XMLUtils.loadSecondStage(count.elements(), dictionaries);
   // XMLUtils.loadSecondStage(p_table.elements(),dictionaries);
   System.out.println("SL1 second stage load finished.");
 }