Пример #1
0
  @Before
  public void setup() {
    nw = new Network();
    nw.setName("test network");

    dp = new DensityMap();

    nw.setNodes(new ArrayList<edu.berkeley.path.model_elements_base.Node>());
    nw.setLinks(new ArrayList<edu.berkeley.path.model_elements_base.Link>());

    Node nd1;
    Node nd2;
    Link ln;

    nd1 = new Node();
    nd1.setId(1L);
    nd1.setName("one");
    nd1.setType("Highway");
    nw.getNodes().add(nd1);

    nd2 = new Node();
    nd2.setId(2L);
    nd2.setName("two");
    nd2.setType("Highway");
    nw.getNodes().add(nd2);

    ln = new Link();
    ln.setId(3L);
    ln.setName("three");
    ln.setType("Highway");
    ln.setLaneCount(4.0);
    ln.setLength(1000.0);

    ln.setBegin(nd1);
    ln.setEnd(nd2);

    nw.getLinks().add(ln);
  }
Пример #2
0
 /** Reads the network geometry from mainScenario and populates the mainlineLinks list */
 public void createMainlineLinkStructureFromMainScenario(int routeID) {
   for (int i = 0;
       i < this.mainScenario.getNetworkList().getNetwork().get(0).getLinkList().getLink().size();
       i++) {
     if (routeID != 0) {
       int routeIndex = 0;
       // find the route index
       for (routeIndex = 0;
           routeIndex < this.mainScenario.getRoutes().getRoute().size();
           routeIndex++) {
         if (Integer.parseInt(this.mainScenario.getRoutes().getRoute().get(routeIndex).getId())
             == routeID) {
           break;
         }
       }
       // go over the route and see if the link belongs to the given route
       boolean linkInRoute = false;
       for (int k = 0;
           k
               < this.mainScenario
                   .getRoutes()
                   .getRoute()
                   .get(routeIndex)
                   .getLinkReferences()
                   .getLinkReference()
                   .size();
           k++) {
         if (this.mainScenario
             .getRoutes()
             .getRoute()
             .get(routeIndex)
             .getLinkReferences()
             .getLinkReference()
             .get(k)
             .getId()
             .contentEquals(
                 this.mainScenario
                     .getNetworkList()
                     .getNetwork()
                     .get(0)
                     .getLinkList()
                     .getLink()
                     .get(i)
                     .getId())) {
           linkInRoute = true;
           break;
         }
       }
       if (!linkInRoute) {
         continue;
       }
     }
     // collect only mainline links in the links list
     if (this.mainScenario
         .getNetworkList()
         .getNetwork()
         .get(0)
         .getLinkList()
         .getLink()
         .get(i)
         .getType()
         .equals("freeway")) {
       Link l = new Link();
       boolean hasDetector = false;
       Detector detectorML = new Detector();
       l.setLinkID(
           Integer.parseInt(
               this.mainScenario
                   .getNetworkList()
                   .getNetwork()
                   .get(0)
                   .getLinkList()
                   .getLink()
                   .get(i)
                   .getId()));
       l.setUpNode(
           nodes.get(
               Integer.parseInt(
                   this.mainScenario
                       .getNetworkList()
                       .getNetwork()
                       .get(0)
                       .getLinkList()
                       .getLink()
                       .get(i)
                       .getBegin()
                       .getNodeId())));
       l.setDownNode(
           nodes.get(
               Integer.parseInt(
                   this.mainScenario
                       .getNetworkList()
                       .getNetwork()
                       .get(0)
                       .getLinkList()
                       .getLink()
                       .get(i)
                       .getEnd()
                       .getNodeId())));
       l.setUpLinks(l.getUpNode().getInLinks());
       l.setDownLinks(l.getDownNode().getOutLinks());
       l.setLength(
           this.mainScenario
               .getNetworkList()
               .getNetwork()
               .get(0)
               .getLinkList()
               .getLink()
               .get(i)
               .getLength()
               .doubleValue());
       l.setLanesML(
           this.mainScenario
               .getNetworkList()
               .getNetwork()
               .get(0)
               .getLinkList()
               .getLink()
               .get(i)
               .getLanes()
               .intValue());
       for (int key : detectors.keySet()) {
         if (detectors.get(key).getLinkAssoc() == l.getLinkID()) {
           hasDetector = true;
           detectorML = detectors.get(key);
         }
       }
       l.setHasDetector(hasDetector);
       l.setDetectorML(detectorML);
       mainlineLinks.add(l);
     }
   }
   // sort mainline links
   mainlineLinks = this.recursiveLinkSort(mainlineLinks);
 }
Пример #3
0
  /** Reads the network geometry from mainScenario and populates the links hashmap */
  public void createLinkStructureFromMainScenario() {
    for (int i = 0;
        i < this.mainScenario.getNetworkList().getNetwork().get(0).getLinkList().getLink().size();
        i++) {
      Link l = new Link();
      boolean hasDetector = false;
      Detector detectorML = new Detector();
      l.setLinkType(
          this.mainScenario
              .getNetworkList()
              .getNetwork()
              .get(0)
              .getLinkList()
              .getLink()
              .get(i)
              .getType());
      l.setLinkID(
          Integer.parseInt(
              this.mainScenario
                  .getNetworkList()
                  .getNetwork()
                  .get(0)
                  .getLinkList()
                  .getLink()
                  .get(i)
                  .getId()));
      l.setUpNode(
          nodes.get(
              Integer.parseInt(
                  this.mainScenario
                      .getNetworkList()
                      .getNetwork()
                      .get(0)
                      .getLinkList()
                      .getLink()
                      .get(i)
                      .getBegin()
                      .getNodeId())));
      l.setDownNode(
          nodes.get(
              Integer.parseInt(
                  this.mainScenario
                      .getNetworkList()
                      .getNetwork()
                      .get(0)
                      .getLinkList()
                      .getLink()
                      .get(i)
                      .getEnd()
                      .getNodeId())));
      l.setUpLinks(l.getUpNode().getInLinks());
      l.setDownLinks(l.getDownNode().getOutLinks());
      l.setLength(
          this.mainScenario
              .getNetworkList()
              .getNetwork()
              .get(0)
              .getLinkList()
              .getLink()
              .get(i)
              .getLength()
              .doubleValue());
      l.setLanesML(
          this.mainScenario
              .getNetworkList()
              .getNetwork()
              .get(0)
              .getLinkList()
              .getLink()
              .get(i)
              .getLanes()
              .intValue());
      for (int key : detectors.keySet()) {
        if (detectors.get(key).getLinkAssoc() == l.getLinkID()) {
          hasDetector = true;
          // Detector dummyDetector = detectors.get(key);
          // if (dummyDetector.getSensorType().toString().equals(arg0) //REVISIT
          detectorML = detectors.get(key);
        }
      }
      l.setHasDetector(hasDetector);
      l.setDetectorML(detectorML);

      links.put(l.getLinkID(), l);
    }
  }