Ejemplo n.º 1
0
        public void joinTrips(String day, String trip1, String trip2, TripPool t_pool)
        {
            int trip1Number = Convert.ToInt32(trip1);
            int trip2Number = Convert.ToInt32(trip2);

            //If trip1 and trip2 are the same
            if (trip1Number == trip2Number)
            {
                MessageBox.Show("Please select two different trips");
                return;
            }
            //If the trip1 is greater than trip2
            if (trip1Number > trip2Number)
            {
                String temp = trip1;
                trip1 = trip2;
                trip2 = temp;
            }
            int trip1Index = 0;
            int trip2Index = 0;

            //Now in this function we're going to join two trips.
            //So the basics of this is that we'll be copying the finishing time and co-ordinates of the first trip into the finish time and co-ordinates of the first trip.
            //So first what we'll do is find the trip that the finish time is going to go to.
            for (int i = 0; i < databaseViewer.Rows.Count; ++i)
            {
                if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip1)
                {
                    trip1Index = i;
                }
                if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip2)
                {
                    trip2Index = i;
                    break;
                }
            }
            //Now that we have the indices of the two trips, let us move the values around.
            //So the finish times and co-ordinates from trip2 go into trip1
            //But before that we'll add both rows to the undo Table and the type of action to the Undo Type Table
            addToUndotable(databaseViewer.Rows[trip2Index]);
            addToUndotable(databaseViewer.Rows[trip1Index]);
            addToUndoTypeTable("Join");
            databaseViewer.Rows[trip1Index]["Finish"] = databaseViewer.Rows[trip2Index]["Finish"];         // copy the trip2 finish time
            t_pool.getTripDetails().Rows[trip1Index]["Finish Time"] = databaseViewer.Rows[trip2Index]["Finish"];
            databaseViewer.Rows[trip1Index]["fLongitude"] = databaseViewer.Rows[trip2Index]["fLongitude"]; // copy the the trip2 longitude
            t_pool.getTripDetails().Rows[trip2Index]["FinishLong"] = databaseViewer.Rows[trip2Index]["fLongitude"];
            databaseViewer.Rows[trip1Index]["fLatitude"] = databaseViewer.Rows[trip2Index]["fLatitude"];   // copy the trip2 latitude.
            t_pool.getTripDetails().Rows[trip2Index]["FinishLat"] = databaseViewer.Rows[trip2Index]["fLatitude"];
            databaseViewer.Rows[trip2Index].Delete();                                                      // This will delete the trip2 row.
            t_pool.getTripDetails().Rows[trip2Index].Delete();
            resetTripCountForDay();
            t_pool.resetTripCount();
            t_pool.resetTripData("Trip_" + trip1);
            completeMissingData(t_pool);
            return;
        }
