Example #1
0
  /**
   * Reads the data from database and writes into detectors hashmap
   *
   * @throws SQLException
   */
  public void readDataIntoDetectorListFromDatabase() throws SQLException {

    // TestConfiguration.dbSetup();

    PeMSStationAggregateReader stationAggregateReader =
        new PeMSStationAggregateReader(oraDatabase.doConnect());
    ArrayList<Long> vdsIDs = new ArrayList<Long>();

    for (int key : detectors.keySet()) {
      vdsIDs.add((long) key);
    }
    List<PeMSStationAggregate> stationsAggregate =
        stationAggregateReader.read(
            this.timeInterval, vdsIDs, PeMSAggregate.AggregationLevel.PEMS_5MIN);

    // Read absolute detector info into the hashmap
    VDSReader stationReader = new VDSReader(oraDatabase.doConnect());
    for (int key : detectors.keySet()) {
      VDS station = stationReader.read((long) key);
      Detector d = detectors.get(key);
      d.setAbsolutePM(station.getAbsolutePostmile());
      d.setDetectorLength(station.getDetectorLength());
      d.setDetectorName(station.getDetectorName());
      d.setFreewayDirection(station.getDirection());
      d.setFreewayNumber(station.getFreewayNum());
      d.setLatitude(station.getPosition().getPoint().get(0).getLat());
      d.setLongitude(station.getPosition().getPoint().get(0).getLng());
      d.setNumberOfLanes(station.getLaneCount());
    }

    // Read 5 minute data into the hashmap
    for (int i = 0; i < stationsAggregate.size(); i++) {
      // find the detector corresponding to the current ID in the data vector and fill the fields
      // accordingly
      Detector d = detectors.get((int) stationsAggregate.get(i).getVdsId());
      d.addDatumToSpeed(stationsAggregate.get(i).getTotal().getAvgSpeed());
      d.addDatumToFlow(
          stationsAggregate.get(i).getTotal().getFlow()
              * 12
              / d
                  .getNumberOfLanes()); // to get the hourly rate at 5 minute granularity, multiply
                                        // by 12
      d.addDatumToDensity(
          stationsAggregate.get(i).getTotal().getFlow()
              * 12
              / stationsAggregate.get(i).getTotal().getAvgSpeed()
              / d.getNumberOfLanes());
      if (i < detectors.size()) {
        d.setHealthStatus(stationsAggregate.get(i).getTotal().getObserved());
      }
    }
  }
Example #2
0
 /** Reads the network geometry from mainScenario and populates the nodes hashmap */
 public void createNodeStructureFromMainScenario() {
   for (int i = 0;
       i < this.mainScenario.getNetworkList().getNetwork().get(0).getNodeList().getNode().size();
       i++) {
     ArrayList<Integer> inputs = new ArrayList<Integer>();
     ArrayList<Integer> outputs = new ArrayList<Integer>();
     Node n = new Node();
     n.setNodeID(
         Integer.parseInt(
             this.mainScenario
                 .getNetworkList()
                 .getNetwork()
                 .get(0)
                 .getNodeList()
                 .getNode()
                 .get(i)
                 .getId()));
     n.setNodeType(
         this.mainScenario
             .getNetworkList()
             .getNetwork()
             .get(0)
             .getNodeList()
             .getNode()
             .get(i)
             .getType());
     for (int j = 0;
         j
             < this.mainScenario
                 .getNetworkList()
                 .getNetwork()
                 .get(0)
                 .getNodeList()
                 .getNode()
                 .get(i)
                 .getInputs()
                 .getInput()
                 .size();
         j++) {
       inputs.add(
           Integer.parseInt(
               this.mainScenario
                   .getNetworkList()
                   .getNetwork()
                   .get(0)
                   .getNodeList()
                   .getNode()
                   .get(i)
                   .getInputs()
                   .getInput()
                   .get(j)
                   .getLinkId()));
     }
     for (int j = 0;
         j
             < this.mainScenario
                 .getNetworkList()
                 .getNetwork()
                 .get(0)
                 .getNodeList()
                 .getNode()
                 .get(i)
                 .getOutputs()
                 .getOutput()
                 .size();
         j++) {
       outputs.add(
           Integer.parseInt(
               this.mainScenario
                   .getNetworkList()
                   .getNetwork()
                   .get(0)
                   .getNodeList()
                   .getNode()
                   .get(i)
                   .getOutputs()
                   .getOutput()
                   .get(j)
                   .getLinkId()));
     }
     n.setInLinks(inputs);
     n.setOutLinks(outputs);
     nodes.put(n.getNodeID(), n);
   }
 }