Package org.worldbank.transport.tamt.shared

Examples of org.worldbank.transport.tamt.shared.SpeedDistributionRecord


  {
    String tagId = "3590f46c-6140-4555-bc73-75c7e381a843";
    String dayType = "WEEKDAY";
    double totalFlow = 27;
   
    SpeedDistributionRecord speedDistributionRecord = new SpeedDistributionRecord();
    speedDistributionRecord.setTagId(tagId);
    speedDistributionRecord.setDayType(dayType);
    speedDistributionRecord.setTotalFlow(totalFlow);
   
    SpeedDistributionRecord match = null;
    logger.debug("test getClosestSpeedDistribution");
    try {
      match = speedBinDAO.updateFromClosestDistribution(speedDistributionRecord);
    } catch (Exception e) {
      // TODO Auto-generated catch block
View Full Code Here


    logger.debug("interpolateSpeedDistribution");
    // get unobserved speed distribution records
    ArrayList<SpeedDistributionRecord> unobservedRecords = getUnobservedSpeedDistributionRecords();
   
    for (Iterator iterator = unobservedRecords.iterator(); iterator.hasNext();) {
      SpeedDistributionRecord unobserved = (SpeedDistributionRecord) iterator
          .next();
     
      SpeedDistributionRecord closestRecord = updateFromClosestDistribution(unobserved);
      //logger.debug("closestRecord=" + closestRecord);
      //TODO: can remove return parameter from updateFromClosestDistribution
     
    }
   
View Full Code Here

   
  }
 
  public SpeedDistributionRecord updateFromClosestDistribution(SpeedDistributionRecord query) throws Exception
  {
    SpeedDistributionRecord match = null;
   
    try {
     
      Connection connection = getConnection();
      Statement s = connection.createStatement();
      String tagId = query.getTagId();
      String dayType = query.getDayType();
      String hourBin = query.getHourBin(); // make sure to send into SP as int
      double totalFlow = query.getTotalFlow();
      String sql = "SELECT * FROM " +
          "TAMT_updateFromClosestDistribution('"+tagId+"','"+dayType+"', "+hourBin+", " +
          totalFlow+", "+CLOSEST_DISTRIBUTION_PERCENT_THRESHOLD+") " +
          "AS foo(tagid text, daytype text, hourbin int, " +
          "isobserved boolean, totaflow double precision, " +
          "diff double precision)";
      //logger.debug("SQL for TAMT_updateFromClosestDistribution: " + sql);
     
      /*
       * The TAMT_getClosestDistribution function always
       * returns the closest row by daytype+threshold
       * or closest row without daytype+threshold. So this
       * should always be exactly one row (no more, no less).
       */
      ResultSet r = s.executeQuery(sql);
      while(r.next())
      {
        match = new SpeedDistributionRecord();
        match.setTagId(r.getString(1));
        match.setDayType(r.getString(2));
        match.setHourBin(r.getString(3));
        match.setObserved(r.getBoolean(4));
        match.setTotalFlow(r.getDouble(5));
      }
     
    } catch (SQLException e) {
      logger.error(e.getMessage());
      throw new Exception("There was an error executing the SQL: "
View Full Code Here

        boolean isObserved = r.getBoolean("isObserved");
       
        if( !isObserved )
        {
          SpeedDistributionRecord speedDistributionRecord = new SpeedDistributionRecord();
          speedDistributionRecord.setTagId(r.getString("tagId"));
          speedDistributionRecord.setDayType(r.getString("dayType"));
          speedDistributionRecord.setHourBin(r.getString("hourBin"));
          speedDistributionRecord.setObserved(isObserved);
         
          // add it to the list of unobserved
          unobserved.add(speedDistributionRecord);
        }
       
View Full Code Here

TOP

Related Classes of org.worldbank.transport.tamt.shared.SpeedDistributionRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.