Ejemplo n.º 2
0
 public void makeFinish(String trip, IKmlPlacemark newFinishPoint, TripPool t_pool)
 {
     //This function will change the starting time of a trip
     //First we'll find the row to edit. The trip should match
     for (int i = 0; i < databaseViewer.Rows.Count; ++i)
     {
         if (databaseViewer.Rows[i]["KMLTrip"].ToString().Equals(trip))
         {
             addToUndotable(databaseViewer.Rows[i]);
             addToUndoTypeTable("Make Finish");
             databaseViewer.Rows[i]["Finish"]     = newFinishPoint.getName();
             databaseViewer.Rows[i]["fLongitude"] = Module.getCoordinates(newFinishPoint)["lon"];
             databaseViewer.Rows[i]["fLatitude"]  = Module.getCoordinates(newFinishPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["FinishLong"]  = Module.getCoordinates(newFinishPoint)["lon"];
             t_pool.getTripDetails().Rows[i]["FinishLat"]   = Module.getCoordinates(newFinishPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["Finish Time"] = newFinishPoint.getName();
             t_pool.resetTripData("Trip_" + trip);
             completeMissingData(t_pool, trip);
         }
     }
 }
Ejemplo n.º 3
0
        public void splitTrip(String day, String trip, IKmlPlacemark s_point, IKmlPlacemark f_point, TripPool t_pool)
        {
            //           MessageBox.Show(tripData.getFeatures().getChildNodes().getLength().ToString() + " " + point.getName() +"    "+point.getId());


            Module testModule = new Module();

            //This function will split a trip in the text file
            //First we'll need to find the day we're talking about
            for (int i = 0; i < databaseViewer.Rows.Count; ++i)
            {
                //once we have found the right day we'll go and find the right trip
                if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip)
                {
                    //Once we have found the trip we'll first have to add it to the Undo Table
                    //First we'll add the entry of what type of action was performed.
                    addToUndoTypeTable("Split");
                    addToUndotable(databaseViewer.Rows[i]);      // So we've added the whole row back into place.
                    //once we have found our trip record we'll make the further modifications
                    //Now the split point of the trip will become the finishing point of the original trip. Before we insert the new values, we should store the other values first
                    String oldFinishTime = databaseViewer.Rows[i]["Finish"].ToString();
                    String oldFinishLat  = databaseViewer.Rows[i]["fLatitude"].ToString();
                    String oldFinishLong = databaseViewer.Rows[i]["fLongitude"].ToString();
                    //Now that we've stored these values, we can safely replace these fields with the new data.
                    databaseViewer.Rows[i]["Finish"] = f_point.getName();
                    t_pool.getTripDetails().Rows[i]["Finish Time"] = f_point.getName();
                    Hashtable coords = Module.getCoordinates(f_point);
                    databaseViewer.Rows[i]["fLatitude"]  = coords["lat"];
                    databaseViewer.Rows[i]["fLongitude"] = coords["lon"];
                    t_pool.getTripDetails().Rows[i]["FinishLat"]  = coords["lat"];
                    t_pool.getTripDetails().Rows[i]["FinishLong"] = coords["long"];
                    t_pool.resetTripData("Trip_" + trip);
                    //By this time the original trip would have been modified correctly. Now we need to create a new trip and set it's fields correctly
                    //Now we need to get the details of the next point
                    //                       point = getNextPoint(tripData, point); //This should give us the next point after the split point.
                    coords = Module.getCoordinates(s_point);
                    //Now once we have all the information we'll create a new record in the table
                    DataRow newRow    = NewRowDataTableCustom();
                    DataRow newRowKML = t_pool.NewRowDataTableCustom();
                    //Most of the information will be the same as the current record
                    newRow["Day"]       = databaseViewer.Rows[i]["Day"];
                    newRow["Household"] = databaseViewer.Rows[i]["HouseHold"];
                    newRow["Person"]    = databaseViewer.Rows[i]["Person"];
                    newRow["Date"]      = databaseViewer.Rows[i]["Date"];
                    newRow["Weekday"]   = databaseViewer.Rows[i]["Weekday"];
                    newRow["Remain"]    = databaseViewer.Rows[i]["Remain"];
                    //Now we'll add the new data
                    newRow["KMLTrip"]    = (Convert.ToInt32(databaseViewer.Rows[i]["KMLTrip"]) + 1).ToString();
                    newRow["Start"]      = s_point.getName();
                    newRow["Finish"]     = oldFinishTime;
                    newRow["sLongitude"] = coords["lon"];
                    newRow["sLatitude"]  = coords["lat"];
                    newRow["fLongitude"] = oldFinishLong;
                    newRow["fLatitude"]  = oldFinishLat;
                    //Now we'll add this row in the dataTable
                    databaseViewer.Rows.InsertAt(newRow, i + 1);
                    newRowKML = copyDataRowContents(newRow, newRowKML);
                    t_pool.getTripDetails().Rows.InsertAt(newRowKML, i + 1);
                    //Now once everything is done, we'll reset the tripCount for that day
                    resetTripCountForDay();
                    t_pool.resetTripCount();
                    t_pool.resetTripData("Trip_" + (Convert.ToInt32(trip) + 1).ToString());
                    completeMissingData(t_pool);
                }
            }
        }
Ejemplo n.º 4
0
        public void splitTrip(String day, String trip, IKmlPlacemark s_point, IKmlPlacemark f_point, TripPool t_pool)
        {
            //           MessageBox.Show(tripData.getFeatures().getChildNodes().getLength().ToString() + " " + point.getName() +"    "+point.getId());

            Module testModule = new Module();
            //This function will split a trip in the text file
            //First we'll need to find the day we're talking about
            for (int i = 0; i < databaseViewer.Rows.Count; ++i)
            {
                    //once we have found the right day we'll go and find the right trip
                    if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip)
                    {
                        //Once we have found the trip we'll first have to add it to the Undo Table
                        //First we'll add the entry of what type of action was performed.
                        addToUndoTypeTable("Split");
                        addToUndotable(databaseViewer.Rows[i]);  // So we've added the whole row back into place.
                        //once we have found our trip record we'll make the further modifications
                        //Now the split point of the trip will become the finishing point of the original trip. Before we insert the new values, we should store the other values first
                        String oldFinishTime = databaseViewer.Rows[i]["Finish"].ToString();
                        String oldFinishLat = databaseViewer.Rows[i]["fLatitude"].ToString();
                        String oldFinishLong = databaseViewer.Rows[i]["fLongitude"].ToString();
                        //Now that we've stored these values, we can safely replace these fields with the new data.
                        databaseViewer.Rows[i]["Finish"] = f_point.getName();
                        t_pool.getTripDetails().Rows[i]["Finish Time"] = f_point.getName();
                        Hashtable coords = Module.getCoordinates(f_point);
                        databaseViewer.Rows[i]["fLatitude"] = coords["lat"];
                        databaseViewer.Rows[i]["fLongitude"] = coords["lon"];
                        t_pool.getTripDetails().Rows[i]["FinishLat"] = coords["lat"];
                        t_pool.getTripDetails().Rows[i]["FinishLong"] = coords["long"];
                        t_pool.resetTripData("Trip_"+ trip);
                        //By this time the original trip would have been modified correctly. Now we need to create a new trip and set it's fields correctly
                        //Now we need to get the details of the next point
             //                       point = getNextPoint(tripData, point); //This should give us the next point after the split point.
                        coords = Module.getCoordinates(s_point);
                        //Now once we have all the information we'll create a new record in the table
                        DataRow newRow = NewRowDataTableCustom();
                        DataRow newRowKML = t_pool.NewRowDataTableCustom();
                        //Most of the information will be the same as the current record
                        newRow["Day"] = databaseViewer.Rows[i]["Day"];
                        newRow["Household"] = databaseViewer.Rows[i]["HouseHold"];
                        newRow["Person"] = databaseViewer.Rows[i]["Person"];
                        newRow["Date"] = databaseViewer.Rows[i]["Date"];
                        newRow["Weekday"] = databaseViewer.Rows[i]["Weekday"];
                        newRow["Remain"] = databaseViewer.Rows[i]["Remain"];
                        //Now we'll add the new data
                        newRow["KMLTrip"] = (Convert.ToInt32(databaseViewer.Rows[i]["KMLTrip"])+1).ToString();
                        newRow["Start"] = s_point.getName();
                        newRow["Finish"] = oldFinishTime;
                        newRow["sLongitude"] = coords["lon"];
                        newRow["sLatitude"] = coords["lat"];
                        newRow["fLongitude"] = oldFinishLong;
                        newRow["fLatitude"] = oldFinishLat;
                        //Now we'll add this row in the dataTable
                        databaseViewer.Rows.InsertAt(newRow, i+1);
                        newRowKML = copyDataRowContents(newRow, newRowKML);
                        t_pool.getTripDetails().Rows.InsertAt(newRowKML, i + 1);
                        //Now once everything is done, we'll reset the tripCount for that day
                        resetTripCountForDay();
                        t_pool.resetTripCount();
                        t_pool.resetTripData("Trip_" + (Convert.ToInt32(trip)+1).ToString());
                        completeMissingData(t_pool);
                    }

            }
        }
