Package ch.epfl.lbd.trajectories

Examples of ch.epfl.lbd.trajectories.Trajectory


        "  ORDER BY datetime  " +
        "  LIMIT 200";
   
    ResultSet results = conn.getSQLQueryResults(query);
   
    Trajectory trj = new Trajectory();
    GPSPoint lastPt = null;
    GPSPoint pt = null;
    while (results.next()){
       Episode newEpisode;
       String tag     = results.getString("tag");
       double lat     = results.getDouble("latitude");
       double lng     = results.getDouble("longitude");
       double northing   = results.getDouble("northing")
       double easting   = results.getDouble("easting");
       int userid     = results.getInt("userid");
       Timestamp datetime = results.getTimestamp("datetime");
       String name = "";
       String desc = "";
       if(pt != null)lastPt = pt;
       pt = new GPSPoint(lat,lng,northing,easting,userid,datetime,name,desc);
       pt.comparePrePoint(lastPt);
       Episode lastEpisode = trj.getLastEpisode();
       if(tag.equalsIgnoreCase("B") || tag.equalsIgnoreCase("S")){
         if(lastEpisode != null && lastEpisode instanceof Move){
           lastEpisode.merge(new Move(pt));
         }
         newEpisode = new Stop(pt);
       }
       else{
         if(lastEpisode != null && lastEpisode instanceof Stop){
           newEpisode = new Move(lastPt);
           newEpisode.merge(new Move(pt));
         }
         else newEpisode = new Move(pt);
       }
       trj.addEpisode(newEpisode);
    }
 
    logger.info("MOVES");
    ArrayList<Move> moves = trj.getMoves();
    for(Move move : moves)logger.info(move.getAvgSpeed());
    logger.info("STOPS");
    ArrayList<Stop> stops = trj.getStops();
    for(Stop stop : stops)logger.info(stop.getAvgSpeed());

    conn.closeConnection();
  }
View Full Code Here


    //retrieving all trajectory combinations that has at least 3 moves
    Combiner trjCombinations = new Combiner();
    ArrayList<ArrayList<Integer>> movesId = trjCombinations.generate(trj.getNumberOfMoves(), 3);
   
    for(int j = 0 ; j < movesId.size() ; j++ ){
      Trajectory subTrajectory = trj.getSubTrajectory(movesId.get(j));
      for(int i = 0 ; i < this.outputs.size() ; i++){
        if(similar(subTrajectory,this.outputs.get(i))){
          this.outputs.get(i).addTrajectory();
          shared = true;
        }
View Full Code Here

      int trj_id = 1;
      int eps = 1;
      GPSPoint lastPt = null;
      GPSPoint pt = null;
     
      Trajectory trj = new Trajectory();
      while(results.next()){
         Episode newEpisode;
         String tag     = results.getString("tag");
         double lat     = results.getDouble("longitude"); //inverted on purpose
         double lng     = results.getDouble("latitude");
         double northing   = results.getDouble("northing")
         double easting   = results.getDouble("easting");
         int userid     = results.getInt("userid");
         Timestamp datetime = results.getTimestamp("datetime");
         String name = "";
         String desc = "";
        if(tag.equalsIgnoreCase("B")){
          if(trj.getLastEpisode() != null){
            Object[] values = null;
            values = new Object[9];
            values[0] = (Integer)trj_id;        //ID
            values[1] = trj.getLifeSpan().getStart()//START
            values[2] = trj.getLifeSpan().getEnd();    //END
            values[3] = trj.getMovingObject().getId()//MOVING_ENTITY
            values[4] = "";                //TYPE
            values[5] = trj.getAvgSpeed();        //AVG_SPEED
            values[6] = trj.getAvgTravelTime();      //AVG_TRAVEL_TIME
            values[7] = 0;                //GROUP_ID
            values[8] = trj.getGeometry();//GEOM

            if(values[8] != null){
              //populate values from trj obj;
              trj_table.insertRow(values);
             
              //populate the list of episodes
              ArrayList<Episode> episodes = trj.getEpisodes();
              for(int j = 0 ; j < episodes.size() ; j++ ){
                Episode episode = episodes.get(j);
                Object[] vals = new Object[9];
                String type = "";
                if(episode instanceof Move ) type = "MOVE";
                else type = "STOP";
                vals[0] = (Integer)eps;            //ID
                vals[1] = episode.getLifeSpan().getStart()//START
                vals[2] = episode.getLifeSpan().getEnd()//END
                vals[3] = trj.getMovingObject().getId()//MOVING_ENTITY
                vals[4] = type;                //TYPE
                vals[5] = episode.getAvgSpeed();      //AVG_SPEED
                vals[6] = episode.getVarSpeed();      //AVG_TRAVEL_TIME
                vals[7] = (Integer)trj_id;          //GROUP_ID
                vals[8] = episode.getGeometry();      //GEOM
                epi_table.insertRow(vals);
                eps++;
              }
             
              logger.info(trj_id+" trajectories inserted");
              trj_id++;
            }
          }
          trj = new Trajectory();
          trj.setMovingObject(new MovingObject(userid));
        }
         if(pt != null)lastPt = pt;
         pt = new GPSPoint(lat,lng,northing,easting,userid,datetime,name,desc);
         pt.comparePrePoint(lastPt);
         Episode lastEpisode = trj.getLastEpisode();
         if(tag.equalsIgnoreCase("B") || tag.equalsIgnoreCase("S")){
           if(lastEpisode != null && lastEpisode instanceof Move){
             lastEpisode.merge(new Move(pt));
           }
           newEpisode = new Stop(pt);
         }
         else{
           if(lastEpisode != null && lastEpisode instanceof Stop){
             newEpisode = new Move(lastPt);
             newEpisode.merge(new Move(pt));
           }
           else newEpisode = new Move(pt);
         }
         trj.addEpisode(newEpisode);
         i++;
      }
    }
    catch(SQLException e){
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of ch.epfl.lbd.trajectories.Trajectory

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.