Ejemplo n.º 5
0
 public void makeStart(String trip, IKmlPlacemark newStartPoint, TripPool t_pool)
 {
     //This function will change the starting time of a trip
     //First we'll find the row to edit. The trip should match
     for (int i = 0; i < databaseViewer.Rows.Count; ++i)
     {
         if (databaseViewer.Rows[i]["KMLTrip"].ToString().Equals(trip))
         {
             addToUndotable(databaseViewer.Rows[i]);
             addToUndoTypeTable("Make Start");
             databaseViewer.Rows[i]["Start"] = newStartPoint.getName();
             databaseViewer.Rows[i]["sLongitude"] = Module.getCoordinates(newStartPoint)["lon"];
             databaseViewer.Rows[i]["sLatitude"] = Module.getCoordinates(newStartPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["StartLong"] = Module.getCoordinates(newStartPoint)["lon"];
             t_pool.getTripDetails().Rows[i]["StartLat"] = Module.getCoordinates(newStartPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["Start Time"] = newStartPoint.getName();
             t_pool.resetTripData("Trip_" + trip);
             completeMissingData(t_pool, trip);
         }
     }
 }
Ejemplo n.º 6
0
 public void joinTrips(String day, String trip1, String trip2, TripPool t_pool)
 {
     int trip1Number = Convert.ToInt32(trip1);
     int trip2Number = Convert.ToInt32(trip2);
     //If trip1 and trip2 are the same
     if (trip1Number == trip2Number)
     {
         MessageBox.Show("Please select two different trips");
         return;
     }
     //If the trip1 is greater than trip2
     if (trip1Number > trip2Number)
     {
         String temp = trip1;
         trip1 = trip2;
         trip2 = temp;
     }
     int trip1Index = 0;
     int trip2Index = 0;
     //Now in this function we're going to join two trips.
     //So the basics of this is that we'll be copying the finishing time and co-ordinates of the first trip into the finish time and co-ordinates of the first trip.
     //So first what we'll do is find the trip that the finish time is going to go to.
     for (int i = 0; i < databaseViewer.Rows.Count; ++i)
     {
         if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip1)
         {
             trip1Index = i;
         }
         if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip2)
         {
             trip2Index = i;
             break;
         }
     }
     //Now that we have the indices of the two trips, let us move the values around.
     //So the finish times and co-ordinates from trip2 go into trip1
     //But before that we'll add both rows to the undo Table and the type of action to the Undo Type Table
     addToUndotable(databaseViewer.Rows[trip2Index]);
     addToUndotable(databaseViewer.Rows[trip1Index]);
     addToUndoTypeTable("Join");
     databaseViewer.Rows[trip1Index]["Finish"] = databaseViewer.Rows[trip2Index]["Finish"];  // copy the trip2 finish time
     t_pool.getTripDetails().Rows[trip1Index]["Finish Time"] = databaseViewer.Rows[trip2Index]["Finish"];
     databaseViewer.Rows[trip1Index]["fLongitude"] = databaseViewer.Rows[trip2Index]["fLongitude"];  // copy the the trip2 longitude
     t_pool.getTripDetails().Rows[trip2Index]["FinishLong"] = databaseViewer.Rows[trip2Index]["fLongitude"];
     databaseViewer.Rows[trip1Index]["fLatitude"] = databaseViewer.Rows[trip2Index]["fLatitude"];  // copy the trip2 latitude.
     t_pool.getTripDetails().Rows[trip2Index]["FinishLat"] = databaseViewer.Rows[trip2Index]["fLatitude"];
     databaseViewer.Rows[trip2Index].Delete();  // This will delete the trip2 row.
     t_pool.getTripDetails().Rows[trip2Index].Delete();
     resetTripCountForDay();
     t_pool.resetTripCount();
     t_pool.resetTripData("Trip_"+ trip1);
     completeMissingData(t_pool);
     return;
 }